0xERR0R / dex

Prometheus Docker EXporter
49 stars 8 forks source link

Adding some more (static) container labels #91

Open vsund opened 4 months ago

vsund commented 4 months ago

Hi there, first of all thanks for this project, it's a great lightweight way to gain a little bit insight into running containers without having to use e.g. cAdvisor.

I'm searching for a way to list running containers from various machines (and Prometheus is probably the most straightforward way of doing so). The dex_container_running metric is great for that, however I think we could add some more labels there.

I poked a little bit around and think it would be quite easy to add it. The Docker API has some more interesting fields available. I guess it's not so easy to add the slice fields, but e.g. Image, ImageID and Created could be simply added to NewDesc via variableLabels or constLabels.

What do you think? I'd be happy to contribute it, especially as it seems quite straightforward :)

0xERR0R commented 4 months ago

Hey, I think, it is a good idea, but we should take in account that each key/value combination for label increases storage on disk (prometheus), see from https://prometheus.io/docs/practices/naming/#labels

CAUTION: Remember that every unique combination of key-value label pairs represents a new time series, which can dramatically increase the amount of data stored. Do not use labels to store dimensions with high cardinality (many different label values), such as user IDs, email addresses, or other unbounded sets of values.

That mean, if you have containers which are frequently updated (newer docker image version), that could have negative impact.

Maybe we should add just one label (image:version) to reduce the amount of labels?