Docker Plugin - Logging Driver - Loki

Hi, I am new to Nomad and trying to configure the logging driver to be Loki for all running docker jobs.

I am trying to pass the extra_labels to Loki via configuring it as such:

 logging {
       type = "loki"
       config {
         loki-url = "http://my_ip:3100/loki/api/v1/push"
         loki-external-labels = "job={{ .Label `com.hashicorp.nomad.job_name` }},task_name={{ .Label `com.hashicorp.nomad.task_name` }}, container_name="
       }
     }

But it returns an error:

API error (500): failed to initialize logging driver: error creating logger: error creating loki logger: loki: could not expand label value: {{ .Label `com.hashicorp.nomad.job_name` }} err : template: label_value:1:3: executing "label_value" at <.Label>: can't evaluate field Label in type *logger.Info

Hi @jrlaberge :wave:

I don’t have a lot of experience with Loki, but from their docs it doesn’t seem like it can read container labels?

Take a look at this blog post from the community Logging on Nomad and log aggregation with Loki :: Adrian Todorov, maybe there’s something there that can help you.

1 Like