grafana: add dynamic prometheus datasource

This commit is contained in:
wizzdom 2025-02-28 02:40:16 +00:00
parent 10fbcd5268
commit 6a3f7018e0
No known key found for this signature in database
GPG key ID: EEB7D796F4B09F07

View file

@ -48,11 +48,11 @@ job "grafana" {
ports = ["http"]
volumes = [
"/storage/nomad/${NOMAD_JOB_NAME}/${NOMAD_TASK_NAME}:/var/lib/grafana"
"/storage/nomad/${NOMAD_JOB_NAME}/${NOMAD_TASK_NAME}:/var/lib/grafana",
"local/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml"
]
}
template {
data = <<EOH
GF_DATABASE_TYPE=postgres
@ -66,6 +66,21 @@ EOH
destination = "local/.env"
env = true
}
template {
data = <<EOH
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
{{- range service "prometheus" }}
url: http://prometheus.service.consul:{{ .Port }}{{ end }}
isDefault: true
editable: false
EOH
destination = "local/datasources.yml"
}
}
task "db" {
driver = "docker"