Вот так выглядят 2 службы из числа многих в консуле:
"1": {
"ID": "1",
"Service": "Service X",
"Meta": {
"country": "USA"
},
"Port": 0,
"Address": "1.1.1.1",
"Weights": {
"Passing": 1,
"Warning": 1
},
"EnableTagOverride": false
}
"2": {
"ID": "2",
"Service": "Service Y",
"Meta": {
"country": "CANADA"
},
"Port": 0,
"Address": "2.2.2.2",
"Weights": {
"Passing": 1,
"Warning": 1
},
"EnableTagOverride": false
}
Каждая из этих служб имеет проверку работоспособности.
Моя цель - найти все исправные службы на основе консула К.В.,Например, найдите все службы, которые "проходят" в "США" , или найдите все "критические" службы в "КАНАДА" ,
Я пробовал несколько вариантов, проблема, с которой я сталкиваюсь, состоит в том, что все метрики имеют каждый релабель, который упоминается в config.yaml
QUERY 1
consul_health_service_status{status="passing", instance="USA"}
ВЫХОД
consul_health_service_status {check = "service: 1", instance = "USA", job = "консул", узел= "machine", service_id = "1", service_name = "Service X", status = "passing"} 1
consul_health_service_status {check = "service: 2", instance = "USA", job = "consul ", node =" machine ", service_id =" 2 ", service_name =" Service Y ", status =" passing "} 1
QUERY 2
consul_health_service_status{status="passing", instance="CANADA"}
ВЫХОД
consul_health_service_status {check = "service: 1", instance = "CANADA", job = "консул", узел= "machine", service_id = "1", service_name = "Service X", status = "passing"} 1
consul_health_service_status {check = "service: 2", instance = "CANADA", job = "consul ", node =" machine ", service_id =" 2 ", service_name =" Service Y ", status =" passing "} 1
CONFIG
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'consul'
consul_sd_configs:
- server: 'localhost:8500'
services: []
relabel_configs:
- source_labels: [__meta_consul_service_metadata_country]
target_label: instance
- source_labels: ['__meta_consul_address']
separator: ';'
target_label: '__address__'
replacement: 'localhost:9107'
action: 'replace'
Мне бы очень хотелось увидеть такой вывод:
QUERY 1
consul_health_service_status{status="passing", instance="USA"}
OUTPUT
consul_health_service_status {check = "service: 1", instance = "USA", job = "консул", node = "machine", service_id = "1", service_name = "Служба X", статус = "прохождение"} 1
QUERY 2
consul_health_service_status{status="passing", instance="CANADA"}
ВЫХОД
consul_health_service_status {check = "service: 2", instance = "CANADA", job = "консул", node = "machine", service_id = "2", service_name = "Услуга Y ", статус =" прохождение "} 1