Transcript
Page 1: Containers and Logging

Containers and Logging Challenges and Solutions

Eduardo Silva (@edsiper) LinuxCon Europe 2016

Page 2: Containers and Logging

Logging

Page 3: Containers and Logging

Logging

● Monitoring

● Troubleshooting

● Statistics

It matters

Page 4: Containers and Logging

Logging Scenarios

● Operating System

● Applications Unit

● Services

Distribution Channels

Page 5: Containers and Logging

Containers

Page 6: Containers and Logging

ContainersEverything is about Isolation

Page 7: Containers and Logging

Containers & Log Handlers

● File System

● Standard I/O interfaces (stdout / stderr)

● Over Network

Distribution Channels

Page 8: Containers and Logging

Docker Logging Drivers

● Json-file● Syslog● Journald● Fluentd● ...

Outputs

Docker Implement drivers for different formats and distribution channels:

Page 9: Containers and Logging

Structured Logs

Page 10: Containers and Logging

Structured Logs

● Often based in Key-Value pairs

● Two minimum keys: time and message

Distribution Channels

Structured logging makes data processing easier

Page 11: Containers and Logging

Structured Logs

● JSON: readable format for structured data

● MessagePack: Binary serialization (json-like)

Common format

Structured logging makes data processing easier

Page 12: Containers and Logging

Structured LogsDocker log example

Original Log Message

This is a test message

Structured Log Message

{ "container_id":"bfdd5b9...", "container_name":"/infallible_mayer", "source":"stdout", "log": "This is a test message"}

Page 13: Containers and Logging

Microservices

Page 14: Containers and Logging

MicroservicesMonolithic

● A service produces alldata about users access

Microservices● Many services produce

data about users access● Log needs to be collected

from many services.

Page 15: Containers and Logging

Microservices

● How to deal with different input formats ?

● Parse plain text is really expensive.

● Not all containers have permanent storage.

● Where to write the logs ?

Logging Challenges

Page 16: Containers and Logging

Distributed Logging

Page 17: Containers and Logging

Distributed LoggingArchitecture

Page 18: Containers and Logging

Distributed LoggingWorkflowCollector

● Retrieve raw logs: file system / network.● Parse log content.

Aggregator● Get data from multiple sources.● Convert incoming data into Streams.

Destination● Retrieve data streams from Aggregator.● Store formatted logs (records) .

Page 19: Containers and Logging

Scaling Logging

● Network Traffic

● CPU Load: parsing and formatting is expensive

● High Availability / Redundant aggregators

Topics to consider

Page 20: Containers and Logging

Aggregation Patterns

Page 21: Containers and Logging

Source Aggregation Patterns

w/o source aggregation with source aggregation

Page 22: Containers and Logging

Aggregation PatternsWithout Source Aggregation

Pros● Simple Configuration

Cons● Fixed Aggregator endpoint address● Many network connections● High load on Aggregator

Page 23: Containers and Logging

Aggregation PatternsWith Source Aggregation

Pros● Less connections● Lower load in aggregator● Less config in Containers

Cons● Need more resources (1 aggregate container

per host.

Page 24: Containers and Logging

DestinationAggregation Patterns

w/o destination aggregation with destination aggregation

Page 25: Containers and Logging

Aggregation PatternsWithout Destination Aggregation

Pros● Less Nodes● Simpler configuration

Cons● Storage side changes affects collector side● Worse performance: many small write requests

on storage

Page 26: Containers and Logging

Aggregation PatternsWith Destination Aggregation

Pros● Collector side configuration is

free from storage side changes.● Better performance with fine

tune on destination side aggregator.

Cons● More Nodes.● More complex configuration.

Page 27: Containers and Logging
Page 28: Containers and Logging

Open Source Data/Log Collector

● High Performance

● Built-in Reliability

● Structured Logs

● Pluggable Architecture

● More than 300 plugins! (input/filtering/output)

Page 29: Containers and Logging

Architecture / Workflow

Page 30: Containers and Logging

Full Collector/Aggregator for Containers

● Docker Interoperability Native Docker logging driver to use Fluentd

● KubernetesFluentd as main aggregator (notes)

● OpenShiftFluentd as main aggregator

Page 31: Containers and Logging

Docker use case

Page 32: Containers and Logging

FluentdDocker use case

Page 33: Containers and Logging

FluentdKubernetes use case

Page 34: Containers and Logging

Fluentd in the Real World

Page 35: Containers and Logging

Microsoft Use Case

Page 36: Containers and Logging
Page 37: Containers and Logging

We collect1.6M events per second !

Page 38: Containers and Logging

It’s a proud member of:

Page 39: Containers and Logging

Fluentd + CNCF ?Logging

Page 40: Containers and Logging

Fluentd + CNCF ?Application: Work in Process

Page 41: Containers and Logging
Page 42: Containers and Logging

Fluent BitLightweight log aggregator

● Written in C

● High Performance

● Pluggable Architecture

● Built-in CPU / Memory metrics / Network TLS support

● Event-Driven

● Fluentd Compatible

Page 43: Containers and Logging
Page 44: Containers and Logging

Architecture

Page 45: Containers and Logging

Library Mode

Page 46: Containers and Logging

Library Mode

Page 47: Containers and Logging

Library Mode

Page 48: Containers and Logging

Library Mode

Page 49: Containers and Logging

Library Mode

Page 50: Containers and Logging

Library Mode

Page 51: Containers and Logging

Library Mode

Page 52: Containers and Logging

Library Mode

Page 53: Containers and Logging

Library Mode

Page 54: Containers and Logging

Library Mode

Page 55: Containers and Logging

Library Mode

Page 56: Containers and Logging

Messages Forwarding Performance

500K messages per second! (1 CPU core)

Page 57: Containers and Logging

Fluent BitRoadmap

● Built-in HTTP Monitoring

● Lua scripting support

Page 58: Containers and Logging

Thank You!

Eduardo Silva / @[email protected]

http://fluentd.org http://fluentbit.io


Top Related