We are using Nomad to schedule tasks which are then registered in Consul from where they are picked up in Prometheus scraping.
service.hcl:
job "myjob" {
group "mygroup" {
count = "1"
task "mytask" {
driver = "docker"
config {
image = "registry/stuff:someVersion"
port_map {
http = 8080
}
}
resources {
memory = 1024
network {
mbits = 100
port "http" {}
}
}
meta {
version = "0.0.1"
}
service {
tags = ["monitoring", "tagone", "tagtwo"]
port = "http"
name = "${JOB}"
check {
type = "http"
port = "http"
path = "/health"
interval = "20s"
timeout = "3s"
}
}
}
}
}
prometheus.yml:
scrape_configs:
- job_name: 'java_apps'
consul_sd_configs:
- server: "1.2.3.4:8500"
scheme: "http"
relabel_configs:
- source_labels: ['__meta_consul_tags']
regex: '(.*),monitoring,(.*)'
action: keep
- source_labels: ['__meta_consul_service']
target_label: service
metrics_path: /prometheus
Now my question is: Is there any way to propagate the value of the meta
keys from the service.hcl
file into Prometheus? According to the [Prometheus documentation|https://prometheus.io/docs/prometheus/latest/configuration/configuration/#],
The following meta labels are available on targets during relabeling: ... __meta_consul_metadata_: each metadata key value of the target
My question is twofold:
* What exactly is being considered as metadata for the target?
* How can I propagate the version
key from the meta
stanza to Prometheus to be used as a label?
0 Answers