From aa05d022dad004d478c67197496cd7c9d4252041 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Jun 2026 18:49:46 -0300 Subject: [PATCH] feat: optionally push to prometheus and loki --- .env.sample | 8 ++++++-- abra.sh | 2 +- config.alloy.tmpl | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env.sample b/.env.sample index bfe6839..519b2e4 100644 --- a/.env.sample +++ b/.env.sample @@ -6,14 +6,18 @@ DOMAIN=monitoring-ng.example.com ENABLE_BACKUPS=true SECRET_BASIC_AUTH_VERSION=v1 -# LOKI_PUSH_URL=https://loki.monitoring.example.org/loki/api/v1/push +# Enable this to send logs to a Loki server, adapt DOMAIN if server is +# remote +# LOKI_PUSH_URL=https://loki.$DOMAIN/loki/api/v1/push +# Enable this to send metrics to a Prometheus server, adapt DOMAIN if +# server is remote +# PROMETHEUS_REMOTE_WRITE_URL=https://prometheus.$DOMAIN/api/v1/write # Monitoring Server # ## Prometheus # COMPOSE_FILE="$COMPOSE_FILE:compose.prometheus.yml" -# PROMETHEUS_REMOTE_WRITE_URL=https://prometheus.$DOMAIN/api/v1/write # PROMETHEUS_RETENTION_TIME=1y # ## Prometheus Pushgateway diff --git a/abra.sh b/abra.sh index e378367..5046f7f 100644 --- a/abra.sh +++ b/abra.sh @@ -11,7 +11,7 @@ export PROMETHEUS_YML_VERSION=v2 export MATRIX_ALERTMANAGER_CONFIG_VERSION=e export MATRIX_ALERTMANAGER_ENTRYPOINT_VERSION=a export GRAFANA_ALERTS_NODE_VERSION=v1c -export CONFIG_ALLOY_VERSION=v6 +export CONFIG_ALLOY_VERSION=v7 # creates a default prometheus scrape config for a given node add_node(){ diff --git a/config.alloy.tmpl b/config.alloy.tmpl index 0d850fa..8fc9b23 100644 --- a/config.alloy.tmpl +++ b/config.alloy.tmpl @@ -7,6 +7,7 @@ discovery.docker "linux" { host = "unix:///var/run/docker.sock" } +{{ if ne (env "PROMETHEUS_REMOTE_WRITE_URL") "" }} prometheus.exporter.cadvisor "docker" { } @@ -38,7 +39,9 @@ prometheus.remote_write "prometheus" { } } } +{{ end }} +{{ if ne (env "LOKI_PUSH_URL") "" }} loki.source.docker "docker" { host = "unix:///var/run/docker.sock" targets = discovery.docker.linux.targets @@ -56,3 +59,4 @@ loki.write "loki" { } } } +{{ end }}