docker logs env variables #6385
Labels
source: docker_logs
Anything `docker_logs` source related
type: enhancement
A value-adding code change that enhances its existing functionality.
Current Vector Version
Use-cases
I'm trying to run vector as a general purpose log shipper for a Nomad cluster (with Docker execution). Ideally - I'd like log shipping and aggregation to be totally transparent to the user. In order to accomplish this - metadata about each docker container needs to be collected.
Attempted Solutions
The canonical solution to this problem is to enrich your images (or containers, at runtime) with docker labels and parse the labels in the log aggregator. The docker daemon on each Nomad client node needs to be configured to pass through label metadata to the log driver - like this (in daemon.json):
This configuration instructs docker to forward any labels whose key is
logging_job_name
along with the other log metadata to thejson-file
log driver (by default).Vector has support for this process in that the Vector docker source forwards label metadata to downstream transforms and sinks. This solution, however, requires each user to label the job with either information that already exists in the container as environment variables by default (NOMAD_JOB_NAME, for example), or create labels that might clash with other job's labels. Nomad has no way to enforce unique labels per job/task.
Proposal
In addition to the above docker configuration for labels, docker can also optionally forward environment variable key/values with the log metadata. The configuration looks quite similar:
This daemon configuration could work in concert with vector configuration in the following way - I've used the
file
sync as a simple example:Of course - this environment variable could also be consumed by downstream vector transforms, sinks, or log aggregators.
References
I couldn't find any tickets like this, but I did have a brief discussion with @jszwedko on the discord chat.
The relevant bit of code in vector to add to probably starts with this struct:
https://github.com/timberio/vector/blob/master/src/sources/docker_logs.rs#L65-L78
The text was updated successfully, but these errors were encountered: