telegraf
telegraf copied to clipboard
docker input - add container image ID
Good day, colleagues!
Current behavior of docker.input (Telegraf v1.7.1 (git: release-1.7 4be18c1e)) is to add the next tags to metrics:
- container_image ("sha256" or text label like 'nginx')
- container_name (something like "stoic_leavitt", can't be empty)
- container_version ('unknown' or if container_image is "sha256", then - full sha256 of image)
It is not convenient. I'd be happy if we could see the next tags:
- container image sha256 as separate entity (always)
- container_version like 'latest' or 'none' if there are no tag
It will make more order in measurements, because there can be situations like:
- we had some image called my_image:latest, then we rebuild it but we didn't stop the container based on previous image. What happens? The container based on old image will lose it's image name as it was relabeled on freshly built image. The
docker ps
would show image ID instead of name. The name of container ("gracious_jackson") of course is the same.
@gecube Sorry about the slow response, I have been looking through this issue closer today and I think I found a good way forward:
container image sha256 as separate entity (always)
I would be reluctant to do this since it could increase the series cardinality quite a bit, something the docker plugin already can struggle with.
container_version like 'latest' or 'none' if there are no tag
Not sure about using "latest", since it would be technically incorrect. We could potentially leave the tag off completely instead of using "unknown".
we had some image called my_image:latest, then we rebuild it but we didn't stop the container based on previous image.
I just tried this and sure enough it's like you say. However, I do notice that while listing containers via /containers/json
the container image name is replaced by a sha, inspecting the container closer via /containers/CONTAINERID/json
still retains the original image name. I think it would be preferable to report the container as the original tagged name, even though the tag no longer exists. Do you think that would work well for your use?
@jcmcken Since you worked on this code recently, does this seem like a good solution to you?
@danielnelson thank for your reply. It is not very bad that too much time passed :-) I believe that we shall have project session each other and think about use cases of docker input with telegraf. I really like telegraf as metrics agent, more than prometheus, cadvisor and others. But as I see our colleagues don't think so and switch to latter ones.
@danielnelson That sounds fine to me. I agree about the series cardinality, although it would be nice if Influx supported non-indexed metadata for stuff like that (e.g. I limit the query using standard InfluxQL clauses, now I want to look at some metadata attached to each row in a small subset of the data, but don't necessarily care about needing to query it with SELECT
clauses).
I debated changing unknown
to something else, but didn't want to introduce any backwards incompatibilities for people using the plugin.
Yeah unknown
is probably not what I would pick today, but I don't think changing it now is worth the disruption. I'll put together a change to prefer the inspect container data for container image.
@gecube for my understanding, what you want is
-
container_name
containing the "name" of the container, i.e. the--name
parameter of thedocker run
command e.g. 'nginx' -
container_image
containing the hash (sha256) of the container -
container_version
containing the tagged version of the container
Is this correctOf so, what if the container was not named? In this case
container_nameshould probably be the hash of the container instance as shown by
docker container list`, shouldn't it?
@srebhan Hi! Thanks for your answer. As I know, container name must be unique and docker will create a random name if you are not giving the name to container. So - yes, container name will be always present and could be obtained by docker container list
command, but it never will look like a sha256.
@gecube does this still exist with the latest version of telegraf? I checked and we now have
-
container_name
: name of the container as specified with--name
or autogenerated name -
container_image
: name of the container image -
container_id
: SHA256 hash of the container i.e. "CONTAINER ID" ofdocker container ls
-
container_version
: tag of the container image orunknown
I think that's what you were after, isn't it? If not, can you provide an example (some container image or Dockerfile) to reproduce the issue!?
Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Forums or provide additional details in this issue and reqeust that it be re-opened. Thank you!