Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nomad should pass job, alloc and task ids as docker labels #4781

Closed
samart opened this issue Oct 14, 2018 · 10 comments
Closed

Nomad should pass job, alloc and task ids as docker labels #4781

samart opened this issue Oct 14, 2018 · 10 comments

Comments

@samart
Copy link

samart commented Oct 14, 2018

It woudl be very useful if nomad passed jobId, alloc Id, and taskid as docker labels on container.create().

This will allow us to correlate - via monitoring tools, (Sysdig/Prometheus/etc) and security tooling - running containers with nomad Runtime metadata. Its very common for these tools to pull in docker labels as means for identification and other categorization purposes.

@rcgenova

@samart samart changed the title Nomad should pass task and alloc ids as docker labels Nomad should pass job, alloc and task ids as docker labels Oct 14, 2018
@jippi
Copy link
Contributor

jippi commented Oct 14, 2018

You can just pass them in

job "demo" {
  group "demo" {
    task "demo" {
      config {
        labels {
          key = value
        }
      }
    }
  }  
}

@samart
Copy link
Author

samart commented Oct 14, 2018

Where would the values come from at runtime? Are there variables i can use to set them? (Let me look..)

Edit - i looked and I only see ENV vars that have these details (aside from jobId), which i’m not sure we can pass in as labels in the job file. Or can we?

Note - mesos does this automatically. (It sorta feels like it shoudl be an automatic thing)

@jippi
Copy link
Contributor

jippi commented Oct 14, 2018

you can reference any environment key using interpolation

@drarnold
Copy link

drarnold commented Jan 14, 2020

Hey @jippi ,

I was going to be using Docker Labels for our containers to autodiscover haproxy and would be putting it into the Nomad Definition. I am curious how to handle each of the keys:
https://docs.datadoghq.com/integrations/haproxy/#containerized
(Especially the Instance Config parameter - <INSTANCE_CONFIG>)

What would the syntax look like because it seems like single quotes are not recognized by the Nomad definition?

Thanks

@kshpytsya
Copy link

Absence of this feature prevents me from effectively using cAdvisor (with Prometheus), as we have same task names in different nomad jobs. I am even considering implementing an augmenting proxy that would rewrite Prometheus metrics obtained from cAdvisor adding Nomad job and group name based on the allocation id, which is included as a suffix in the name label (querying local Nomad agent to get allocation info). But of course, it would be much better to just have it properly implemented in Nomad itself. Modifying job descriptions as suggested in #4781 (comment) is highly impractical in our case.

@m1keil
Copy link

m1keil commented Apr 28, 2020

@kshpytsya you can expose these via cadvisor's --docker_env_metadata_whitelist

@sofixa
Copy link
Contributor

sofixa commented Jan 13, 2021

Any news on this? It would be a very useful feature for log shipping agents ( like promtail) which can only read Docker labels.

@sofixa
Copy link
Contributor

sofixa commented Jan 25, 2021

FYI i've created a PR adding those labels #9885

@tgross tgross added this to Needs Roadmapping in Nomad - Community Issues Triage Feb 12, 2021
@tgross tgross moved this from Needs Roadmapping to In Progress in Nomad - Community Issues Triage Mar 4, 2021
@tgross
Copy link
Member

tgross commented Mar 22, 2021

Forgot to close this one out when #9885 was merged. Marked for 1.1.0

@tgross tgross closed this as completed Mar 22, 2021
Nomad - Community Issues Triage automation moved this from In Progress to Done Mar 22, 2021
@tgross tgross added this to the 1.1.0 milestone Mar 22, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants