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 templates = var.templates
host_volumes = var.host_volumes 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 upstreams = var.upstreams
use_mysql = var.use_mysql use_mysql = var.use_mysql
use_redis = var.use_redis use_redis = var.use_redis

View File

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