Skip to content

Docker input doesn't parse image names correctly #5835

@jcmcken

Description

@jcmcken

Relevant telegraf.conf:

It's not really relevant, but:

[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
gather_services = false
perdevice = false
total = true

System info:

Telegraf 1.9.1 (git: HEAD 2063609)
Docker 18.09.4, build d14af54266

Steps to reproduce:

  1. Run a container from a private registry on a specific port, but without a tag, e.g. docker run -d repo.example.com:9003/postgres (no :latest or any other tag, which is a valid way to run a container)
  2. Start Telegraf with the Docker input.
  3. Run telegraf --config <file> --test --input-filter docker and observe the output.

Expected behavior:

The container_image should be repo.example.com:9003/postgres and the container_version should be latest (since no tag was specified).

Actual behavior:

The metrics will show the container_image as repo.example.com and the container_version as 9003/postgres.

Additional info:

The image parsing logic is here, and does not account for the case where the registry URL includes a port and no tag is present in the image name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dockerbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions