SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
Docker Logging
and analysing with
Elastic Stack
JAKUB HAJEK,
jakub.hajek@cometari.com, @_jakubhajek November 2019, Warsaw
www.devopsdays.pl
Introduction
• I am the owner and technical consultant working for Cometari
• I have been system admin since 1998.
• Cometari is a solution company implementing DevOps culture, providing
consultancy, workshops and software services.
• Our areas of expertise are DevOps, Elastic Stack (log analysis), Cloud
Computing.
• We are very deeply involved in the travel tech industry, however our solutions go
much further than just integrating travel API’s.
—
“I strongly believe that implementing DevOps
culture, across the entire organisation, should
provide measurable value and solve the real
issue rather than generate a new one.”
Agenda
• A little bit of the theory about logs.
• The major difference with old fashioned approach comparing to container world.
• Distributed logging with Elasticsearch and Fluentd
• Demo of logging based on live demos:
• A simple example sending logs from container to Fluentd
• Fully fledged environment running on Docker Swarm with deployed:
Elasticsearch Cluster, Kibana and Fluentd
• Deployed application stack contains multi tier application stack including Traefik
frontend and backend application
For what for do we need to collect
logs?
What are logs?
What are logs?
• Logs are the stream of aggregated, time ordered events collected from the
output stream
• The output stream can be generated by processes and backing services
• Raw logs are typically a text format with one event per line
• Backtraces from exceptions are usually multiline
• Logs have no beginning or end but flows continuously as long as the app is
operating.
Logging considerations
• Logging is not cheap. Requires lots of computing: storage, cpu, memory.
• Logging can be even expensive if you want to search against logs and correlate data.
• Having “LIVE” data accessible immediately can be even more expensive.
• Don’t log everything, consider which data you are interested in (it’s not for free)
• Logging retention time have to be considered (Curator if you store logs in Elasticsearch)
• I recommend Elasticsearch to keep logs as a time based data. It requires some
experience with Elasticsearch to provide reliable environment for logs.
• Logging is a mess ; Logging is not fun but we have to deal with it and build logging
solution
Logging in production
• Service logs
• Web access logs
• Transaction Logs
• Distributed tracing
• System Logs
• Syslog, system and other logs
• Audit logs
• Basic operating system metrics (CPU, memory, load …)
Logs for Business
KPI
Machine Learning
Predctive analytics
…
Logs for Service
System monitoring
Bottleneck
Troubleshooting
…
Logging is not the same as Monitoring
• Logging is recording to diagnose a system
• Monitoring is an observation, checking and than recording
• A Notification ( usually called alerts) can be send out to any notification
channels for both: logging and monitoring
• The notification can be triggered when specific criteria is met. e.g.
Http_requests_response_code is 500 in the last 60 seconds
A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main_dlq
Plugin: <LogStash::Inputs::DeadLetterQueue pipeline_id=>"main", path=>"/usr/share/logstash/data/dead_letter_queue", id=>"830027210528f50ad1234fe96f0ccc5f8a6989bb0b2d944881373ec56e555357", commit_offsets=>true,
enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_32044710-aeb5-4303-ba0e-2feb2dd851e9", enable_metric=>true, charset=>"UTF-8">>
Error:
Exception: Java::JavaNio::BufferOverflowException
Stack: java.nio.HeapByteBuffer.put(java/nio/HeapByteBuffer.java:189)
eas_errors{errorType=“CONTENT”,provider=“HRS",requestName="HotelAvailability", 
errorId=“1234",errorSeverity="2",startDate="2019-11-20T22:00:00",endDate="2019-11-21T21:59:59",} 10.0
Standard approach of logging to file
system
Writing message to a log file
Application
LOGS Logging}
Files -> Multiple places (usually /var/log)
Application
STDOUT 1 STDERR 2STDIN
Standard I/O Streams
{ echo "stdout"; echo "stderr" 1>&2; } | grep -v std
STDOUT 1 STDERR 2
Logging in container World!
The container world
Bare metal Container world
Service architecture Monolithic Microservices
System image Mutable Immutable
Local data Persistent Ephemeral
Network Physical Address No fixed address
Environment Manually / Automation Orchestration tools
Logging syslogd/rsync ?
*There is nothing wrong with monolithic system
unless you can distinguish boundaries in the system and
move that domain to the service on demand !
What are the challenges with logs in
container world?
Logging challenges with Containers
• No permanent storage (Container are stateless and storage is Ephemeral
• No fixed physical address.
• No fixed mapping between server and roles
• Lots of various application types
• Transfer logs immediately to distributed logging infrastructure
• Push logs from containers
• Labels logs with service name or use tags
• Need to handle various logs with regexp, GROK
Logging and Docker containers
Logging and Docker container strategy
• Application should writes a message to the STDOUT
STDOUT
APPLICATION running in
Docker container
Hello World!
Logging and Docker container strategy
• Message encapsulated in a JSON map (with JSON driver) structure via Docker.
Hello World!
{
“log” : “hello World!”,
“stream”: “stdout”,
“time”: “timestamp"
}
Logging and Docker container strategy
/var/log/docker/containers/00fae94d9a721bec312dba411…
f55f37e37/00fae94d9a721bec312dba41168231…6303f274f55f37e37-json.log
$: docker run -d busybox echo -n “Hello World!"
00fae94d9a721bec312dba411682313a4ab8846f01f7b406303f274f55f37e37
> cat
00fae94d9a721bec312dba411682313a4ab8846f01f7b406303f274f55f37e37-
json.log
{
“log”:”HelloWorld!",
“stream":"stdout",
“time":"2019-11-21T14:12:01.599413578Z"
}
Application running in a cluster
Node1
Node10
Node2 Node3
Node…nNode20
Region A Region B
Region C Region D
What is the approach to the logging
in the container world?
Treat logs as an event stream
Treat logs as an event stream
• Application should be stateless and does not store data / logs locally.
• Logs should not attempt to write to local storage
• Logs should not be managed locally, e.g. logrotate
• All logs should be treated as an event streams
• Each running process writes its event to STDOUT and STDERR
• In container based environment logging should be sent to STDOUT
Logging in the context of distributed
cluster
HOTELS
INSURENCES
RAILS
CARS
FLIGHTS INVOICESPAYMENTSPROFILESSEARCH
API GATEWAY
USERS
PROFILES PAYMENTS INVOICESSEARCHFLIGHTS
CARS
HOTELS
RAILS
INSURANCE
APP LOGS
API GATEWAY
Live aggregated logs
KPI, Dashboards
Analytics
grep / awk / Perl :-)
Log collectors for Central logging
• Logstash from Elastic Stack, Fluentd, Apache Flume and many more…
LOGS LOG COLLECTOR STORAGE
• Example storage options:
• S3, MongoDB, Hadoop, Elasticsearch
• file, forward, copy, stdout (useful for debugging)
Fluentd data collector
• An extensible and reliable data collection.
• Unified Logging Layer - treats logs as JSON
• Pluggable Architecture
• Supports memory and file based buffering to prevent internode data lost
• Built-in HA and load balancing
CORE
• Divide and conquer
• Buffering and retries
• Error Handling
• Message routing
• Parallelism
PLUGINS
• Read data
• Parse data
• Buffer data
• Write data
• Format data
Unifying logging layer
Services Services
Collector nodes
Aggregator Nodes
Elasticsearch
Fluentd
Application generates logs
Convert raw log data
in a structured data
Aggregated structured data
Structured Data Ready for analysis
An event in Fluentd
TAG: myapp.access
TIME: (current time)
RECORD: {“event”: “data”}
INPUT PARSER FILTER BUFFER OUTPUT FORMATTER
Internal architecture of plugins
“input-ish” “output-ish”
TAG TIME
RECORD
ROUTER
input - filter Output
Chunk
Chunk
Chunk
Metadata
Metadata
Metadata
BUFFER
Chunk
QUEUE
Chunk
ChunkChunk
Chunk
Process
Format
Write
Try _write OUTPUT
EMIT
ENQUEUE
source: https://docs.fluentd.org/output
Brief overview of configuration
• <source> where all the data come from, routing engine
• <match> Tell Fluentd what to do!
• <filter> Event processing pipeline
• INPUT -> filter 1 -> …. -> filter N -> OUTPUT
• <system> - system directive
• <label> use for grouping filter and output for internal routing
• @include split config into multiple files and re-use configuration
Source: https://docs.fluentd.org/configuration/config-file
<source>
@type forward
port 24223
bind 0.0.0.0
tag backend.invoice
</source>
<filter **>
@type parser
key_name log
reserve_data true
hash_value_field log
….
<parse>
@type multi_format
<pattern>
format json
</pattern>
…
</parse>
</source>
<match **>
@type Elasticsearch
host “#{ENV[‘ES_HOST’]}”
Port 9200
id_key hash
remove_keys hash
type_name doc
logstash_format true
logstash_dateformat %Y.%m
logstash_prefix logs
logstash_tag_key true
tag_key serviceTagName
…
<buffer tag>
@type memory
flush_thread_count 2
</buffer>
</match>
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<match backend.*>
@type mongo
Database fluent
Collection test
</match>
Docker fluentd driver
• The logging driver sends container logs to Fluentd in as structured log data
• Metadata: container_id, container_name, source, logs
• —log-driver fluentd —log-opt tag=docker.{{.ID} —log-opt fluentd-
address=tcp://fluenthost
• Messages are buffered until connection is established.
• The data can be buffered before flushing
• Retry, max-retry, sub-second-precision…
Architecture of the demo
environment
FLUENTD ELASTICSEARCH KIBANA
TRAEFIK
Frontend
BACKEND
Live demo & Examples of code
JAKUB HAJEK,
JAKUB.HAJEK@COMETARI.COM, @_jakubhajek
I'm waiting for
your feedback!
You can rate speakers and lectures
using our official conference app

Weitere ähnliche Inhalte

Was ist angesagt?

Open Source Logging and Metric Tools
Open Source Logging and Metric ToolsOpen Source Logging and Metric Tools
Open Source Logging and Metric ToolsPhase2
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017Andrus Adamchik
 
Advanced troubleshooting linux performance
Advanced troubleshooting linux performanceAdvanced troubleshooting linux performance
Advanced troubleshooting linux performanceForthscale
 
Data Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageSATOSHI TAGOMORI
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDSean Chittenden
 
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)Mitsunori Komatsu
 
Tuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsTuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsSematext Group, Inc.
 
Logstash family introduction
Logstash family introductionLogstash family introduction
Logstash family introductionOwen Wu
 
Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logsSmartLogic
 
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.Airat Khisamov
 
Elasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveElasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveSematext Group, Inc.
 
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...ForgeRock
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Puppet
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'Cloud Elements
 
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Oleksiy Panchenko
 

Was ist angesagt? (20)

Open Source Logging and Metric Tools
Open Source Logging and Metric ToolsOpen Source Logging and Metric Tools
Open Source Logging and Metric Tools
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017
 
Advanced troubleshooting linux performance
Advanced troubleshooting linux performanceAdvanced troubleshooting linux performance
Advanced troubleshooting linux performance
 
Data Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby Usage
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
 
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
 
Using Logstash, elasticsearch & kibana
Using Logstash, elasticsearch & kibanaUsing Logstash, elasticsearch & kibana
Using Logstash, elasticsearch & kibana
 
elk_stack_alexander_szalonnas
elk_stack_alexander_szalonnaselk_stack_alexander_szalonnas
elk_stack_alexander_szalonnas
 
Elk scilifelab
Elk scilifelabElk scilifelab
Elk scilifelab
 
Tuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsTuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for Logs
 
Logstash
LogstashLogstash
Logstash
 
Logstash family introduction
Logstash family introductionLogstash family introduction
Logstash family introduction
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logs
 
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
Central LogFile Storage. ELK stack Elasticsearch, Logstash and Kibana.
 
Elasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveElasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep dive
 
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'
 
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
 

Ähnlich wie Docker Logging and analysing with Elastic Stack

ETL with SPARK - First Spark London meetup
ETL with SPARK - First Spark London meetupETL with SPARK - First Spark London meetup
ETL with SPARK - First Spark London meetupRafal Kwasny
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container EraSadayuki Furuhashi
 
Elk presentation 2#3
Elk presentation 2#3Elk presentation 2#3
Elk presentation 2#3uzzal basak
 
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and LogsCloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and LogsAltoros
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoopclairvoyantllc
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.Renzo Tomà
 
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
Intro to Apache Apex - Next Gen Platform for Ingest and TransformIntro to Apache Apex - Next Gen Platform for Ingest and Transform
Intro to Apache Apex - Next Gen Platform for Ingest and TransformApache Apex
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly SolarWinds Loggly
 
Cashing in on logging and exception data
Cashing in on logging and exception dataCashing in on logging and exception data
Cashing in on logging and exception dataStackify
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performanceEngine Yard
 
Why you should be using structured logs
Why you should be using structured logsWhy you should be using structured logs
Why you should be using structured logsStefan Krawczyk
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGIMike Pittaro
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerCisco Canada
 
File Processing - Batch Process Execution
File Processing - Batch Process ExecutionFile Processing - Batch Process Execution
File Processing - Batch Process ExecutionAbimael Desales López
 
File Processing - Process Execution Solution
File Processing - Process Execution SolutionFile Processing - Process Execution Solution
File Processing - Process Execution SolutionAbimael Desales López
 
Adding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemAdding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemJohn Efstathiades
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak PROIDEA
 

Ähnlich wie Docker Logging and analysing with Elastic Stack (20)

ETL with SPARK - First Spark London meetup
ETL with SPARK - First Spark London meetupETL with SPARK - First Spark London meetup
ETL with SPARK - First Spark London meetup
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
 
Elk presentation 2#3
Elk presentation 2#3Elk presentation 2#3
Elk presentation 2#3
 
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and LogsCloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoop
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
Intro to Apache Apex - Next Gen Platform for Ingest and TransformIntro to Apache Apex - Next Gen Platform for Ingest and Transform
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
 
Into The Box 2018 Ortus Keynote
Into The Box 2018 Ortus KeynoteInto The Box 2018 Ortus Keynote
Into The Box 2018 Ortus Keynote
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
 
Cashing in on logging and exception data
Cashing in on logging and exception dataCashing in on logging and exception data
Cashing in on logging and exception data
 
Grails and Ajax
Grails and AjaxGrails and Ajax
Grails and Ajax
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Why you should be using structured logs
Why you should be using structured logsWhy you should be using structured logs
Why you should be using structured logs
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
File Processing - Batch Process Execution
File Processing - Batch Process ExecutionFile Processing - Batch Process Execution
File Processing - Batch Process Execution
 
File Processing - Process Execution Solution
File Processing - Process Execution SolutionFile Processing - Process Execution Solution
File Processing - Process Execution Solution
 
Adding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemAdding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded System
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 

Mehr von Jakub Hajek

Traefik 2.x features - canary deployment with Traefik and K3S
Traefik 2.x features - canary deployment with Traefik and K3STraefik 2.x features - canary deployment with Traefik and K3S
Traefik 2.x features - canary deployment with Traefik and K3SJakub Hajek
 
Canary deployment with Traefik and K3S
Canary deployment with Traefik and K3SCanary deployment with Traefik and K3S
Canary deployment with Traefik and K3SJakub Hajek
 
Traefik as an open source edge router for microservice architectures
Traefik as an open source edge router for microservice architecturesTraefik as an open source edge router for microservice architectures
Traefik as an open source edge router for microservice architecturesJakub Hajek
 
Container Orchestration with Traefik 2.x
Container Orchestration with Traefik 2.xContainer Orchestration with Traefik 2.x
Container Orchestration with Traefik 2.xJakub Hajek
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Jakub Hajek
 
Container Orchestration with Traefk on Docker Swarm
Container Orchestration with Traefk on Docker SwarmContainer Orchestration with Traefk on Docker Swarm
Container Orchestration with Traefk on Docker SwarmJakub Hajek
 
Cometari Dedicated Solutions Company Presentation
Cometari Dedicated Solutions Company PresentationCometari Dedicated Solutions Company Presentation
Cometari Dedicated Solutions Company PresentationJakub Hajek
 
Cometari Dedicated Solutions Oferta ogólna
Cometari Dedicated Solutions Oferta ogólnaCometari Dedicated Solutions Oferta ogólna
Cometari Dedicated Solutions Oferta ogólnaJakub Hajek
 
Cometari Dedicated Solutions General Offer
Cometari Dedicated Solutions General OfferCometari Dedicated Solutions General Offer
Cometari Dedicated Solutions General OfferJakub Hajek
 

Mehr von Jakub Hajek (9)

Traefik 2.x features - canary deployment with Traefik and K3S
Traefik 2.x features - canary deployment with Traefik and K3STraefik 2.x features - canary deployment with Traefik and K3S
Traefik 2.x features - canary deployment with Traefik and K3S
 
Canary deployment with Traefik and K3S
Canary deployment with Traefik and K3SCanary deployment with Traefik and K3S
Canary deployment with Traefik and K3S
 
Traefik as an open source edge router for microservice architectures
Traefik as an open source edge router for microservice architecturesTraefik as an open source edge router for microservice architectures
Traefik as an open source edge router for microservice architectures
 
Container Orchestration with Traefik 2.x
Container Orchestration with Traefik 2.xContainer Orchestration with Traefik 2.x
Container Orchestration with Traefik 2.x
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
 
Container Orchestration with Traefk on Docker Swarm
Container Orchestration with Traefk on Docker SwarmContainer Orchestration with Traefk on Docker Swarm
Container Orchestration with Traefk on Docker Swarm
 
Cometari Dedicated Solutions Company Presentation
Cometari Dedicated Solutions Company PresentationCometari Dedicated Solutions Company Presentation
Cometari Dedicated Solutions Company Presentation
 
Cometari Dedicated Solutions Oferta ogólna
Cometari Dedicated Solutions Oferta ogólnaCometari Dedicated Solutions Oferta ogólna
Cometari Dedicated Solutions Oferta ogólna
 
Cometari Dedicated Solutions General Offer
Cometari Dedicated Solutions General OfferCometari Dedicated Solutions General Offer
Cometari Dedicated Solutions General Offer
 

Kürzlich hochgeladen

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Kürzlich hochgeladen (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Docker Logging and analysing with Elastic Stack

  • 1. Docker Logging and analysing with Elastic Stack JAKUB HAJEK, jakub.hajek@cometari.com, @_jakubhajek November 2019, Warsaw www.devopsdays.pl
  • 2. Introduction • I am the owner and technical consultant working for Cometari • I have been system admin since 1998. • Cometari is a solution company implementing DevOps culture, providing consultancy, workshops and software services. • Our areas of expertise are DevOps, Elastic Stack (log analysis), Cloud Computing. • We are very deeply involved in the travel tech industry, however our solutions go much further than just integrating travel API’s.
  • 3. — “I strongly believe that implementing DevOps culture, across the entire organisation, should provide measurable value and solve the real issue rather than generate a new one.”
  • 4. Agenda • A little bit of the theory about logs. • The major difference with old fashioned approach comparing to container world. • Distributed logging with Elasticsearch and Fluentd • Demo of logging based on live demos: • A simple example sending logs from container to Fluentd • Fully fledged environment running on Docker Swarm with deployed: Elasticsearch Cluster, Kibana and Fluentd • Deployed application stack contains multi tier application stack including Traefik frontend and backend application
  • 5. For what for do we need to collect logs?
  • 7. What are logs? • Logs are the stream of aggregated, time ordered events collected from the output stream • The output stream can be generated by processes and backing services • Raw logs are typically a text format with one event per line • Backtraces from exceptions are usually multiline • Logs have no beginning or end but flows continuously as long as the app is operating.
  • 8. Logging considerations • Logging is not cheap. Requires lots of computing: storage, cpu, memory. • Logging can be even expensive if you want to search against logs and correlate data. • Having “LIVE” data accessible immediately can be even more expensive. • Don’t log everything, consider which data you are interested in (it’s not for free) • Logging retention time have to be considered (Curator if you store logs in Elasticsearch) • I recommend Elasticsearch to keep logs as a time based data. It requires some experience with Elasticsearch to provide reliable environment for logs. • Logging is a mess ; Logging is not fun but we have to deal with it and build logging solution
  • 9. Logging in production • Service logs • Web access logs • Transaction Logs • Distributed tracing • System Logs • Syslog, system and other logs • Audit logs • Basic operating system metrics (CPU, memory, load …) Logs for Business KPI Machine Learning Predctive analytics … Logs for Service System monitoring Bottleneck Troubleshooting …
  • 10. Logging is not the same as Monitoring • Logging is recording to diagnose a system • Monitoring is an observation, checking and than recording • A Notification ( usually called alerts) can be send out to any notification channels for both: logging and monitoring • The notification can be triggered when specific criteria is met. e.g. Http_requests_response_code is 500 in the last 60 seconds A plugin had an unrecoverable error. Will restart this plugin. Pipeline_id:main_dlq Plugin: <LogStash::Inputs::DeadLetterQueue pipeline_id=>"main", path=>"/usr/share/logstash/data/dead_letter_queue", id=>"830027210528f50ad1234fe96f0ccc5f8a6989bb0b2d944881373ec56e555357", commit_offsets=>true, enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_32044710-aeb5-4303-ba0e-2feb2dd851e9", enable_metric=>true, charset=>"UTF-8">> Error: Exception: Java::JavaNio::BufferOverflowException Stack: java.nio.HeapByteBuffer.put(java/nio/HeapByteBuffer.java:189) eas_errors{errorType=“CONTENT”,provider=“HRS",requestName="HotelAvailability", errorId=“1234",errorSeverity="2",startDate="2019-11-20T22:00:00",endDate="2019-11-21T21:59:59",} 10.0
  • 11. Standard approach of logging to file system
  • 12. Writing message to a log file Application LOGS Logging} Files -> Multiple places (usually /var/log)
  • 13. Application STDOUT 1 STDERR 2STDIN Standard I/O Streams { echo "stdout"; echo "stderr" 1>&2; } | grep -v std STDOUT 1 STDERR 2 Logging in container World!
  • 14. The container world Bare metal Container world Service architecture Monolithic Microservices System image Mutable Immutable Local data Persistent Ephemeral Network Physical Address No fixed address Environment Manually / Automation Orchestration tools Logging syslogd/rsync ? *There is nothing wrong with monolithic system unless you can distinguish boundaries in the system and move that domain to the service on demand !
  • 15. What are the challenges with logs in container world?
  • 16. Logging challenges with Containers • No permanent storage (Container are stateless and storage is Ephemeral • No fixed physical address. • No fixed mapping between server and roles • Lots of various application types • Transfer logs immediately to distributed logging infrastructure • Push logs from containers • Labels logs with service name or use tags • Need to handle various logs with regexp, GROK
  • 17. Logging and Docker containers
  • 18. Logging and Docker container strategy • Application should writes a message to the STDOUT STDOUT APPLICATION running in Docker container Hello World!
  • 19. Logging and Docker container strategy • Message encapsulated in a JSON map (with JSON driver) structure via Docker. Hello World! { “log” : “hello World!”, “stream”: “stdout”, “time”: “timestamp" }
  • 20. Logging and Docker container strategy /var/log/docker/containers/00fae94d9a721bec312dba411… f55f37e37/00fae94d9a721bec312dba41168231…6303f274f55f37e37-json.log $: docker run -d busybox echo -n “Hello World!" 00fae94d9a721bec312dba411682313a4ab8846f01f7b406303f274f55f37e37 > cat 00fae94d9a721bec312dba411682313a4ab8846f01f7b406303f274f55f37e37- json.log { “log”:”HelloWorld!", “stream":"stdout", “time":"2019-11-21T14:12:01.599413578Z" }
  • 23. What is the approach to the logging in the container world?
  • 24. Treat logs as an event stream
  • 25. Treat logs as an event stream • Application should be stateless and does not store data / logs locally. • Logs should not attempt to write to local storage • Logs should not be managed locally, e.g. logrotate • All logs should be treated as an event streams • Each running process writes its event to STDOUT and STDERR • In container based environment logging should be sent to STDOUT
  • 26. Logging in the context of distributed cluster
  • 27. HOTELS INSURENCES RAILS CARS FLIGHTS INVOICESPAYMENTSPROFILESSEARCH API GATEWAY USERS PROFILES PAYMENTS INVOICESSEARCHFLIGHTS CARS HOTELS RAILS INSURANCE APP LOGS API GATEWAY Live aggregated logs KPI, Dashboards Analytics grep / awk / Perl :-)
  • 28. Log collectors for Central logging • Logstash from Elastic Stack, Fluentd, Apache Flume and many more… LOGS LOG COLLECTOR STORAGE • Example storage options: • S3, MongoDB, Hadoop, Elasticsearch • file, forward, copy, stdout (useful for debugging)
  • 29. Fluentd data collector • An extensible and reliable data collection. • Unified Logging Layer - treats logs as JSON • Pluggable Architecture • Supports memory and file based buffering to prevent internode data lost • Built-in HA and load balancing
  • 30. CORE • Divide and conquer • Buffering and retries • Error Handling • Message routing • Parallelism PLUGINS • Read data • Parse data • Buffer data • Write data • Format data
  • 31. Unifying logging layer Services Services Collector nodes Aggregator Nodes Elasticsearch Fluentd Application generates logs Convert raw log data in a structured data Aggregated structured data Structured Data Ready for analysis
  • 32. An event in Fluentd TAG: myapp.access TIME: (current time) RECORD: {“event”: “data”}
  • 33. INPUT PARSER FILTER BUFFER OUTPUT FORMATTER Internal architecture of plugins “input-ish” “output-ish”
  • 34. TAG TIME RECORD ROUTER input - filter Output Chunk Chunk Chunk Metadata Metadata Metadata BUFFER Chunk QUEUE Chunk ChunkChunk Chunk Process Format Write Try _write OUTPUT EMIT ENQUEUE source: https://docs.fluentd.org/output
  • 35. Brief overview of configuration • <source> where all the data come from, routing engine • <match> Tell Fluentd what to do! • <filter> Event processing pipeline • INPUT -> filter 1 -> …. -> filter N -> OUTPUT • <system> - system directive • <label> use for grouping filter and output for internal routing • @include split config into multiple files and re-use configuration Source: https://docs.fluentd.org/configuration/config-file
  • 36. <source> @type forward port 24223 bind 0.0.0.0 tag backend.invoice </source> <filter **> @type parser key_name log reserve_data true hash_value_field log …. <parse> @type multi_format <pattern> format json </pattern> … </parse> </source> <match **> @type Elasticsearch host “#{ENV[‘ES_HOST’]}” Port 9200 id_key hash remove_keys hash type_name doc logstash_format true logstash_dateformat %Y.%m logstash_prefix logs logstash_tag_key true tag_key serviceTagName … <buffer tag> @type memory flush_thread_count 2 </buffer> </match> <source> @type forward port 24224 bind 0.0.0.0 </source> <match backend.*> @type mongo Database fluent Collection test </match>
  • 37. Docker fluentd driver • The logging driver sends container logs to Fluentd in as structured log data • Metadata: container_id, container_name, source, logs • —log-driver fluentd —log-opt tag=docker.{{.ID} —log-opt fluentd- address=tcp://fluenthost • Messages are buffered until connection is established. • The data can be buffered before flushing • Retry, max-retry, sub-second-precision…
  • 38. Architecture of the demo environment
  • 41. Live demo & Examples of code
  • 42. JAKUB HAJEK, JAKUB.HAJEK@COMETARI.COM, @_jakubhajek I'm waiting for your feedback! You can rate speakers and lectures using our official conference app