Update logging driver

Hi,

We’re trying to switch the logging driver on nomad from default into using the loki docker driver plugin.

{
  "dns": ["172.17.0.1"],
  "debug" : true,
  "log-driver": "loki",
  "log-opts": {
      "loki-url": "https://loki.domain.com/loki/api/v1/push",
      "loki-batch-size": "400",
      "loki-retries": "0",
      "env": "NOMAD_JOB_NAME",
      "labels": "service"
  }
}

However, the jobs don’t seem to get updated in terms of nomad specs, how do you force nomad to deploy with the updated driver without needing to define the driver in each jobspec?

Hi @dpewsey,

What Nomad config object does this represent?

Thanks,
jrasell and the Nomad team

Hi @jrasell

This is the docker daemon.json /etc/docker/daemon.json
With an average jobspec looking like such

    task "grafana" {
      driver = "docker"
       env {
         GF_PATHS_PROVISIONING="/local/provisioning"
       }
       config {
         image = ""
         args = ["--config=/local/grafana.yaml"]
         ports = ["grafana"]
         logging {
         }
       }

however when redeploying the app the logging driver remains json-file

 docker inspect bd9d90285104 | jq '.[].HostConfig.LogConfig'
{
  "Type": "json-file",
  "Config": {
    "max-file": "2",
    "max-size": "2m"
  }
}

Digging a bit more the only way it seems to get updated is by adding a blank logging and config stanza, otherwise it doesn’t seem to pick it up.

       config {
         image = ""
         args = ["--config=/local/grafana.yaml"]
         ports = ["grafana"]
         logging { 
           config {}
         }
       }

It there a way to apply this to all jobs without the need to update all the specs?

Hi @dpewsey,

It there a way to apply this to all jobs without the need to update all the specs?

There is not unfortunately as Nomad does not have a notion of external admissions controllers that can mutate all jobs on registration.

Thanks,
jrasell and the Nomad team

Hi @jrasell
Thanks for the reply, how annoying.

Is there another way to get nomad job to use the logging config specified via docker without needing to include it in the jobspec? eg like a default open when using the docker driver or to use the docker driver’s details?

Hi @dpewsey,

I believe you can configure the logging block within the Nomad client configuration file. This should set the default logging configuration which all Docker containers receive.

Thanks,
jrasell and the Nomad team

Ah that’s that did it, once the containers have been restarted thanks!

1 Like