Skip to content

feat(metrics): Expose CLF Ready condition as a Prometheus metric#3287

Open
vparfonov wants to merge 1 commit into
openshift:masterfrom
vparfonov:log7718
Open

feat(metrics): Expose CLF Ready condition as a Prometheus metric#3287
vparfonov wants to merge 1 commit into
openshift:masterfrom
vparfonov:log7718

Conversation

@vparfonov
Copy link
Copy Markdown
Contributor

@vparfonov vparfonov commented May 20, 2026

Description

Add log_forwarder_ready gauge metric that surfaces the ClusterLogForwarder Ready condition status (True/False/Unknown) so alerts can detect validation errors.

Example output:

  log_forwarder_ready{resource_name="instance",resource_namespace="openshift-logging",status="True"} 1
  log_forwarder_ready{resource_name="instance",resource_namespace="openshift-logging",status="False"} 0
  log_forwarder_ready{resource_name="instance",resource_namespace="openshift-logging",status="Unknown"} 0

/cc @Clee2691
/assign @jcantrill

Links

Summary by CodeRabbit

  • New Features
    • Added log_forwarder_ready Prometheus metric to monitor log forwarder readiness status.
    • Reports ready, not-ready, and unknown condition states for each forwarder, enabling improved observability of forwarder health across your clusters.

Add log_forwarder_ready gauge metric that surfaces the ClusterLogForwarder
Ready condition status (True/False/Unknown) so alerts can detect validation
errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot requested review from alanconway and cahartma May 20, 2026 10:15
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vparfonov
Once this PR has been reviewed and has the lgtm label, please assign xperimental for approval. 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 May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f136cc35-683a-4926-b2cb-913cd6c08f32

📥 Commits

Reviewing files that changed from the base of the PR and between 1e78ce5 and 37e43d3.

📒 Files selected for processing (3)
  • internal/metrics/telemetry/collector.go
  • internal/metrics/telemetry/collector_test.go
  • internal/metrics/telemetry/telemetry.go

Walkthrough

This PR adds a new log_forwarder_ready Prometheus metric that reports the ready-condition status of ClusterLogForwarder resources. The metric emits gauge values for True, False, and Unknown status variants, with test coverage validating behavior across all three status scenarios.

Changes

Forwarder Ready Metric

Layer / File(s) Summary
Metric descriptor and label constant
internal/metrics/telemetry/telemetry.go
Introduces labelStatus constant and forwarderReadyDesc Prometheus descriptor for the log_forwarder_ready metric, keyed by resource namespace, name, and status.
Collector emission and registration
internal/metrics/telemetry/collector.go
Registers forwarderReadyDesc in Describe, implements metric emission in collectForwarder by iterating over True/False/Unknown status values, and adds readyConditionStatus helper to extract the ready condition's status string from conditions.
Test validation for ready metric
internal/metrics/telemetry/collector_test.go
Updates existing test expectations to include log_forwarder_ready metric output; adds two new test contexts for Ready=False and missing Ready condition scenarios.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

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.
Test Structure And Quality ⚠️ Warning New tests lack meaningful assertion failure messages (e.g., Expect(err).To(BeNil()) without context), violating requirement #4 for diagnostic messages to help identify failures. Add failure messages to all assertions in the new test cases (lines 128-201). For example, replace Expect(err).To(BeNil()) with Expect(err).To(BeNil(), "failed to collect and compare log_forwarder_ready metrics").
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: adding a Prometheus metric that exposes the ClusterLogForwarder Ready condition.
Description check ✅ Passed The description includes all mandatory sections: context and rationale (surfacing CLF Ready condition for alerting), reviewer and approver assignments, and a related JIRA link.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All test names are stable and deterministic. The new tests use static, descriptive titles with no dynamic values, timestamps, UUIDs, or pod names.
Microshift Test Compatibility ✅ Passed The modified test file is a unit test, not an e2e test. It uses fake Kubernetes clients and doesn't interact with a real cluster, so MicroShift compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds unit tests to internal/metrics/telemetry/collector_test.go, not e2e tests. E2E tests require test/e2e location and e2e framework. Custom check applies only to e2e tests.
Topology-Aware Scheduling Compatibility ✅ Passed This PR modifies only metrics collection code, not deployments or scheduling. No topology-aware scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed PR introduces Prometheus metric collection in telemetry package with no process-level stdout writes, fmt.Print calls, or klog configuration changes that would violate OTE stdout contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Tests added are unit tests using fake Kubernetes clients with no IPv4 assumptions or external connectivity requirements, not e2e tests.

✏️ 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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

@vparfonov: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@jcantrill
Copy link
Copy Markdown
Contributor

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 20, 2026
@jcantrill
Copy link
Copy Markdown
Contributor

Placed on hold so we can determine if we can pull this into the release. We are past code-freeze so this likely needs to wait.

The "minimal" servicemonitor profile will need to be updated to always include this metric.

@xperimental please review the metrics impl to see if you have any opinions

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants