Monitor
with the Stack
Philipp Krenn@xeraa
1
Monitor with the Stack Philipp Krenn @xeraa 1 Infrastructure | - - PowerPoint PPT Presentation
Monitor with the Stack Philipp Krenn @xeraa 1 Infrastructure | Developer Advocate 2 Disclaimer This is not a training https://www.elastic.co/training 3 Who Is Using Elasticsearch Logstash and Kibana Beats 4 5 6 7
with the Stack
Philipp Krenn@xeraa
1Infrastructure | Developer Advocate
2Disclaimer
https://www.elastic.co/training
3Who Is Using
Elasticsearch Logstash and Kibana Beats
4Starting Point
https://github.com/xeraa/mongodb-monitoring
8USB Sticks
9Box
Vagrant Ansible Provisioner
10Credentials vagrant & vagrant
11SSH
$ ssh vagrant@127.0.0.1 -p 2222 -o PreferredAuthentications=password Windows: http://www.putty.org
12Ansible
$ cd /elastic-stack/ $ ls
13REST
$ curl -XGET -u "elastic:changeme" http://localhost:9200/
15Login
http://localhost:5601 elastic & changeme
17Filebeat
19Filebeat Modules
20System Dashboards
21MongoDB Logs
/var/log/mongodb/mongod.log
23/etc/filebeat/filebeat.yml
filebeat.prospectors:
paths:
document_type: mongodb
24PS: Multiline Logs
25/etc/filebeat/filebeat.yml
filebeat.prospectors:
paths:
document_type: java multiline.pattern: '^[[:space:]]' multiline.negate: false multiline.match: after
26Test
$ java -jar /opt/pocdriver/bin/POCDriver.jar -k 20 -i 10 -u 10 -b 20
27Kibana Discover
Limit Kibana view to the mongodb type
28Grok Patterns
https://github.com/logstash-plugins/logstash-patterns- core/blob/master/patterns/grok-patterns
30MongoDB Patterns
https://github.com/logstash-plugins/logstash-patterns- core/blob/master/patterns/mongodb
31Building Patterns
Grokdebug in Kibana 5.5+ (X-Pack Basic)
https://grokdebug.herokuapp.com
32/etc/filebeat/filebeat.yml
hosts: ["localhost:9200"] username: "{{ elastic_user }}" password: "{{ elastic_password }}" pipeline: "mongodb_log"
34Console
Pattern in a single line
PUT _ingest/pipeline/mongodb_log { "description": "Ingest pipeline for MongoDB logs", "processors": [ { "grok": { "field": "message", "patterns": [ "%{TIMESTAMP_ISO8601:timestamp}%{SPACE}%{MONGO3_SEVERITY:mongodb.severity} %{SPACE}%{MONGO3_COMPONENT:mongodb.component}%{SPACE} (?:[%{DATA:mongodb.context}])?%{SPACE}%{GREEDYDATA:message}" ] } } ] } 35Filebeat Restart
$ sudo service filebeat restart
36Test
$ java -jar /opt/pocdriver/bin/POCDriver.jar -k 20 -i 10 -u 10 -b 20
37Refresh Field List
Management → Index Patterns → filebeat-* → Refresh field list
38Visualize
mongodb.component of log events
39Fetch the Slow Log
42/etc/logstash/conf.d/00-mongodb- input.conf
input { mongodb { uri => 'mongodb://127.0.0.1:27017/POCDB' placeholder_db_dir => '/var/local/logstash-mongodb/' collection => 'system.profile' batch_size => 500 generateId => true } }
43/etc/logstash/conf.d/20-elasticsearch-
elasticsearch { hosts => ["localhost:9200"] manage_template => false index => "mongodb-%{+YYYY.MM.dd}" document_type => "slowlog" user => "{{ elastic_user }}" password => "{{ elastic_password }}" } }
44Logstash Restart
$ sudo service logstash restart
45Debug Logstash
$ less /var/log/logstash/logstash-plain.log
46Doesn't Work
Getting data from system collections
https://github.com/phutchins/logstash-input-mongodb/issues/8
47Extension Idea
Build an exec filter to run slow queries against MongoDB's .explain()
48Metricbeat
49Metricbeat System
50Metricbeat Service
51/etc/metricbeat/metricbeat.yml
metricsets: ["dbstats", "status"] hosts: ["localhost:27017"]
52Metricbeat Restart
$ sudo service metricbeat restart
53Test
$ java -jar /opt/pocdriver/bin/POCDriver.jar -k 20 -i 10 -u 10 -b 20
54Visual Builder
mongodb.status.network.in.bytes vs mongodb.status.network.out.bytes
56Packetbeat
58Protocols
59Flows
Application layer: Unsupported / encrypted (TLS) protocols IP / TCP / UDP Number of packets & bytes Retransmissions Temporal flow
60/etc/packetbeat/packetbeat.yml
packetbeat.protocols.mongodb: ports: [27017]
61Packetbeat Restart
$ sudo service packetbeat restart
62Test
$ java -jar /opt/pocdriver/bin/POCDriver.jar -k 20 -i 10 -u 10 -b 20
63Heartbeat
65Heartbeat
ICMP, TCP, HTTP, HTTPS
66/etc/heartbeat/heartbeat.yml
heartbeat.monitors:
hosts: ["127.0.0.1:27017"] schedule: '@every 10s'
67Heartbeat Restart
$ sudo service heartbeat restart
68Test
$ sudo service mongod stop $ sudo service mongod start
69Visualize
Up or down and TCP response times
70Dashboard
Combining visualizations
73Winlogbeat
75libbeat
https://github.com/elastic/beats/tree/master/generate/beat
76X-Pack
Security Monitoring Graph Reporting Alerting Machine Learning
78X-Pack Basic
79Thanks!
Philipp Krenn@xeraa
84