SlideShare a Scribd company logo
Aggregierte
Logging Patterns
Philipp Krenn @xeraa
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
@xeraa
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
Developer
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
@xeraa
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
Disclaimer
I build highly monitored Hello World
apps
@xeraa
Example: Java
SLF4J, Logback, MDC
with logstash-logback-encoder
Alternative https://github.com/vy/log4j2-logstash-layout
@xeraa
And Everywhere Else
.NET: NLog
JavaScript: Winston
Python: structlog
PHP: Monolog
@xeraa
Anti-Pattern: print
System.out.println("Oops");
@xeraa
Anti-Pattern: Coupling
@xeraa
Parse
@xeraa
@xeraa
Bind Mount Logs
java_app:
volumes:
- './logs-docker/:/logs/'
...
filebeat_for_logstash:
volumes:
- './logs-docker/:/mnt/logs/:ro'
...
@xeraa
Collect Log Lines
filebeat.inputs:
- type: log
paths:
- /mnt/logs/*.log
@xeraa
Metadata
processors:
- add_host_metadata: ~
@xeraa
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
Test Multiline Pattern
https://www.elastic.co/guide/en/beats/filebeat/current/
_test_your_regexp_pattern_for_multiline.html
@xeraa
Grok
https://github.com/logstash-plugins/logstash-patterns-core/blob/
master/patterns/grok-patterns
@xeraa
Dev Tools
Grok Debugger
@xeraa
[2018-09-28 10:30:38.516] ERROR net.xeraa.logging.LogMe [main] -
user_experience= , session=46, loop=15 -
Wake me up at night
java.lang.RuntimeException: Bad runtime...
at net.xeraa.logging.LogMe.main(LogMe.java:30)
^[%{TIMESTAMP_ISO8601:@timestamp}]%{SPACE}%{LOGLEVEL:log.level}
%{SPACE}%{USERNAME:log.package}%{SPACE}[%{WORD:log.method}]
%{SPACE}-%{SPACE}%{GREEDYDATA:log.labels}%{SPACE}-%{SPACE}
%{GREEDYDATA:message}(?:n+(?<stacktrace>(?:.|r|n)+))?
@xeraa
Elastic Common
Schema
https://github.com/elastic/ecs
@xeraa
Machine Learning
Data Visualizer
@xeraa
Logstash Key Value Filter for MDC
kv {
source => "labels"
field_split => ","
trim_key => " "
}
@xeraa
Monitoring:
Logstash Pipeline
Plus other components
@xeraa
Pro: No change
Con: Regular expression, multiline,
format changes
@xeraa
Send
@xeraa
@xeraa
logback.xml
<appender name="logstash" class="net.logstash.logback.appender.LogstashAccessTcpSocketAppender">
<destination>logstash:4560</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
@xeraa
Pro: No files
Con: Outages & coupling
@xeraa
Structure
@xeraa
@xeraa
Collect JSON
filebeat.input:
- type: log
paths:
- /mnt/logs/*.json
json:
message_key: message
keys_under_root: true
@xeraa
Stack(trace) Hash
@xeraa
Bonues: Multi-Index
output.elasticsearch:
hosts: ["http://localhost:9200"]
indices:
- index: "warning-%{[agent.version]}-%{+yyyy.MM.dd}"
when.contains:
message: "WARN"
- index: "error-%{[agent.version]}-%{+yyyy.MM.dd}"
when.contains:
message: "ERR"
@xeraa
Pro: Right format
Con: JSON serialization overhead
@xeraa
Containerize
@xeraa
@xeraa
Where to put Filebeat?
Sidecar
@xeraa
@xeraa
https://github.com/elastic/beats/tree/
master/deploy/docker
@xeraa
Docker Logs
filebeat.autodiscover:
providers:
- type: docker
hints.enabled: true
processors:
- add_docker_metadata: ~
@xeraa
Metadata
No Docker metadata with the other methods
@xeraa
"docker": {
"container": {
"labels": {
"app": "fizzbuzz",
"co_elastic_logs/multiline_match": "after",
"com_docker_compose_config-hash": "41520c6cf2b6a1f3dae4f16d0a6fd76760cdfc38fbfe43a3a3be2e09bdd1b8b5",
"environment": "production",
"co_elastic_logs/multiline_pattern": "^[",
"co_elastic_logs/multiline_negate": "true",
"com_docker_compose_oneoff": "False",
"com_docker_compose_project": "java-logging",
"com_docker_compose_service": "java_app",
"com_docker_compose_container-number": "1",
"com_docker_compose_version": "1.23.2"
}
}
}
@xeraa
Missing the Last Line
Waiting for the newline
@xeraa
Hints
labels:
- "app=fizzbuzz"
- "co.elastic.logs/multiline.pattern=^["
- "co.elastic.logs/multiline.negate=true"
- "co.elastic.logs/multiline.match=after"
@xeraa
Registry File
filebeat.registry.path: /usr/share/filebeat/data/registry
@xeraa
Ingest Pipeline
output.elasticsearch:
hosts: ["http://elasticsearch:9200"]
index: "docker"
pipelines:
- pipeline: "parse_java"
when.contains:
container.name: "java_app"
@xeraa
Ingest Pipeline
{
"description" : "Parse Java log lines",
"processors": [
{
"grok": {
"field": "message",
"patterns": [ "^[%{TIMESTAMP_ISO8601:timestamp}]%{SPACE}%{LOGLEVEL:log.level}
%{SPACE}%{USERNAME:log.package}%{SPACE}[%{WORD:log.method}]%{SPACE}-
%{SPACE}%{GREEDYDATA:labels}%{SPACE}-%{SPACE}%{GREEDYDATA:message_parsed}
(?:n+(?<stacktrace>(?:.|r|n)+))?" ],
"ignore_failure": true
}
}
]
}
@xeraa
Unknown Fields
@xeraa
ASCII Art
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
.-`` .-```. ```/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 55757
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
@xeraa
Configuration Templates
filebeat.autodiscover:
providers:
- type: docker
templates:
- condition:
equals:
docker.container.image: redis
config:
- type: docker
containers.ids:
- "${data.docker.container.id}"
exclude_lines: ["^s+[-`('.|_]"]
@xeraa
Who Logs the Logger
Avoid loops
Process without -e
filebeat.yml: logging.to_files: true
@xeraa
Pro: Hot
Con: Complexity
@xeraa
Orchestrate
@xeraa
@xeraa
Where to put Filebeat?
DaemonSet
@xeraa
https://github.com/elastic/beats/tree/
master/deploy/kubernetes
@xeraa
Metadata
Either in cluster or outside
processors:
- add_kubernetes_metadata:
in_cluster: true
- add_kubernetes_metadata:
in_cluster: false
host: <hostname>
kube_config: ${HOME}/.kube/config
@xeraa
{
"host": "172.17.0.21",
"port": 9090,
"kubernetes": {
"container": {
"id": "382184ecdb385cfd5d1f1a65f78911054c8511ae009635300ac28b4fc357ce51",
"image": "my-java:1.0.0",
"name": "my-java"
},
"labels": {
"app": "java",
},
"namespace": "default",
"node": {
"name": "minikube"
},
"pod": {
"name": "java-2657348378-k1pnh"
}
},
}
@xeraa
More Metadata
Add: Cloud, local timezone, process
Drop: Events, fields
Rename: Fields
Dissect, DNS reverse lookup
@xeraa
Configuration Templates
filebeat.autodiscover:
providers:
- type: kubernetes
templates:
- condition:
equals:
kubernetes.namespace: redis
config:
- type: docker
containers.ids:
- "${data.kubernetes.container.id}"
exclude_lines: ["^s+[-`('.|_]"]
@xeraa
Customize Indices
output.elasticsearch:
index: "%{[kubernetes.namespace]:filebeat}-%{[beat.version]}-%{+yyyy.MM.dd}"
@xeraa
Pro: Hot
Con: Complexity++
@xeraa
Moar
@xeraa
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns
Index Patterns
Time based (default: daily)
Versioned
@xeraa
Sizing
Daily volume * Retention * Replication
Number of shards
@xeraa
Index Lifecycle Management
! "
@xeraa
Order
https://github.com/elastic/elasticsearch/blob/7.1/x-pack/plugin/core/src/main/java/org/elasticsearch/
xpack/core/indexlifecycle/TimeseriesLifecycleType.java
static final List<String> ORDERED_VALID_HOT_ACTIONS = Arrays.asList(
SetPriorityAction.NAME, UnfollowAction.NAME, RolloverAction.NAME
);
static final List<String> ORDERED_VALID_WARM_ACTIONS = Arrays.asList(
SetPriorityAction.NAME, UnfollowAction.NAME, ReadOnlyAction.NAME,
AllocateAction.NAME, ShrinkAction.NAME, ForceMergeAction.NAME
);
static final List<String> ORDERED_VALID_COLD_ACTIONS = Arrays.asList(
SetPriorityAction.NAME, UnfollowAction.NAME, AllocateAction.NAME, FreezeAction.NAME
);
static final List<String> ORDERED_VALID_DELETE_ACTIONS = Arrays.asList(
DeleteAction.NAME
);
@xeraa
Frozen Indices
https://www.elastic.co/guide/en/elasticsearch/reference/6.6/
frozen-indices.html
@xeraa
Ratio Heap : Storage
Index > Frozen Index > Closed Index
Read-only
@xeraa
Throttled Thread Pool
1 parallel search / node
100 in queue
@xeraa
Conclusion
@xeraa
Examples
https://github.com/xeraa/java-logging
@xeraa
Parse
Send
Structure
Containerize
Orchestrate
@xeraa
Questions?
Philipp Krenn @xeraa
@xeraa

More Related Content

PDF
When To Use Ruby On Rails
PDF
4Developers 2018: Structured logging (Bartek Szurgot)
PDF
mruby で mackerel のプラグインを作るはなし
PDF
Ruby MVC from scratch with Rack
PDF
Lights, Camera, Docker: Streaming Video at DramaFever
PDF
Ruby on Rails Presentation
PDF
ChefConf 2012 Spiceweasel
PPT
Migrating PriceChirp to Rails 3.0: The Pain Points
When To Use Ruby On Rails
4Developers 2018: Structured logging (Bartek Szurgot)
mruby で mackerel のプラグインを作るはなし
Ruby MVC from scratch with Rack
Lights, Camera, Docker: Streaming Video at DramaFever
Ruby on Rails Presentation
ChefConf 2012 Spiceweasel
Migrating PriceChirp to Rails 3.0: The Pain Points

What's hot (20)

KEY
Sinatra for REST services
PDF
Apache and PHP: Why httpd.conf is your new BFF!
PDF
Building web framework with Rack
PDF
Nginx Workshop Aftermath
PDF
Middleware as Code with mruby
PDF
Rails Girls: Programming, Web Applications and Ruby on Rails
PDF
20141210 rakuten techtalk
PDF
Lightweight Webservices with Sinatra and RestClient
PDF
PHPCon China 2018 - 好孩子的 PHP 撰碼指南
PDF
Introduction to Rails - presented by Arman Ortega
PDF
Till Vollmer Presentation
PDF
Ruby on Rails Security
PDF
Debugging on rails
PDF
Cadence flow
PDF
Ruby off Rails (japanese)
PDF
Workin On The Rails Road
PDF
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
KEY
PSGI/Plack OSDC.TW
PDF
Using Sinatra to Build REST APIs in Ruby
KEY
Composer
Sinatra for REST services
Apache and PHP: Why httpd.conf is your new BFF!
Building web framework with Rack
Nginx Workshop Aftermath
Middleware as Code with mruby
Rails Girls: Programming, Web Applications and Ruby on Rails
20141210 rakuten techtalk
Lightweight Webservices with Sinatra and RestClient
PHPCon China 2018 - 好孩子的 PHP 撰碼指南
Introduction to Rails - presented by Arman Ortega
Till Vollmer Presentation
Ruby on Rails Security
Debugging on rails
Cadence flow
Ruby off Rails (japanese)
Workin On The Rails Road
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
PSGI/Plack OSDC.TW
Using Sinatra to Build REST APIs in Ruby
Composer
Ad

Similar to Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns (20)

PDF
OSDC 2018 | Monitoring Kubernetes at Scale by Monica Sarbu
PDF
Monitoring Kubernetes with Elasticsearch Services - Ted Jung, Consulting Arch...
PDF
Docker Logging and analysing with Elastic Stack
PDF
Docker Logging and analysing with Elastic Stack - Jakub Hajek
PDF
Managing Stateful Services with the Operator Pattern in Kubernetes - Kubernet...
PPTX
Centralized log-management-with-elastic-stack
ODP
Log aggregation and analysis
PDF
Playground 11022017 user_monitoring
PDF
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...
PDF
Deploying PostgreSQL on Kubernetes
PDF
Combining logs, metrics, and traces for unified observability
PDF
OSDC 2019 | Fast log management for your infrastructure by Nicolas Frankel
PDF
OSMC 2016 - Monitor your infrastructure with Elastic Beats by Monica Sarbu
PDF
OSMC 2016 | Monitor your Infrastructure with Elastic Beats by Monica Sarbu
PDF
JavaOne 2016: Kubernetes introduction for Java Developers
PDF
Kubernetes for Java Developers
PDF
Monitoring&Logging - Stanislav Kolenkin
PPTX
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
PDF
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
PDF
Application Logging in the 21st century - 2014.key
OSDC 2018 | Monitoring Kubernetes at Scale by Monica Sarbu
Monitoring Kubernetes with Elasticsearch Services - Ted Jung, Consulting Arch...
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Managing Stateful Services with the Operator Pattern in Kubernetes - Kubernet...
Centralized log-management-with-elastic-stack
Log aggregation and analysis
Playground 11022017 user_monitoring
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...
Deploying PostgreSQL on Kubernetes
Combining logs, metrics, and traces for unified observability
OSDC 2019 | Fast log management for your infrastructure by Nicolas Frankel
OSMC 2016 - Monitor your infrastructure with Elastic Beats by Monica Sarbu
OSMC 2016 | Monitor your Infrastructure with Elastic Beats by Monica Sarbu
JavaOne 2016: Kubernetes introduction for Java Developers
Kubernetes for Java Developers
Monitoring&Logging - Stanislav Kolenkin
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
Application Logging in the 21st century - 2014.key
Ad

More from DevDay Dresden (20)

PDF
The Architecture of Uncertainty - Kevlin Henney
PDF
Dev Day 2021 - Stephan Pirnbaum - Anwendungsmodernisierung
PDF
Tobias Nebel - Herausforderungen und Changen in Full-Stack-IoT-Projekten
PDF
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
PDF
Alexander Reelsen - Seccomp for Developers
PDF
DevDay 19 Accessibility: Praxistipps für Entwickler
PDF
Dev Day 2019: Mirko Seifert – Next Level Integration Testing mit Docker und T...
PDF
Dev Day 2019: Nathan Mattes – Kommunikation ist wichtig, scheiße wichtig und ...
PDF
Dev Day 2019: Stephan Birnbaum – Die Glaskugel hat ausgedient, wir machen Sof...
PDF
Dev Day 2019: Markus Winand – Die Mutter aller Abfragesprachen: SQL im 21. Ja...
PDF
Dev Day 2019: Kay Grebenstein – Wie wir müssen das noch testen? - design for ...
PDF
Dev Day 2019: Kathrin Friedrich/Michael Kunze – Design better together - Styl...
PDF
Dev Day 2019: Benjamin Wolf – "Some fixes" - Commit Message 101
PDF
Dev Day 2019: Lucas Fiedler – DevOps-Dashboard: Transparenz für DevOps-Teams
PDF
Dev Day 2019: Ulrich Deiters – Offene Daten und IT-Lösungen für den Radverkehr
PDF
Dev Day 2019: Alexander Lichter - JAMstack - Eine neuartige Webanwendungs-Arc...
PDF
Dev Day 2019: Martin Schurz - Manual Work Is A Bug!
PDF
Dev Day 2019: Stefan Schleyer: How to build an cloud-based IoT application“
PDF
Dev Day 2019: Mirko Zeibig – "Hallo " <> "Elixir"
PDF
Dev Day 2019: Mike Sperber – Software Design für die Seele
The Architecture of Uncertainty - Kevlin Henney
Dev Day 2021 - Stephan Pirnbaum - Anwendungsmodernisierung
Tobias Nebel - Herausforderungen und Changen in Full-Stack-IoT-Projekten
Andreas Roth - GraphQL erfolgreich im Backend einsetzen
Alexander Reelsen - Seccomp for Developers
DevDay 19 Accessibility: Praxistipps für Entwickler
Dev Day 2019: Mirko Seifert – Next Level Integration Testing mit Docker und T...
Dev Day 2019: Nathan Mattes – Kommunikation ist wichtig, scheiße wichtig und ...
Dev Day 2019: Stephan Birnbaum – Die Glaskugel hat ausgedient, wir machen Sof...
Dev Day 2019: Markus Winand – Die Mutter aller Abfragesprachen: SQL im 21. Ja...
Dev Day 2019: Kay Grebenstein – Wie wir müssen das noch testen? - design for ...
Dev Day 2019: Kathrin Friedrich/Michael Kunze – Design better together - Styl...
Dev Day 2019: Benjamin Wolf – "Some fixes" - Commit Message 101
Dev Day 2019: Lucas Fiedler – DevOps-Dashboard: Transparenz für DevOps-Teams
Dev Day 2019: Ulrich Deiters – Offene Daten und IT-Lösungen für den Radverkehr
Dev Day 2019: Alexander Lichter - JAMstack - Eine neuartige Webanwendungs-Arc...
Dev Day 2019: Martin Schurz - Manual Work Is A Bug!
Dev Day 2019: Stefan Schleyer: How to build an cloud-based IoT application“
Dev Day 2019: Mirko Zeibig – "Hallo " <> "Elixir"
Dev Day 2019: Mike Sperber – Software Design für die Seele

Recently uploaded (20)

PDF
medical staffing services at VALiNTRY
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
history of c programming in notes for students .pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
L1 - Introduction to python Backend.pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
System and Network Administraation Chapter 3
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPT
Introduction Database Management System for Course Database
PPTX
Transform Your Business with a Software ERP System
medical staffing services at VALiNTRY
Navsoft: AI-Powered Business Solutions & Custom Software Development
Softaken Excel to vCard Converter Software.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Migrate SBCGlobal Email to Yahoo Easily
PTS Company Brochure 2025 (1).pdf.......
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
How to Choose the Right IT Partner for Your Business in Malaysia
history of c programming in notes for students .pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
L1 - Introduction to python Backend.pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
System and Network Administraation Chapter 3
Odoo Companies in India – Driving Business Transformation.pdf
Introduction Database Management System for Course Database
Transform Your Business with a Software ERP System

Dev Day 2019: Phillip Krenn – Aggregierte Logging Patterns