-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Support tags filter on nomad service discovery #11775
Comments
Related to: #11465 |
2 months bump. |
6 months bump. 🤔 |
I'm working on a different approach, this is still a WIP. The idea is to use Nomad's templating in combination with Prometheus HTTP discovery; this is my HCL: job "prometheus-discovery" {
datacenters = ["dc1"]
namespace = "cluster"
type = "service"
update {
max_parallel = 1
health_check = "checks"
min_healthy_time = "10s"
healthy_deadline = "1m"
progress_deadline = "2m"
auto_revert = true
auto_promote = true
canary = 1
stagger = "10s"
}
group "prometheus-discovery" {
count = 2
ephemeral_disk {
size = 150
}
network {
port "http" {
to = 80
}
}
task "nginx" {
service {
name = "prometheus-discovery"
port = "http"
provider = "nomad"
check {
name = "status endpoint"
type = "http"
path = "/ping"
interval = "5s"
timeout = "1s"
method = "GET"
header {
User-Agent = ["Nomad"]
}
}
}
logs {
max_files = 10
max_file_size = 1
}
driver = "docker"
config {
image = "nginx:stable-alpine"
entrypoint = ["nginx", "-c", "/local/nginx.conf"]
ports = ["http"]
init = true
}
template {
destination = "local/nginx.conf"
env = false
change_mode = "restart"
data = <<-EOH
daemon off;
user nobody;
worker_processes 1;
events {
use epoll;
worker_connections 128;
}
http {
server {
root /local/www;
location /ping {
default_type text/plain;
return 200 "OK";
}
}
}
EOH
}
template {
destination = "local/www/services.json"
env = false
change_mode = "noop"
data = <<-EOH
{{- sprig_toPrettyJson nomadServices -}}
EOH
}
resources {
cpu = 100
memory = 64
}
}
}
} I could run this and point prometheus to it (optionally through my load balancer). |
No one wants to implement this? My Go-fu is at level 1 so I can't contribute. |
The approach above works for me in prod |
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Fixes prometheus#11775 Signed-off-by: Joseph Lorenzini <jaloren@fastmail.com>
Proposal
Use the same way of filtering services by
tags
as we can do with consul_sd_configs.This let's us have a single job "service-metrics" that auto-detects, filters and scrapes any service which are marked with
tags=prometheus,metrics
.Should also be backported to LTS version.
The text was updated successfully, but these errors were encountered: