Skip to content

Commit

Permalink
OM-173 - Old exporter config file fails (#109)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mphanias authored Mar 5, 2024
1 parent f3fa7d7 commit d3eebae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions configs/ape.toml
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down
4 changes: 2 additions & 2 deletions configs/ape.toml.template
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down
8 changes: 6 additions & 2 deletions internal/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d3eebae

Please sign in to comment.