From c7d29a8bf92bb46fee9f0c7cc30ca78783cfa7c5 Mon Sep 17 00:00:00 2001 From: Nicholas Valler Date: Sun, 10 Nov 2019 13:06:21 -0800 Subject: [PATCH 1/2] add ViolationCloseTimer field to NrqlAlertCondition type to reflect API updates --- api/types.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/api/types.go b/api/types.go index bc24da10..46c230cb 100644 --- a/api/types.go +++ b/api/types.go @@ -72,17 +72,18 @@ type AlertNrqlQuery struct { // AlertNrqlCondition represents a New Relic NRQL Alert condition. type AlertNrqlCondition struct { - PolicyID int `json:"-"` - ID int `json:"id,omitempty"` - Type string `json:"type,omitempty"` - Name string `json:"name,omitempty"` - Enabled bool `json:"enabled"` - RunbookURL string `json:"runbook_url,omitempty"` - Terms []AlertConditionTerm `json:"terms,omitempty"` - ValueFunction string `json:"value_function,omitempty"` - ExpectedGroups int `json:"expected_groups,omitempty"` - IgnoreOverlap bool `json:"ignore_overlap,omitempty"` - Nrql AlertNrqlQuery `json:"nrql,omitempty"` + PolicyID int `json:"-"` + ID int `json:"id,omitempty"` + Type string `json:"type,omitempty"` + Name string `json:"name,omitempty"` + Enabled bool `json:"enabled"` + RunbookURL string `json:"runbook_url,omitempty"` + Terms []AlertConditionTerm `json:"terms,omitempty"` + ValueFunction string `json:"value_function,omitempty"` + ExpectedGroups int `json:"expected_groups,omitempty"` + IgnoreOverlap bool `json:"ignore_overlap,omitempty"` + Nrql AlertNrqlQuery `json:"nrql,omitempty"` + ViolationCloseTimer int `json:"violation_time_limit_seconds,omitempty"` } // AlertPlugin represents a plugin to use with a Plugin alert condition. From 592d46d39787b2f4c2136eee2e30898fac7eb373 Mon Sep 17 00:00:00 2001 From: Nicholas Valler Date: Mon, 11 Nov 2019 16:16:59 -0800 Subject: [PATCH 2/2] improve NrqlAlertCondition tests with violation_time_limit_seconds --- api/alert_nrql_conditions_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/alert_nrql_conditions_test.go b/api/alert_nrql_conditions_test.go index 731026ee..81dad503 100644 --- a/api/alert_nrql_conditions_test.go +++ b/api/alert_nrql_conditions_test.go @@ -20,6 +20,7 @@ func TestQueryAlertNrqlConditions(t *testing.T) { "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", "enabled": true, + "violation_time_limit_seconds": 3600, "terms": [ { "duration": "10", @@ -65,6 +66,7 @@ func TestGetAlertNrqlCondition(t *testing.T) { "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", "enabled": true, + "violation_time_limit_seconds": 3600, "terms": [ { "duration": "10", @@ -110,6 +112,7 @@ func TestListAlertNrqlConditions(t *testing.T) { "id": 12345, "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ { @@ -155,6 +158,7 @@ func TestCreateAlertNrqlCondition(t *testing.T) { "id": 12345, "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ { @@ -235,6 +239,7 @@ func TestCreateAlertNrqlStaticCondition(t *testing.T) { "type": "static", "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ { @@ -319,6 +324,7 @@ func TestCreateAlertNrqlBaselineCondition(t *testing.T) { "type": "baseline", "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ { @@ -409,6 +415,7 @@ func TestCreateAlertNrqlOutlierCondition(t *testing.T) { "type": "outlier", "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ { @@ -493,6 +500,7 @@ func TestUpdateAlertNrqlCondition(t *testing.T) { "id": 12345, "name": "NRQL Condition", "runbook_url": "https://example.com/runbook.md", + "violation_time_limit_seconds": 3600, "enabled": true, "terms": [ {