Is it there any possibility of define dynamic labels on containers? Like the "hostname"

274 views
Skip to first unread message

basili...@softonic.com

unread,
Nov 5, 2016, 11:13:10 AM11/5/16
to docker-dev
Hi, 

I see that each time I create a service some labels are automatically assigned to the containers that run each service task. For example:

```
"Labels": {
                "com.docker.swarm.node.id": "0td8h541ayzmzh8mdlayvi9ks",
                "com.docker.swarm.service.id": "cr01rvd7ugu3a5r5gs3apypau",
                "com.docker.swarm.service.name": "deleteme2",
                "com.docker.swarm.task": "",
                "com.docker.swarm.task.id": "e3cif2jl3wdmfd56dpgkxebga",
                "com.docker.swarm.task.name": "deleteme2.1"
            }
```

Would be possible to define an arbitrary label whose value is dynamic? I mean on environment variables set in the host, or docker daemon labels.

In my particular case I wan to identify the host "hostname", because it allows me to filter monitoring data via cAdvisor.
I know there's a value named "node.id" but this value does not have any meaning for me and I cannot merge it with other values when filtering metrics.

In my case I have some metrics obtained from node-exporter, where I have the hostname, and I'm interested to have a single id for each node whose name is well known by me.

The result now can be seen in a dashboard I did for swarm based on cAdvisor+NodeExporter+Prometheus+Grafana: https://grafana.net/dashboards/609

A screenshot of what I've now can be seen here: https://grafana.net/api/dashboards/609/images/542/image

Sebastiaan van Stijn

unread,
Nov 7, 2016, 6:52:33 AM11/7/16
to basili...@softonic.com, docker-dev
You may be interested in this PR, which is working on “templating” service options;

Not sure if hostname is part of the template though (keep in mind that the hostname is not managed by Swarm, so
for that reason may not be part of the template; the node.id is the canonical identifier of a host)

--
You received this message because you are subscribed to the Google Groups "docker-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to docker-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

basili...@softonic.com

unread,
Nov 7, 2016, 9:19:58 AM11/7/16
to docker-dev, basili...@softonic.com
I know the node.id value, as I said. But as it's an internal value that does not have any meaning outside of the swarm cluster. For external tools is a useless value that does not provide any semantic. :(

Currently is the value I'm using to filter containers per host in my grafana panel, but as I cannot relate it with the hostname (which is a well know value) it's weird for the user to identify the host where something is happening. And I cannot obtain crossed metrics with other sources that provide node values based on the hostname.
Reply all
Reply to author
Forward
0 new messages