Docker logging with Elastic stack

Preview:

Citation preview

01

02

Let's start!03

Dockerrrr04

Java

05

Docker and Java

06

Docker Flow

07

Ship artifacts

08

Container packaging

09

Container packaging

10

Container packaging

11

Yeah!

12

Ouch!

13

Logging14

ELK ((L)LEK)

15

ELK ((L)LEK)

16

ELK (B(L)EK)

17

ELK (B(L)EK)

18

ELK (BEK)

19

Docker logsShow container's STDERR and STDOUT.

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

20

Logging driver$ docker info | grep 'Logging Driver'

Logging Driver: json‐file

01.

02.

21

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

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

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

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

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

26

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

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

Hints (filebeat.yml)output.elasticsearch:

  hosts: ["elasticsearch:9200"]

01.

02.

29

Conclusion30

That's all!31

Thank you!32

33

Upcomingtrainings

34

DevOpsMasterClass

35

Training: DevOps MasterClass

36

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

JVM Internals38

Training: JVM Internals

39

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

Recommended