アプリケーション(パフォーマンス) 監視入門 - Elastic編 Jun Ohtani, Developer | Evangelist 2019/06/29 とちぎRuby会議 08

スライドについて • スライドは公開してます 2

about • Me, Jun Ohtani / Community Engineer ‒ lucene-gosenコミッター ‒ データ分析基盤構築入門 共著 ‒ http://blog.johtani.info • Elastic, founded in 2012 ‒ Products: Elasticsearch, Logstash, Kibana, Beats Elastic APM, Elastic Cloud, Swiftype Professional services: Support & development subscriptions Trainings, Consulting, SaaS 3

Kibana、ログだけじゃないし 監視系の話もできないとなぁ

5

これだ! (インスパイアされてみました)

アジェンダ • 監視とは? • Elastic Stackとは? • 様々な観点からのアプリケーションの監視 • さらに色々試してみるには? 7

監視とは?

Subtitle sentence case (Open Sans 18pt) 9

Subtitle sentence case (Open Sans 18pt) 10

マイクロサービス (Wikipedia) Subtitle sentence case (Open Sans 18pt) https://ja.wikipedia.org/wiki/マイクロサービス 11

モノリシック v.s. マイクロサービス 12

マイクロサービス??? 13

Elastic Stackとは?

Application Search Site Search Metrics APM Enterprise Search Logging Business Analytics Security Analytics Future ソリューション Kibana 可視化、管理 Elasticsearch 保存、検索、分析 Elastic Stack Beats SaaS Elastic Cloud 15 インジェスト Logstash Self Managed Elastic Cloud Enterprise Standalone デプロイ

デモサイト GCEインスタンス 16 GCEインスタンス APM Ruby Heartbeat Filebeat Filebeat Metricbeat Metricbeat Packetbeat Packetbeat Auditbeat Auditbeat

デモサイト https://www.johtani.dev 17

アプリケーションの 監視ポイント

監視ポイント • 外形監視 • メトリック(メトリクス) • サーバー、アプリケーション • ログ • アプリケーションのリリースタイミング • 分散トレーシング 19

外形監視 • 死活監視 20 • プロセス • HTTPサーバー • TCP • ICMP

Heartbeat Lightweight Shipper for Uptime Monitoring

Uptime UI Dedicated Uptime Monitoring UI for Kibana

メトリック • サーバー • • アプリケーション • • リクエスト数、コネクション数、処理時間 コンテナー • 23 CPU、メモリ、ディスク、ネットワークI/O、プロセス数 コンテナ数

Metricbeat Collect system and application metrics

Metricbeat lots of modules

Metricbeat モジュール 26 ● ● ● ● ● ● ● ● ● ● ● ● ● ● Aerospike module Apache module aws module Ceph module Couchbase module couchdb module Docker module Dropwizard module Elasticsearch module envoyproxy module Etcd module Golang module Graphite module HAProxy module ● ● ● ● ● ● ● ● ● ● ● ● ● HTTP module Jolokia module Kafka module Kibana module Kubernetes module kvm module Logstash module Memcached module MongoDB module mssql module Munin module MySQL module Nats module ● ● ● ● ● ● ● ● ● ● ● Nginx module PHP_FPM module PostgreSQL module Prometheus module RabbitMQ module Redis module System module traefik module uwsgi module vSphere module Windows module ZooKeeper module

ログ • アクセスログ • システムログ • 認証ログ • スローログ • アプリケーションログ 27

Filebeat tail log from file

Filebeat many modules

Filebeat modules - v7.0.0 • Apache module • Auditd module • Elasticsearch module • haproxy module • Icinga module • IIS module • Iptables module • Kafka module • PostgreSQL module • Kibana module • Redis module • Logstash module • Santa module • MongoDB module • Suricata module • MySQL module • System module • Nginx module • Traefik module • Osquery module • Zeek (Bro) Module

winlogbeat Welcome to 1998

winlogbeat Now

Packetbeat Capture the Packet

Packetbeat Capture the Packet

アプリケーションのリリースタイミング • バグフィックスリリース • 新機能リリース • 新サービス開始 • サーバー増強 35

Time Series Visual Builder Annotations on Visualization

分散トレーシング • マイクロサービス • 1つのリクエストに対して複数のプロセスが関係 • アプリケーションパフォーマンスモニタリングの1つ 37

38

サポート言語 • Node.js • Python • Ruby • Go • Java • .NET • RUM - Real User Monitoring JavaScript Agent 39

Elastic APM 40

Distributed Tracing Beta | Basic (free) 全ての計測されたサービスを見るための 統合されたビュー サブコンテキスト内のトレースに遷移 OpenTracing 互換

Deployment Dashboards OSS Beats App - Basic (free) Logs Metrics Packets … Logstash Datastore JMX OSS APM Agents #42 OSS APM Server Elasticsearch Kibana

APM Ruby Agent Framework Support • Ruby on Rails >= 4.x • Sinatra and Rack compatible frameworks 43

APM Ruby Agent with Rails How to use with Rails • Add elastic-apm gem in Gemfile • Create elastic_apm.yml file under config dir • See reference for other configurations https://www.elastic.co/guide/en/apm/agent/ruby/current/ configuration.html 44

そのほかの便利な機能 • Infra UI • Logs UI • Machine Learning • Alerting 45

Infrastructure Solution Beta | Basic (free) インフラオペレーター向けに特化 1000を超えるインフラの構成を俯瞰 Kubernetes、Docker のネイティブサ ポート メトリック、ログ、APM ビューへの ドリル・ダウン アドホックおよび構造化検索

Logs Solution Beta | Basic (free) ライブでログのトラブルシューティング を助ける軽量なログビューアー コンソールのような表示 (tail -fのような)ライブ・ログ・ストリー ミング 履歴ログの無限スクロール アドホックおよび構造化検索

さらに活用するには?

52

53

参考サイト • ユースケース • https://www.elastic.co/use-cases • Discuss(Webフォーラム) • https://discuss.elastic.co • Elastic{ON}のビデオと資料 • https://www.elastic.co/elasticon/videos • サポートメニュー • https://www.elastic.co/subscriptions 54

参考文献 • Elasticsearch - The Definitive guide ‒ http://www.elastic.co/guide/en/elasticsearch/guide/current/ index.html • 書籍(日本語) ‒ データ分析基盤構築入門 ‒ Elasticsearch実践ガイド 55

参考文献 • 入門 監視 ―モダンなモニタリングのためのデザインパターン Mike Julian 著、松浦 隼人 訳 https://www.oreilly.co.jp/books/9784873118642/ 56

Thank you! ● ● ● ● Sample: https://github.com/johtani/monitoring-ruby-app Web : https://www.elastic.co/jp/ Forums : https://discuss.elastic.co/ Twitter : @johtani