Skip to content

feat(alerts): add support for cci polling frequency field in conditions#2890

Open
gffuentes wants to merge 3 commits intomainfrom
cci-polling-frequency
Open

feat(alerts): add support for cci polling frequency field in conditions#2890
gffuentes wants to merge 3 commits intomainfrom
cci-polling-frequency

Conversation

@gffuentes
Copy link
Contributor

@gffuentes gffuentes commented Jun 6, 2025

DO NOT MERGE YET

Description

Adds support for polling frequency - a new field on conditions that is part of CCI project

newrelic/newrelic-client-go#1303

Fixes # https://new-relic.atlassian.net/browse/NR-413526

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

Please delete options that are not relevant.

  • My commit message follows conventional commits
  • My code is formatted to Go standards
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes. Go here for instructions on running tests locally.

How to test this change?

The feature is has relevant FF on for 100% in staging.

Test by trying to create a condition with the new field - HAS TO BE A CCI CONDITION. example below:

resource "newrelic_nrql_alert_condition" "static_polling_freq_condition" {
	policy_id                    = 1514915
	name                         = "Condition for polling frequency test"
	type                         = "static"
	enabled                      = false
	violation_time_limit_seconds = 3600
	aggregation_delay            = 2
	aggregation_window           = 3600
	aggregation_method           = "event_flow"
	evaluation_delay             = 60
	polling_frequency            = 3600
	nrql {
		query = "SELECT count(*) FROM CloudCost"
	}
	critical {
		operator              = "above"
		threshold             = 1
		threshold_duration    = 3600
		threshold_occurrences = "ALL"
	}
}

@gffuentes gffuentes force-pushed the cci-polling-frequency branch 3 times, most recently from c970f85 to 29443ea Compare June 11, 2025 17:56
@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2025

Codecov Report

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

Project coverage is 30.54%. Comparing base (ad8acab) to head (4f66902).

Files with missing lines Patch % Lines
...wrelic/structures_newrelic_nrql_alert_condition.go 33.33% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2890   +/-   ##
=======================================
  Coverage   30.54%   30.54%           
=======================================
  Files         104      104           
  Lines       28704    28716   +12     
=======================================
+ Hits         8768     8772    +4     
- Misses      19759    19766    +7     
- Partials      177      178    +1     

☔ 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.

@gffuentes gffuentes force-pushed the cci-polling-frequency branch 2 times, most recently from 63d0900 to d504348 Compare June 11, 2025 19:51
@gffuentes gffuentes force-pushed the cci-polling-frequency branch from d504348 to 4556ae7 Compare June 13, 2025 19:31
@gffuentes gffuentes requested a review from akane0915 June 16, 2025 19:39
@gffuentes gffuentes force-pushed the cci-polling-frequency branch 2 times, most recently from 8ef418e to de6e476 Compare June 16, 2025 21:16
@gffuentes gffuentes force-pushed the cci-polling-frequency branch from de6e476 to 4f66902 Compare June 17, 2025 00:29
- `evaluation_delay` - (Optional) How long we wait until the signal starts evaluating. The maximum delay is 7200 seconds (120 minutes).
- `slide_by` - (Optional) Gathers data in overlapping time windows to smooth the chart line, making it easier to spot trends. The `slide_by` value is specified in seconds and must be smaller than and a factor of the `aggregation_window`.
- `signal_seasonality` - (Optional) Seasonality under which a condition's signal(s) are evaluated. Only available for baseline conditions. Valid values are: `NEW_RELIC_CALCULATION`, `HOURLY`, `DAILY`, `WEEKLY`, or `NONE`. To have New Relic calculate seasonality automatically, set to `NEW_RELIC_CALCULATION`. To turn off seasonality completely, set to `NONE`.
- `polling_frequency` - (Optional) The frequency at which the NRQL will be executed and the results will be evaluated, in seconds. Polling cannot happen more frequently than 3600 seconds (1 hour), and must be specified in whole hour increments. Example: Frequency may be 3600 seconds (1 hour), but not 5400 seconds (1.5 hours). Polling cannot happen less frequently than the duration of the warning term, critical term, or 24 hours, whichever is shortest. Example: If the warning term duration is 2 days and the critical term duration is 3 days, the polling must be no less frequent than once every 86400 seconds (24 hours). Example: If the warning term duration is 6 hours and the critical term duration is 12 hours, the polling must be no less frequent than once every 21600 seconds (6 hours). Default polling frequency will be 3600 seconds (1 hour). Only valid for NRQL conditions with CloudCost, KubernetesCost, or CloudCostEstimate event types. Conditions for these event types are evaluated in a polling fashion.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- `polling_frequency` - (Optional) The frequency at which the NRQL will be executed and the results will be evaluated, in seconds. Polling cannot happen more frequently than 3600 seconds (1 hour), and must be specified in whole hour increments. Example: Frequency may be 3600 seconds (1 hour), but not 5400 seconds (1.5 hours). Polling cannot happen less frequently than the duration of the warning term, critical term, or 24 hours, whichever is shortest. Example: If the warning term duration is 2 days and the critical term duration is 3 days, the polling must be no less frequent than once every 86400 seconds (24 hours). Example: If the warning term duration is 6 hours and the critical term duration is 12 hours, the polling must be no less frequent than once every 21600 seconds (6 hours). Default polling frequency will be 3600 seconds (1 hour). Only valid for NRQL conditions with CloudCost, KubernetesCost, or CloudCostEstimate event types. Conditions for these event types are evaluated in a polling fashion.
- `polling_frequency` - (Optional) The frequency, in seconds, at which the NRQL will be executed and results evaluated. When using `polling_frequency`, consider these important points:
- Default polling frequency is 3600 seconds (1 hour).
- Polling cannot happen more frequently than 3600 seconds (1 hour), and must be specified in whole hour increments. For example, you can set `polling_frequency` to 3600 seconds (1 hour), but not 5400 seconds (1.5 hours).
- Polling cannot happen less frequently than the duration of the warning term, critical term, or 24 hours, whichever is shortest. For instance:
- If the warning term duration is 2 days and the critical term duration is 3 days, polling must be no less frequent than once every 86400 seconds (24 hours).
- If the warning term duration is 6 hours and the critical term duration is 12 hours, polling must be no less frequent than once every 21600 seconds (6 hours).
- `polling_frequency` is only valid for NRQL conditions with CloudCost, KubernetesCost, or CloudCostEstimate event types. Conditions for these event types are evaluated in a polling fashion.

Optimized the text to make it visually clear :) please consider this change.

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.

4 participants

Comments