Skip to content

Commit

Permalink
Add namespace label on metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Oct 2, 2023
1 parent d9dfbc5 commit 30764ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/reconciliation/construct_podtemplatespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ func buildContainers(dc *api.CassandraDatacenter, baseTemplate *corev1.PodTempla
{Name: "CLUSTER_NAME", Value: dc.Spec.ClusterName},
{Name: "DATACENTER_NAME", Value: dc.DatacenterName()},
{Name: "RACK_NAME", ValueFrom: selectorFromFieldPath("metadata.labels['cassandra.datastax.com/rack']")},
{Name: "NAMESPACE", Value: dc.Namespace},
}

loggerContainer.Env = combineEnvSlices(loggerEnvDefaults, loggerContainer.Env)
Expand Down
1 change: 1 addition & 0 deletions pkg/reconciliation/construct_podtemplatespec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func TestLoggerContainerEnvVars(t *testing.T) {
assert.True(envVarsContains(loggerContainer.Env, rackNameEnvVar))
assert.True(envVarsContains(loggerContainer.Env, corev1.EnvVar{Name: "CLUSTER_NAME", Value: dc.Spec.ClusterName}))
assert.True(envVarsContains(loggerContainer.Env, corev1.EnvVar{Name: "DATACENTER_NAME", Value: dc.DatacenterName()}))
assert.True(envVarsContains(loggerContainer.Env, corev1.EnvVar{Name: "NAMESPACE", Value: dc.Namespace}))
}

func TestCassandraDatacenter_buildContainers_override_other_containers(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions tests/testdata/configs/vector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ data:
if err == null {
.rack = rack
}
namespace, err = get_env_var("NAMESPACE")
if err == null {
.namespace = namespace
}
'''
[sinks.console]
Expand Down

0 comments on commit 30764ce

Please sign in to comment.