liveBook · Manning

Log filtering

As explained in Learn Docker in a Month of Lunches, Second Edition

Log filtering is the selective retention, routing, or suppression of log records according to their attributes or severity.

Log filtering keeps logging useful without storing everything. An application can emit verbose records, while Fluentd selectively retains, routes, or suppresses them before storage. section 19.4

Use tags and match rules to tune collection without restarting application containers:

  • Configure Fluentd match blocks to inspect tags supplied by the Docker logging driver. section 19.4
  • Route verbose access-log records to Fluentd container stdout instead of Elasticsearch. section 19.4
  • Enrich records by splitting tags into application, service, and image fields for easier Kibana filtering. section 19.4
  • Change the Fluentd configuration independently, allowing logging-level adjustments without application downtime. section 19.4

Filter access logs

With a tag prefix of gallery.access-log, the first match block sends access-log entries to stdout. Other gallery records continue to Elasticsearch, so Kibana shows application logs but no newly filtered access logs. section 19.4

Listing 19.4 Sending log entries to different targets based on the tag
<match gallery.access-log.**>
  @type copy
  <store>
    @type stdout
  </store>
</match>
<match gallery.**>
  @type copy
  <store>
    @type elasticsearch
. . .

Inspect the Fluentd match configuration that sends tagged access logs to stdout and other gallery logs to Elasticsearch. section 19.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains tag-based Fluentd routing, enrichment, and configuration updates, but stops short of broader filtering strategies.
Examples
Demonstrates filtering gallery.access-log records to stdout while retaining other gallery logs in Elasticsearch.
What it assumes
Assumes Docker Compose and container logging familiarity while introducing Fluentd tags and match blocks.
What you can do after
Operate/configure Fluentd to route verbose container logs without changing application containers.
How it connects
Connects Docker logging drivers, Fluentd, stdout, Elasticsearch, and Kibana.

Also explained in

Compare how 2 books explain log filtering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.