From d3eebae9e5ab0dda136807bbe3ab97981b7b74a0 Mon Sep 17 00:00:00 2001 From: mphanias <121247041+mphanias@users.noreply.github.com> Date: Tue, 5 Mar 2024 23:31:51 +0530 Subject: [PATCH] OM-173 - Old exporter config file fails (#109) If old config file is used without prometheus config key, fall back to prometheus enabled mode added enable_ prefix to config names for prometheus & open-telemetry --- configs/ape.toml | 4 ++-- configs/ape.toml.template | 4 ++-- internal/pkg/config/config.go | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configs/ape.toml b/configs/ape.toml index b494a966..9187a1cd 100644 --- a/configs/ape.toml +++ b/configs/ape.toml @@ -1,7 +1,7 @@ [Agent] # Metrics Serving modes - PROMETHEUS = true - OPEN_TELEMETRY = false + enable_prometheus = true + enable_open_telemetry = false # labels to add to the prometheus metrics for e.g. labels={zone="asia-south1-a", platform="google compute engine"} labels = {latitude="0",longitude="0"} diff --git a/configs/ape.toml.template b/configs/ape.toml.template index 1a68b3d1..260c5e4f 100644 --- a/configs/ape.toml.template +++ b/configs/ape.toml.template @@ -1,7 +1,7 @@ [Agent] # Metrics Serving modes - PROMETHEUS = ${AGENT_PROMETHEUS} - OPEN_TELEMETRY = ${AGENT_OPEN_TELEMETRY} + enable_prometheus = ${AGENT_PROMETHEUS} + enable_open_telemetry = ${AGENT_OPEN_TELEMETRY} # labels to add to the prometheus metrics for e.g. labels={zone="asia-south1-a", platform="google compute engine"} labels = {${METRIC_LABELS}} diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 4ee1a078..05afd0bf 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -15,8 +15,8 @@ var Cfg Config // Config represents the aerospike-prometheus-exporter configuration type Config struct { Agent struct { - OtelEnabled bool `toml:"OPEN_TELEMETRY"` - PrometheusEnabled bool `toml:"PROMETHEUS"` + OtelEnabled bool `toml:"enable_open_telemetry"` + PrometheusEnabled bool `toml:"enable_prometheus"` MetricLabels map[string]string `toml:"labels"` @@ -176,6 +176,10 @@ func (c *Config) ValidateAndUpdate(md toml.MetaData) { c.Agent.Otel.OtelPushInterval = 15 } + if !md.IsDefined("Agent", "enable_prometheus") { + log.Infof("Defaulting to Prometheus Exporting mode") + c.Agent.PrometheusEnabled = true + } } func (c *Config) FetchCloudInfo(md toml.MetaData) {