Skip to content

feat(metrics): add configurable metrics level filtering for Prometheus exporter #2174

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

Draft
wants to merge 1 commit into
base: reboot
Choose a base branch
from

Conversation

vimalk78
Copy link
Collaborator

  • Add configurable metrics level filtering to control which metric types are exported by the Prometheus exporter
  • Implement metrics level configuration via command line flags and YAML config
  • Add support for granular control over node, process, container, VM, and pod metrics
  • Added tests

Supported metric levels: node, process, container, vm, pod, all, none

Usage:

sudo ./bin/kepler  --metrics=node --metrics=pod --kube.enable --kube.node-name="kind-worker2" --kube.config=/home/vimalkum/.kube/config

@github-actions github-actions bot added the feat A new feature or enhancement label Jun 20, 2025
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 95.97990% with 8 lines in your changes missing coverage. Please review.

Project coverage is 92.26%. Comparing base (63fc7f6) to head (db0050e).
Report is 2 commits behind head on reboot.

Files with missing lines Patch % Lines
internal/exporter/prometheus/prometheus.go 60.00% 4 Missing ⚠️
config/config.go 90.90% 2 Missing and 1 partial ⚠️
internal/exporter/prometheus/metrics/level.go 99.05% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           reboot    #2174    +/-   ##
========================================
  Coverage   92.26%   92.26%            
========================================
  Files          36       37     +1     
  Lines        3606     3763   +157     
========================================
+ Hits         3327     3472   +145     
- Misses        217      227    +10     
- Partials       62       64     +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vimalk78 vimalk78 marked this pull request as draft June 20, 2025 14:31
…s exporter

  - Add configurable metrics level filtering to control which metric types are exported by the Prometheus exporter
  - Implement metrics level configuration via command line flags and YAML config
  - Add support for granular control over node, process, container, VM, and pod metrics
  - Added tests

  Supported metric levels: node, process, container, vm, pod, all, none

Signed-off-by: Vimal Kumar <vimal78@gmail.com>
MetricsLevelPod // 16

// MetricsLevelAll represents all metrics enabled
MetricsLevelAll Level = MetricsLevelNode | MetricsLevelProcess | MetricsLevelContainer | MetricsLevelVM | MetricsLevelPod
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets avoid the none and the all until there is a specific usecase.

metricsLevels: [] | null

indicates all

Is there a specific usecase of none ?

@@ -36,6 +36,11 @@ exporter:
debugCollectors:
- go
- process
# metricsLevel: all
metricsLevel:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
metricsLevel:
metricsLevels:

to indicate multiple

@@ -91,6 +93,55 @@ type (
}
)

// MetricsLevelValue is a custom kingpin.Value that parses metrics levels directly into metrics.Level
type MetricsLevelValue struct {
level *metrics.Level
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be pointer? won't value suffice?

Comment on lines +120 to +128
// Handle special cases
if value == "all" {
*m.level = metrics.MetricsLevelAll
return nil
}
if value == "none" {
*m.level = metrics.MetricsLevelNone
return nil
}
Copy link
Collaborator

@sthaha sthaha Jun 22, 2025

Choose a reason for hiding this comment

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

Lets avoid the explicit "none" and and "all" cases until there is a specific use case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i don't see the need to remove these, the meanings are quite clear.

Copy link
Collaborator

@sthaha sthaha Jun 22, 2025

Choose a reason for hiding this comment

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

Its not about the meaning but about the purpose ... when would user want to set kepler to not export any metric for instance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the argument against all is similar. By default all metrics are exported, so

metricLevels: [] | null 

exports all metrics as well as ...

metricLevels: 
 - all

the all example looks odd IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat A new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants