Skip to content

How to dynamically retrieve internal IP for docker container? #4829

Closed Answered by pschiffe
pschiffe asked this question in Q&A
Discussion options

You must be logged in to vote

I've solved it with discovery.relabel:

discovery.docker "default" {
  host = "unix:///var/run/docker.sock"
  port = 8080

  filter {
    name = "label"
    values = ["metrics.job"]
  }
}

discovery.relabel "docker" {
  targets = discovery.docker.default.targets

  rule {
    source_labels = ["__meta_docker_network_ip", "__meta_docker_container_label_metrics_port"]
    separator     = ":"
    target_label  = "__address__"
    action        = "replace"
  }

  rule {
    source_labels = ["__meta_docker_container_label_metrics_path"]
    target_label  = "__metrics_path__"
    action        = "replace"
  }

  rule {
    source_labels = ["__meta_docker_container_label_metrics_job"]
    target_l…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pschiffe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant