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 customfields to prometheus labels #314

Merged
merged 4 commits into from
Apr 23, 2022

Conversation

LivingInSyn
Copy link
Contributor

@LivingInSyn LivingInSyn commented Apr 15, 2022

Signed-off-by: Jeremy Mill [email protected]

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area config

/area outputs

/area tests

What this PR does / why we need it:

This PR allows users to configure custom prometheus labels. It is separate from the CUSTOMFIELDS configuration to avoid creating too many series in prometheus.

Which issue(s) this PR fixes:
n/a

Fixes #

Special notes for your reviewer:
The primary use case is to do something like add a cluster and environment tag to prometheus metrics to differentiate between clusters and prod/dev environments.

Sample output from a test in my cluster with this build is:

falco_events{app_kubernetes_io_instance="falco", app_kubernetes_io_name="falcosidekick", cluster="security", environment="dev", instance="10.96.2.18:2801", job="kubernetes-pods", k8s_ns_name="default", k8s_pod_name="prom-prometheus-node-exporter-7zk92", namespace="default", pod="falco-falcosidekick-6fc876bb4c-njk9n", pod_template_hash="6fc876bb4c", priority="Informational", rule="Launch Sensitive Mount Container"}

I'm open to changing how this was done if there are concerns that I'm not aware of

Signed-off-by: Jeremy Mill <[email protected]>
@LivingInSyn LivingInSyn changed the title add custom prometheus labes add customfields to prometheus labels Apr 15, 2022
@Issif Issif added this to the 2.25.0 milestone Apr 16, 2022
stats_prometheus.go Outdated Show resolved Hide resolved
@LivingInSyn
Copy link
Contributor Author

LivingInSyn commented Apr 16, 2022

@Issif I made sure the labels are valid prometheus labels according to their docs here in this commit: dd989ed

I wanted to also add unit testing to this since it seems a likely place to have an accidental breakage in the future. To support unit testing in the main package I added a check in 8761d46 to avoid running init when unit testing. This is because kingpin really doesn't work nicely with go test (see: alecthomas/kingpin#194 and other associated issues)

Let me know what you think

@poiana
Copy link

poiana commented Apr 23, 2022

LGTM label has been added.

Git tree hash: fd34b4581def8af037c85d5fea7d5329e10e952d

@poiana
Copy link

poiana commented Apr 23, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Issif, LivingInSyn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants