40
01

Docker logging with Elastic stack

Embed Size (px)

Citation preview

Page 1: Docker logging with Elastic stack

01

Page 2: Docker logging with Elastic stack

02

Page 3: Docker logging with Elastic stack

Let's start!03

Page 4: Docker logging with Elastic stack

Dockerrrr04

Page 5: Docker logging with Elastic stack

Java

05

Page 6: Docker logging with Elastic stack

Docker and Java

06

Page 7: Docker logging with Elastic stack

Docker Flow

07

Page 8: Docker logging with Elastic stack

Ship artifacts

08

Page 9: Docker logging with Elastic stack

Container packaging

09

Page 10: Docker logging with Elastic stack

Container packaging

10

Page 11: Docker logging with Elastic stack

Container packaging

11

Page 12: Docker logging with Elastic stack

Yeah!

12

Page 13: Docker logging with Elastic stack

Ouch!

13

Page 14: Docker logging with Elastic stack

Logging14

Page 15: Docker logging with Elastic stack

ELK ((L)LEK)

15

Page 16: Docker logging with Elastic stack

ELK ((L)LEK)

16

Page 17: Docker logging with Elastic stack

ELK (B(L)EK)

17

Page 18: Docker logging with Elastic stack

ELK (B(L)EK)

18

Page 19: Docker logging with Elastic stack

ELK (BEK)

19

Page 20: Docker logging with Elastic stack

Docker logsShow container's STDERR and STDOUT.

docker logs [‐f] [‐t] CONTAINER_ID01.

20

Page 21: Docker logging with Elastic stack

Logging driver$ docker info | grep 'Logging Driver'

Logging Driver: json‐file

01.

02.

21

Page 22: Docker logging with Elastic stack

Find the logs$ docker run ‐itd jenkins

67aa...

$ tail ‐f /var/lib/docker/containers/67aa.../67aa..._json.log

...

{"log":"INFO: Jenkins is fully up and running\r\n",

 "stream":"stdout","time":"2017‐02‐06T02:15:23.087459653Z"}

01.

02.

03.

04.

05.

06.

22

Page 23: Docker logging with Elastic stack

Redirecting to syslogsudo docker run ‐i ‐t ‐d \

   ‐‐log‐driver=syslog \

   ‐‐log‐opt syslog‐address=tcp://127.0.0.1:5000 \

   jenkins

01.

02.

03.

04.

23

Page 24: Docker logging with Elastic stack

VolumesIf application has several log files, they can be shared through

volumes.

Logging agent can monitor those volumes and send data to log

aggregators.

24

Page 25: Docker logging with Elastic stack

Let's play with itStart ElasticSearch in a container.

Change PetClinic to log in JSON format.

Start File Beat in a container and make it send PetClinic container

JSON log to ElasticSearch.

Start Kibana in a container and observe the result.

•••

25

Page 26: Docker logging with Elastic stack

HintsUse https://github.com/logstash/logstash­logback­encoder.•

26

Page 27: Docker logging with Elastic stack

Hintsdocker network create elk

docker run ‐dit ‐‐net=elk ‐‐name=elasticsearch ‐p

9200:9200 ‐p 9300:9300 elasticsearch:5.2.0

docker run ‐dit ‐‐net=elk ‐‐name=kibana ‐p 5601:5601

kibana:5.2.0

••

27

Page 28: Docker logging with Elastic stack

Hints (filebeat.yml)filebeat.prospectors:

‐ input_type: log

    paths: ["...."]

    json.keys_under_root: true

    json.overwrite_keys: true

    json.add_error_key: true

    json.message_key: "message"

    tags: ["json"]

01.

02.

03.

04.

05.

06.

07.

08.

28

Page 29: Docker logging with Elastic stack

Hints (filebeat.yml)output.elasticsearch:

  hosts: ["elasticsearch:9200"]

01.

02.

29

Page 30: Docker logging with Elastic stack

Conclusion30

Page 31: Docker logging with Elastic stack

That's all!31

Page 32: Docker logging with Elastic stack

Thank you!32

Page 33: Docker logging with Elastic stack

33

Page 34: Docker logging with Elastic stack

Upcomingtrainings

34

Page 35: Docker logging with Elastic stack

DevOpsMasterClass

35

Page 36: Docker logging with Elastic stack

Training: DevOps MasterClass

36

Page 37: Docker logging with Elastic stack

Training: DevOps MasterClasshttp://bit.ly/devops_stockholm

Stockholm, 27th­28th of March, 22nd­23rd of May, 2017

http://bit.ly/devops_riga

Riga, 8th­9th of May, 2017

••••

37

Page 38: Docker logging with Elastic stack

JVM Internals38

Page 39: Docker logging with Elastic stack

Training: JVM Internals

39

Page 40: Docker logging with Elastic stack

Training: JVM Internalshttp://bit.ly/jvm_stockholm

Stockholm, 24th­25th of May, 2017

http://devchampions.com/training/jvm/

Riga, 18th­19th of May, 2017

••••

40