Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add namespace label on metrics #574

Merged
merged 3 commits into from
Oct 2, 2023
Merged

Conversation

adejanovski
Copy link
Contributor

What this PR does:
Adds the namespace as env variable in the server-system-logger container.

Which issue(s) this PR fixes:
Fixes #573

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CHANGELOG.md updated (not required for documentation PRs)
  • CLA Signed: DataStax CLA

@adejanovski adejanovski requested a review from a team as a code owner October 2, 2023 08:08
@@ -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},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a correct approach in general sense or how other stuff is done. The pod itself knows the namespace already, it's in the file /var/run/secrets/kubernetes.io/serviceaccount/namespace so just catting that would be enough. This is also something that can be used in the upstream alone without needing a new version of cass-operator by simply modifying the vector configuration there.

The other "correct" method I think is to use selector, so:

{Name: "NAMESPACE", ValueFrom: selectorFromFieldPath("metadata.namespace")},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vector VRLs language doesn't have a function to read data from a file. All we can do is read the hostname or read an env variable (see here).
So I think we need the additional variable to avoid building a convoluted solution.
I'm ok with using the "metadata.namespace" instead of the dc namespace, I'll push a change for this.

@adejanovski adejanovski requested a review from burmanm October 2, 2023 12:11
@adejanovski adejanovski force-pushed the add-namespace-metrics-label branch from ac9e73b to 7e210b0 Compare October 2, 2023 12:12
@burmanm burmanm merged commit 34e2ae6 into master Oct 2, 2023
35 of 38 checks passed
@burmanm burmanm deleted the add-namespace-metrics-label branch September 23, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics need the namespace as label
2 participants