Docker Community Forums

Share and learn in the Docker community.

Using an existing label as a log driver tag for ELK?


(Ryuzaki) #1

Hey

Just wondering if anyone had any clear instructions on how to use an existing label on a container in it’s log driver tag? The documentation certainly suggests it’s possible at the end of the log tags page with a go template called ExtraAttributes:

 docker run -it --rm \
    --log-driver syslog \
    --log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \
    --log-opt env=SOME_ENV_VAR \
    -e SOME_ENV_VAR=logtester.1234 \
    flyinprogrammer/logtester

I’m also wondering about the limitations here as the label I want to use has full stops in it. ELK doesn’t like full stops though. As an aside can I set a new label with underscores to another label to avoid the full stop limitation?

Cheers,
R