Skip to content

NETOBSERV-2234: Validation warning about missing metrics#2552

Open
Amoghrd wants to merge 3 commits intonetobserv:mainfrom
Amoghrd:netobserv-2234
Open

NETOBSERV-2234: Validation warning about missing metrics#2552
Amoghrd wants to merge 3 commits intonetobserv:mainfrom
Amoghrd:netobserv-2234

Conversation

@Amoghrd
Copy link
Copy Markdown
Member

@Amoghrd Amoghrd commented Mar 16, 2026

Description

Warning saying that some of the queries run from the console plugin will fail when user does not add some of the default metrics in includeList

Dependencies

#2546

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Summary by CodeRabbit

  • Bug Fixes

    • Consistently filter out metrics tied to disabled features from both default and user-specified metric include lists.
    • Added a validation warning when the console plugin is enabled in Prometheus-only mode and a custom metrics list omits required default metrics.
  • Tests

    • Expanded tests covering console-plugin validation and missing-default scenarios with customized include lists.

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Mar 16, 2026

@Amoghrd: This pull request references NETOBSERV-2234 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Description

Warning saying that some of the queries run from the console plugin will fail when user does not add some of the default metrics in includeList

Dependencies

n/a

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@Amoghrd Amoghrd requested a review from jotak March 16, 2026 18:09
@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Mar 16, 2026

@Amoghrd: This pull request references NETOBSERV-2234 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Description

Warning saying that some of the queries run from the console plugin will fail when user does not add some of the default metrics in includeList

Dependencies

#2546

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.00%. Comparing base (6ad9ed9) to head (6d57df4).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2552      +/-   ##
==========================================
- Coverage   72.07%   72.00%   -0.08%     
==========================================
  Files         105      105              
  Lines       10924    10953      +29     
==========================================
+ Hits         7874     7887      +13     
- Misses       2565     2578      +13     
- Partials      485      488       +3     
Flag Coverage Δ
unittests 72.00% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...flowcollector/v1beta2/flowcollector_alert_types.go 97.77% <100.00%> (+0.18%) ⬆️
...lector/v1beta2/flowcollector_validation_webhook.go 73.85% <100.00%> (+1.76%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Amoghrd Amoghrd added the needs-review Tells that the PR needs a review label Mar 17, 2026
@Amoghrd Amoghrd requested a review from jpinsonneau March 24, 2026 21:04
jpinsonneau
jpinsonneau previously approved these changes Mar 30, 2026
@openshift-ci openshift-ci Bot added the lgtm label Mar 30, 2026
@Amoghrd Amoghrd removed the needs-review Tells that the PR needs a review label Mar 30, 2026
}
}

func (v *validator) validateFLPMetricsForConsolePlugin() {
Copy link
Copy Markdown
Member

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 warning is going to be always relevant. Some metrics from the defaults can be disabled or modified without necessarily being a problem for the console display. I can think for example about "node_to_node_ingress_flows_total" which is used in default alerts but not in the console queries (and it generates already a warning if it's disabled AND the related alert is in use)

Which means sometimes the warning would be triggered as a false positive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TBH, we have improved the situation lately about missing metrics in the console, I wonder if it's still worth it to try doing something in the webhook

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So is it better to have a separate list of metrics only required for console which does not include alerts?
Or since we implemented incremental metrics too, is it better to not have this warning at all?

@Amoghrd
Copy link
Copy Markdown
Member Author

Amoghrd commented Apr 3, 2026

/hold

@Amoghrd Amoghrd added the needs-review Tells that the PR needs a review label Apr 8, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 8, 2026

New changes are detected. LGTM label has been removed.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 8, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jpinsonneau. For more information see the Code Review Process.

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

Details 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a6e1a18-caa7-4760-8a55-d33e5cbf16eb

📥 Commits

Reviewing files that changed from the base of the PR and between 7a3a51c and 6d57df4.

📒 Files selected for processing (1)
  • api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go

📝 Walkthrough

Walkthrough

Refactors metric-include computation into shared helpers, adds validation that warns when the web console plugin is enabled while Loki is disabled and a custom metrics include list omits required defaults, and extends unit tests to cover these validation scenarios.

Changes

Cohort / File(s) Summary
Metric Computation Refactoring
api/flowcollector/v1beta2/flowcollector_alert_types.go
Extracted disabled-feature metric filtering into removeDisabledFeatureMetrics(); added GetDefaultMetrics() to choose base defaults by Loki status and apply filtering; updated GetIncludeList() to apply filtering to both default and user-provided lists.
Console Plugin Validation
api/flowcollector/v1beta2/flowcollector_validation_webhook.go
Added validateFLPMetricsForConsolePlugin() and integrated it into validateFLP(); emits a warning when Loki is disabled, the console plugin is enabled, and a custom processor.metrics.includeList omits required default metrics.
Test Coverage
api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go
Added table-driven test cases verifying warnings for missing default metrics in Prometheus-only (Loki disabled) + console-enabled scenarios, plus cases for compliant lists, Loki-enabled mode, console-disabled mode, and nil includeList.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references a specific issue (NETOBSERV-2234) and accurately describes the main change: adding a validation warning about missing metrics.
Description check ✅ Passed The description covers the main purpose, lists a dependency, and completes the checklist with unit tests added and QE requirements specified.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@Amoghrd
Copy link
Copy Markdown
Member Author

Amoghrd commented Apr 8, 2026

/unhold

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Apr 8, 2026

@Amoghrd: This pull request references NETOBSERV-2234 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Description

Warning saying that some of the queries run from the console plugin will fail when user does not add some of the default metrics in includeList

Dependencies

#2546

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Summary by CodeRabbit

  • Bug Fixes

  • Improved metric filtering consistency when optional features are disabled.

  • Added validation warnings to alert users when custom metrics exclude defaults required for console plugin operation in Prometheus-only mode.

  • Tests

  • Enhanced test coverage for metrics validation scenarios.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
api/flowcollector/v1beta2/flowcollector_validation_webhook.go (1)

443-467: ⚠️ Potential issue | 🟠 Major

False-positive risk: warning compares against full defaults, not console-query-required metrics.

On Line 443, GetDefaultMetrics() is used as the required set, but the warning on Line 464 says those are required for console plugin queries. That over-approximates and can warn on metrics that console queries do not actually need.

Suggested direction
- defaults := v.fc.GetDefaultMetrics()
+ required := v.fc.GetConsolePluginRequiredMetrics()
...
- for _, metric := range defaults {
+ for _, metric := range required {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/flowcollector/v1beta2/flowcollector_validation_webhook.go` around lines
443 - 467, The warning is using v.fc.GetDefaultMetrics() (GetDefaultMetrics) as
the required set but should only check metrics actually needed by console
queries; change the check in the validation that builds userMetrics from
v.fc.Processor.Metrics.IncludeList and compares against defaults to instead
compute the concrete set of console-required metrics (e.g., a new function or
constant like ConsoleQueryRequiredMetrics) and compare userMetrics to that set;
update the message and keep guidance about using
spec.processor.metrics.additionalIncludeList, appending the warning to
v.warnings only when console-required metrics (not the full defaults) are
missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go`:
- Around line 911-1010: Add two edge-case table-driven tests in
flowcollector_validation_webhook_test.go covering
spec.processor.metrics.includeList == nil and spec.processor.metrics.includeList
== &[]FLPMetric{}: create FlowCollector test entries (use FlowCollector,
FlowCollectorSpec, FlowCollectorLoki, FlowCollectorConsolePlugin,
FlowCollectorFLP, FLPMetrics) mirroring the existing "Console plugin with Loki
disabled..." case but once omitting IncludeList (nil) and once setting
IncludeList: &[]FLPMetric{} (empty slice), and assert the same expectedWarnings
about missing default metrics when ConsolePlugin.Enable is true and Loki.Enable
is false; also include a case showing no warning when ConsolePlugin is disabled
to cover the empty/nil path.

---

Duplicate comments:
In `@api/flowcollector/v1beta2/flowcollector_validation_webhook.go`:
- Around line 443-467: The warning is using v.fc.GetDefaultMetrics()
(GetDefaultMetrics) as the required set but should only check metrics actually
needed by console queries; change the check in the validation that builds
userMetrics from v.fc.Processor.Metrics.IncludeList and compares against
defaults to instead compute the concrete set of console-required metrics (e.g.,
a new function or constant like ConsoleQueryRequiredMetrics) and compare
userMetrics to that set; update the message and keep guidance about using
spec.processor.metrics.additionalIncludeList, appending the warning to
v.warnings only when console-required metrics (not the full defaults) are
missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7190651c-76f7-44b3-a7e0-f58be242d74c

📥 Commits

Reviewing files that changed from the base of the PR and between 6ad9ed9 and 7a3a51c.

📒 Files selected for processing (3)
  • api/flowcollector/v1beta2/flowcollector_alert_types.go
  • api/flowcollector/v1beta2/flowcollector_validation_webhook.go
  • api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go

Comment thread api/flowcollector/v1beta2/flowcollector_validation_webhook_test.go
Add test cases for nil and empty slice includeList scenarios:
- nil includeList: No warning (uses defaults automatically)
- Empty slice includeList: Warning expected (explicitly empty, missing all defaults)

Addresses CodeRabbit review feedback to ensure edge cases are covered.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

openshift-ci-robot commented Apr 8, 2026

@Amoghrd: This pull request references NETOBSERV-2234 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Description

Warning saying that some of the queries run from the console plugin will fail when user does not add some of the default metrics in includeList

Dependencies

#2546

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Summary by CodeRabbit

  • Bug Fixes

  • Consistently filter out metrics tied to disabled features from both default and user-specified metric include lists.

  • Added a validation warning when the console plugin is enabled in Prometheus-only mode and a custom metrics list omits required default metrics.

  • Tests

  • Expanded tests covering console-plugin validation and missing-default scenarios with customized include lists.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@Amoghrd
Copy link
Copy Markdown
Member Author

Amoghrd commented Apr 8, 2026

Rebased with main and updated wrt coderabbit review comment

@Amoghrd Amoghrd added needs-review Tells that the PR needs a review and removed needs-review Tells that the PR needs a review labels Apr 20, 2026
@Amoghrd Amoghrd requested a review from jotak April 23, 2026 14:29
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 23, 2026

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants