Skip to content

Instantly share code, notes, and snippets.

@qoomon
Created November 17, 2017 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoomon/ad65841ebe436f830e77a06bd63dc431 to your computer and use it in GitHub Desktop.
Save qoomon/ad65841ebe436f830e77a06bd63dc431 to your computer and use it in GitHub Desktop.
Docker Logging Tag
---
version: '2.3'
x-logging: &logging
driver: fluentd
options:
fluentd-address: localhost:24224
fluentd-async-connect: 'true'
tag: 'docker.{{if (index .ContainerLabels "logging-tag") }}{{index .ContainerLabels "logging-tag"}}.{{end}}{
"service_name": "${COMPOSE_PROJECT_NAME}",
"service_version": "${COMPOSE_PROJECT_VERSION}",
"container_name": "{{.Name}}",
"container_id": "{{.ID}}",
"container_image_name": "{{.ImageName}}",
"container_image_id": "{{index (split .ImageFullID ":") 1 | printf "%.12s"}}",
"tags": [ "."{{range $$key, $$value := .ContainerLabels}}, "{{$$key}}{{if $$value}}:{{$$value}}{{end}}"{{end}} ]
}'
services:
log_producer:
image: hashicorp/http-echo
cmd: [ "-text='hello world'"]
ports:
- "80:5678"
labels:
loggging-tag: http
foo: bar
production:
logging: *logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment