Export envoy metrics for services

This commit is contained in:
IamTheFij 2023-03-02 11:00:30 -08:00
parent 882fe7e29c
commit 5228e7c7fb
2 changed files with 17 additions and 4 deletions

View File

@ -21,6 +21,7 @@ resource "nomad_job" "service" {
templates = var.templates
host_volumes = var.host_volumes
connect = anytrue([var.ingress, var.use_mysql, var.use_redis, var.use_ldap, length(var.upstreams) > 0])
upstreams = var.upstreams
use_mysql = var.use_mysql
use_redis = var.use_redis

View File

@ -15,6 +15,11 @@ job "${name}" {
to = ${service_port}
}
%{ endif }
%{ if connect }
port "envoy_metrics" {
to = 9123
}
%{~ endif }
}
%{ if length(group_meta) > 0 }
@ -42,7 +47,7 @@ job "${name}" {
name = "${replace(name, "_", "-")}"
port = "main"
%{ if anytrue([ingress, use_mysql, use_redis, use_ldap, length(upstreams) > 0]) }
%{ if connect }
connect {
sidecar_service {
proxy {
@ -71,6 +76,10 @@ job "${name}" {
local_bind_port = ${upstream.local_bind_port}
}
%{ endfor }
config {
envoy_prometheus_bind_addr = "0.0.0.0:9123"
}
}
}
@ -93,13 +102,16 @@ job "${name}" {
timeout = "10s"
}
%{ endif ~}
%{ if metrics_port_name != null ~}
%{~ endif }
meta {
%{ if metrics_port_name != null }
metrics_addr = "$${NOMAD_ADDR_${metrics_port_name}}"
%{ endif }
%{ if connect }
envoy_metrics_addr = "$${NOMAD_ADDR_envoy_metrics}"
%{~ endif }
}
%{ endif ~}
tags = [
%{ if ingress }
"traefik.enable=true",