diff --git a/pkg/alerts/nrql_conditions.go b/pkg/alerts/nrql_conditions.go index 772c3fff6..9fe78497d 100644 --- a/pkg/alerts/nrql_conditions.go +++ b/pkg/alerts/nrql_conditions.go @@ -246,6 +246,7 @@ type NrqlConditionBase struct { Expiration *AlertsNrqlConditionExpiration `json:"expiration,omitempty"` Signal *AlertsNrqlConditionSignal `json:"signal,omitempty"` EntityGUID common.EntityGUID `json:"entityGuid,omitempty"` + TitleTemplate *string `json:"titleTemplate,omitempty"` } // NrqlConditionCreateBase represents the base fields for creating a New Relic NRQL Alert condition. @@ -261,6 +262,7 @@ type NrqlConditionCreateBase struct { ViolationTimeLimitSeconds int `json:"violationTimeLimitSeconds,omitempty"` Expiration *AlertsNrqlConditionExpiration `json:"expiration,omitempty"` Signal *AlertsNrqlConditionCreateSignal `json:"signal,omitempty"` + TitleTemplate *string `json:"titleTemplate,omitempty"` } // NrqlConditionUpdateBase represents the base fields for updating a New Relic NRQL Alert condition. @@ -276,6 +278,7 @@ type NrqlConditionUpdateBase struct { ViolationTimeLimitSeconds int `json:"violationTimeLimitSeconds,omitempty"` Expiration *AlertsNrqlConditionExpiration `json:"expiration,omitempty"` Signal *AlertsNrqlConditionUpdateSignal `json:"signal"` + TitleTemplate *string `json:"titleTemplate"` } // NrqlConditionCreateInput represents the input options for creating a Nrql Condition. @@ -325,6 +328,7 @@ type NrqlCondition struct { Terms []ConditionTerm `json:"terms,omitempty"` Type string `json:"type,omitempty"` EntityGUID *common.EntityGUID `json:"entity_guid,omitempty"` + TitleTemplate *string `json:"titleTemplate,omitempty"` } // NrqlQuery represents a NRQL query to use with a NRQL alert condition @@ -719,6 +723,7 @@ const ( enabled entityGuid description + titleTemplate policyId runbookUrl terms { @@ -737,7 +742,7 @@ const ( openViolationOnExpiration } signal { - aggregationWindow + aggregationWindow evaluationOffset evaluationDelay fillOption diff --git a/pkg/alerts/nrql_conditions_integration_test.go b/pkg/alerts/nrql_conditions_integration_test.go index a84ff1190..89b7d9f35 100644 --- a/pkg/alerts/nrql_conditions_integration_test.go +++ b/pkg/alerts/nrql_conditions_integration_test.go @@ -27,6 +27,7 @@ var ( nrqlConditionBaseAggTimer = 5 // needed for setting pointer nrqlConditionBaseSlideBy = 30 // needed for setting pointer nrqlConditionEvaluationDelay = 60 // needed for setting pointer + nrqlConditionTitleTemplate = "Title {{ createdAt }}" // needed for setting pointer nrqlConditionCreateBase = NrqlConditionCreateBase{ Description: "test description", Enabled: true, @@ -35,7 +36,8 @@ var ( Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", EvaluationOffset: &nrqlConditionBaseEvalOffset, }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -68,7 +70,8 @@ var ( Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", EvaluationOffset: &nrqlConditionBaseEvalOffset, }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -100,7 +103,8 @@ var ( Nrql: NrqlConditionCreateQuery{ Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -133,7 +137,8 @@ var ( Nrql: NrqlConditionUpdateQuery{ Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -166,7 +171,8 @@ var ( Nrql: NrqlConditionCreateQuery{ Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App' FACET OtherStuff", }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -200,7 +206,8 @@ var ( Nrql: NrqlConditionUpdateQuery{ Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -455,7 +462,8 @@ func TestIntegrationNrqlConditions_Search(t *testing.T) { Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", EvaluationOffset: &nrqlConditionBaseEvalOffset, }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &thresholdCritical, @@ -522,7 +530,8 @@ func TestIntegrationNrqlConditions_CreateStatic(t *testing.T) { Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", EvaluationOffset: &nrqlConditionBaseEvalOffset, }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThreshold, @@ -587,7 +596,8 @@ func TestIntegrationNrqlConditions_ZeroValueThreshold(t *testing.T) { Query: "SELECT rate(sum(apm.service.cpu.usertime.utilization), 1 second) * 100 as cpuUsage FROM Metric WHERE appName like 'Dummy App'", EvaluationOffset: &nrqlConditionBaseEvalOffset, }, - RunbookURL: "test.com", + RunbookURL: "test.com", + TitleTemplate: &nrqlConditionTitleTemplate, Terms: []NrqlConditionTerm{ { Threshold: &nrqlConditionBaseThresholdZeroValue,