Skip to content

Default Grafana alert RuleQuery interval to 30s#2229

Open
cawthorne wants to merge 2 commits into
mainfrom
fix/grafana-alert-rule-query-interval
Open

Default Grafana alert RuleQuery interval to 30s#2229
cawthorne wants to merge 2 commits into
mainfrom
fix/grafana-alert-rule-query-interval

Conversation

@cawthorne

Copy link
Copy Markdown
Contributor

Summary

  • Add RuleQuery.Interval to observability-lib with a default of "30s".
  • Set interval on Prometheus datasource query models (refId A) in newRuleQuery, so deployed Grafana alert rules no longer show 1s on the datasource step.
  • Reuse a shared defaultRuleQueryIntervalMs constant for condition query defaults.
  • Add TestNewAlertRule_DefaultRuleQueryInterval.

Companion to chainlink-observability#467, which sets rule group evaluation intervals and condition intervalMs in chainlink-observability. This PR covers the remaining alert rule model layer: the Prometheus query step (refId A).

Coverage

Layer Owner
Rule group evaluation (Evaluate every) chainlink-observability #467
Condition step intervalMs (B/C) observability-lib + chainlink-observability #467
Datasource query model interval (ref A) This PR

Test plan

  • go test ./observability-lib/grafana/...
  • After merge: bump observability-lib in chainlink-observability and verify ref A shows "interval": "30s" in generated alert JSON

Sets interval on Prometheus datasource query models (refId A) so deployed
alert rules no longer default to 1s evaluation in Grafana UI.
Copilot AI review requested due to automatic review settings July 7, 2026 16:44
@cawthorne cawthorne requested a review from a team as a code owner July 7, 2026 16:44
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

👋 cawthorne, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common/observability-lib

✅ Compatible Changes (2)

grafana (1)
  • DefaultRuleQueryInterval — ➕ Added
grafana.RuleQuery (1)
  • Interval — ➕ Added

📄 View full apidiff report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a default Prometheus query interval for Grafana alert rule query models to avoid generated rules showing a 1s datasource step by default, aligning the alert rule “refId A” query step with the intended 30s evaluation cadence.

Changes:

  • Introduces RuleQuery.Interval with a default of "30s" and applies it in newRuleQuery for Prometheus datasource query models (refId A).
  • Reuses a shared defaultRuleQueryIntervalMs constant for condition query intervalMs defaults.
  • Adds a unit test validating the default interval is set on the Prometheus query model.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
observability-lib/grafana/alerts.go Adds default rule query interval support and reuses a shared interval constant for condition query defaults.
observability-lib/grafana/builder_test.go Adds coverage to ensure the Prometheus query model interval defaults to "30s".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread observability-lib/grafana/alerts.go
Addresses review feedback to avoid drift between the Prometheus query
interval string and condition step intervalMs defaults.
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.

2 participants