Slide 1

Slide 1 text

Monitor Your Containers with the Stack Philipp Krenn̴̴̴̴̴@xeraa

Slide 2

Slide 2 text

Infrastructure | Developer Advocate

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

$ curl http://localhost:9200 { "name": "zDODSc4", "cluster_name": "docker-cluster", "cluster_uuid": "qbx3DVATRfWOgHB6uiLtNw", "version": { "number": "6.3.0", "build_flavor": "default", "build_type": "tar", "build_hash": "424e937", "build_date": "2018-06-11T23:38:03.357887Z", "build_snapshot": false, "lucene_version": "7.3.1", "minimum_wire_compatibility_version": "5.6.0", "minimum_index_compatibility_version": "5.0.0" }, "tagline": "You Know, for Search" }

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Filebeat

Slide 16

Slide 16 text

tail -f ̴ ̴

Slide 17

Slide 17 text

tail -f over the network ̴

Slide 18

Slide 18 text

tail -f over the network on

Slide 19

Slide 19 text

Parse & Enrich Logstash or Ingest-Node

Slide 20

Slide 20 text

34.253.145.46 - - [06/Sep/2017:22:33:30 +0000] "GET /server-status HTTP/1.1" 200 97 "-" "Go-http-client/1.1" "-" "remote_ip": "34.253.145.46", "method": "GET", "url": "/server-status", "http_version": "1.1", "response_code": 200,

Slide 21

Slide 21 text

"remote_ip": "34.253.145.46" "geoip": { "continent_name": "North America", "city_name": "Houston", "country_iso_code": "US", "region_name": "Texas", "location": { "lon": -95.5858, "lat": 29.6997 } }

Slide 22

Slide 22 text

At-Least-Once Backpressure Graceful Downtime

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Filtering include_lines̴̴exclude_lines̴̴exclude_files filebeat.prospectors: - input_type: log paths: - /var/log/myapp/*.log include_lines: ["^ERR", "^WARN"]

Slide 27

Slide 27 text

Multiline Exception in thread "main" java.lang.IllegalStateException: A book has a null property at com.example.myproject.Author.getBookIds(Author.java:38) at com.example.myproject.Bootstrap.main(Bootstrap.java:14) Caused by: java.lang.NullPointerException at com.example.myproject.Book.getId(Book.java:22) at com.example.myproject.Author.getBookIds(Author.java:35) ... 1 more multiline.pattern: '^[[:space:]]+|^Caused by:' multiline.negate: false multiline.match: after

Slide 28

Slide 28 text

JSON Decode

Slide 29

Slide 29 text

Filebeat Modules Apache2, Auditd, Icinga, IIS, Kafka, Logstash, MongoDB, MySQL, Nginx, Osquery, PostgreSQL, Redis, System, Traefik

Slide 30

Slide 30 text

Logging with Docker 101 options

Slide 31

Slide 31 text

https://docs.docker.com/engine/admin/logging/overview/

Slide 32

Slide 32 text

001 JSON-File Filebeat for JSON ➕ Simple, default, well integrated Metadata (name, labels,...) docker logs ➖ Potentially slow By default unlimited file size

Slide 33

Slide 33 text

010 Syslog Local Syslog server and Filebeat ➕ Configurable path, rotation,... ➖ Custom Syslog server Metadaten serialized and deserialized Multiline

Slide 34

Slide 34 text

011 Journald Filebeat ➕ Widely available Metadata docker logs ➖ Not yet supported by Filebeat (Community Beat: Journalbeat)

Slide 35

Slide 35 text

100 GELF Logstash-GELF-Input ➕ Direct Logstash connection ➖ UDP — no ACK, no backpressure

Slide 36

Slide 36 text

101 Volume Filebeat ➕ Simple installation (if app rotates logs) Scalable ➖ Metadata

Slide 37

Slide 37 text

! Today: JSON, Syslog, Volume Future: Journald

Slide 38

Slide 38 text

Docker Metadata - input_type: log paths: - /var/lib/docker/containers/*/*-json.log document_type: docker json.message_key: log processors: - add_docker_metadata: ~

Slide 39

Slide 39 text

Kubernetes Metadata processors: - add_kubernetes_metadata: in_cluster: true

Slide 40

Slide 40 text

Metricbeat

Slide 41

Slide 41 text

Metricbeat System

Slide 42

Slide 42 text

Metricbeat Service Many: https://www.elastic.co/guide/en/ beats/metricbeat/current/metricbeat- modules.html

Slide 43

Slide 43 text

Read cgroup data from /proc/

Slide 44

Slide 44 text

Part of the system module

Slide 45

Slide 45 text

No Docker API access required Security

Slide 46

Slide 46 text

All containers Docker, rkt, runC, LXD,...

Slide 47

Slide 47 text

Enriches process information automatically with cgroup data

Slide 48

Slide 48 text

No container names or labels

Slide 49

Slide 49 text

But Docker...

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Dockerbeat https://github.com/Ingensi/dockerbeat

Slide 52

Slide 52 text

Dockerbeat https://github.com/Ingensi/dockerbeat

Slide 53

Slide 53 text

Dockbeat https://github.com/Ingensi/dockbeat

Slide 54

Slide 54 text

Metricbeat 5.1+

Slide 55

Slide 55 text

System Permissions $ docker run \ --volume=/proc:/hostfs/proc:ro \ --volume=/sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro \ --volume=/:/hostfs:ro \ --net=host docker.elastic.co/beats/metricbeat:6.3.0 -system.hostfs=/hostfs

Slide 56

Slide 56 text

Service Permissions $ docker run \ --link some-mysql:mysql \ -e MYSQL_PASSWORD=secret \ docker.elastic.co/beats/metricbeat:6.3.0

Slide 57

Slide 57 text

Metricbeat and Docker

Slide 58

Slide 58 text

Docker Metadata processors: - add_docker_metadata: ~

Slide 59

Slide 59 text

Kubernetes Metadata processors: - add_kubernetes_metadata: in_cluster: true

Slide 60

Slide 60 text

Kubernetes Metrics - module: kubelet metricsets: ["node", "container", "volume", "pod", "system"] hosts: ["localhost:10255"]

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Packetbeat

Slide 63

Slide 63 text

Protocols

Slide 64

Slide 64 text

Flows Application layer: Unsupported or encrypted protocols IP / TCP / UDP Number of packets & bytes Retransmissions Temporal flow

Slide 65

Slide 65 text

Packetbeat and Docker

Slide 66

Slide 66 text

Auditbeat

Slide 67

Slide 67 text

Linux Kernel File Integrity

Slide 68

Slide 68 text

Heartbeat

Slide 69

Slide 69 text

Winlogbeat

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

https://github.com/elastic/elasticsearch-docker https://github.com/elastic/kibana-docker https://github.com/elastic/logstash-docker https://github.com/elastic/beats-docker

Slide 72

Slide 72 text

--- version: '2' services: kibana: image: docker.elastic.co/kibana/kibana:6.3.0 links: - elasticsearch ports: - 5601:5601 elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:6.3.0 volumes: - esdata:/usr/share/elasticsearch/data ports: - 9200:9200 volumes: esdata: driver: local

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

Demo https://github.com/xeraa/elastic-docker/ tree/master/full_stack Elasticsearch, Kibana, Filebeat, Heartbeat, Metricbeat, Packetbeat, nginx, MySQL

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Conclusion

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

Questions? Philipp Krenn̴̴̴̴̴@xeraa PS: Sticker