Skip to content

Conversation

@z0nker
Copy link

@z0nker z0nker commented Aug 20, 2025

There are no interval, scrapeTimeout, relabelings and metricRelabelings fields in ServiceMonitor spec so I get an error when try to apply this CRD. At least I got such error in my ArgoCD setup:

Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error running server side apply in dryrun mode for resource ServiceMonitor/signoz-clickhouse-operator-metrics: failed to create typed patch object (monitoring/signoz-clickhouse-operator-metrics; monitoring.coreos.com/v1, Kind=ServiceMonitor): .spec.interval: field not declared in schema

To fix this just move the specified fields to Endpoint

Summary by CodeRabbit

  • Bug Fixes
    • Scrape interval and timeout are now applied at the endpoint level for the ClickHouse Operator.
    • Endpoint-level relabelings and metricRelabelings are now honored when provided.
    • These fields are included only when configured; interval/scrapeTimeout are rendered as strings to ensure valid specs and correct Prometheus scraping.

@z0nker z0nker requested a review from a team as a code owner August 20, 2025 11:25
@coderabbitai
Copy link

coderabbitai bot commented Aug 20, 2025

Walkthrough

Move ServiceMonitor fields (interval, scrapeTimeout, relabelings, metricRelabelings) from the top-level spec into the first endpoints entry in charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml, rendering each field conditionally with Go template with blocks and quoting interval/scrapeTimeout.

Changes

Cohort / File(s) Summary
ServiceMonitor endpoint field relocation
charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml
Removed top-level spec entries for interval, scrapeTimeout, relabelings, and metricRelabelings; added them inside the first endpoints item, each gated by {{- with .Values.clickhouseOperator.serviceMonitor.<field> }}. interval and scrapeTimeout are rendered as quoted strings; relabelings and metricRelabelings use toYaml with increased indentation (nindent 8). Other fields unchanged.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Values as Values YAML
    participant Helm as Helm template
    participant SM as ServiceMonitor manifest

    Note over Values,Helm: Helm rendering
    Values->>Helm: provide .Values.clickhouseOperator.serviceMonitor.{interval,scrapeTimeout,relabelings,metricRelabelings}
    alt value present
        Helm->>SM: inject field into endpoints[0] (quoted interval/scrapeTimeout, YAML relabelings/metricRelabelings)
    else value absent
        Helm->>SM: omit field
    end
    Note right of SM: Resulting ServiceMonitor has endpoint-scoped fields
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit nests in Helm's warm light,
Shifting fields to endpoints, tidy and right.
Quoted carrots and YAML leaves in a row,
Appear when set — otherwise they go.
Metrics hum softly where the burrows grow. 🥕🐰

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 09300b4 and f76202b.

📒 Files selected for processing (1)
  • charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🧹 Nitpick comments (2)
charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (2)

18-20: Quote the duration to enforce string type

Quoting avoids accidental numeric typing if users set an integer in values.yaml (e.g., 30) and keeps the field a string as expected by the CRD.

Apply this diff:

-      interval: {{ . }}
+      interval: "{{ . }}"

24-26: scrapeTimeout likely belongs under endpoints; please verify against the CRD

In recent Prometheus Operator versions, scrapeTimeout is an endpoint-level field (like interval). Top-level spec.scrapeTimeout may be ignored or rejected. Consider moving it under the endpoint for consistency.

Apply this diff to remove the top-level field:

-  {{- with .Values.clickhouseOperator.serviceMonitor.scrapeTimeout }}
-  scrapeTimeout: {{ . }}
-  {{- end }}

Then add this block alongside the endpoint keys (right next to interval):

      {{- with .Values.clickhouseOperator.serviceMonitor.scrapeTimeout }}
      scrapeTimeout: "{{ . }}"
      {{- end }}

If you want, I can open a follow-up PR to make this migration consistently across charts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6357892 and cee4621.

📒 Files selected for processing (1)
  • charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (1 hunks)
🔇 Additional comments (2)
charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (2)

18-20: Relocating interval to endpoint is correct and fixes the CRD validation error

Endpoint-level interval is the valid field in ServiceMonitor. This change aligns with the Prometheus Operator API and should resolve the apply-time error.


27-34: Confirm whether relabelings and metricRelabelings are intended at spec-level

These are commonly endpoint-level fields in ServiceMonitor. Some charts keep them top-level for historical reasons, but CRD validation may expect them under endpoints. Please verify against your operator version.

Would you like me to prepare a patch that moves these under endpoints while preserving current values behavior?

@z0nker z0nker changed the title fix: move interval field to endpoints in serviceMonitor definition fix: move Endpoint fields to the correct level in serviceMonitor definition Aug 20, 2025
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cee4621 and a6fdef9.

📒 Files selected for processing (1)
  • charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (1 hunks)
🔇 Additional comments (1)
charts/clickhouse/templates/clickhouse-operator/servicemonitor.yaml (1)

18-23: Correctly relocated interval and scrapeTimeout to endpoint scope

Moving these fields under the endpoint aligns with the Prometheus Operator ServiceMonitor schema. The conditional rendering with with blocks is appropriate.

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.

1 participant