diff --git a/pkg/telemetry/cassandra_agent/cassandra_agent_config.go b/pkg/telemetry/cassandra_agent/cassandra_agent_config.go index fbc29981d..ceaf81f09 100644 --- a/pkg/telemetry/cassandra_agent/cassandra_agent_config.go +++ b/pkg/telemetry/cassandra_agent/cassandra_agent_config.go @@ -12,6 +12,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/cassandra" "github.com/k8ssandra/k8ssandra-operator/pkg/labels" "github.com/k8ssandra/k8ssandra-operator/pkg/result" + promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -22,6 +23,26 @@ import ( var ( agentConfigLocation = "/config/metric-collector.yaml" + defaultAgentConfig = telemetryapi.CassandraAgentSpec{ + Endpoint: telemetryapi.Endpoint{ + Port: "9001", + Address: "127.0.0.1", + }, + Filters: []promapi.RelabelConfig{ + { + SourceLabels: []string{"__tag1__", "__tag2__"}, + Separator: ";", + Regex: "(.*);(b.*)", + Action: "drop", + }, + { + SourceLabels: []string{"__tag1__", "__tag2__"}, + Separator: ",", + Regex: "^(a|b|c),.*", + Action: "drop", + }, + }, + } ) type Configurator struct { @@ -33,10 +54,20 @@ type Configurator struct { } func (c Configurator) GetTelemetryAgentConfigMap() (*corev1.ConfigMap, error) { - yamlData, err := yaml.Marshal(&c.TelemetrySpec.Cassandra) - if err != nil { - return &corev1.ConfigMap{}, err + var yamlData []byte + var err error + if c.TelemetrySpec.Cassandra != nil { + yamlData, err = yaml.Marshal(&c.TelemetrySpec.Cassandra) + if err != nil { + return &corev1.ConfigMap{}, err + } + } else { + yamlData, err = yaml.Marshal(&defaultAgentConfig) + if err != nil { + return &corev1.ConfigMap{}, err + } } + cm := corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: c.Kluster.Namespace,