From 926dfae5c8ad2612c3e4cd8884666b671269f478 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 22:18:23 -0600 Subject: [PATCH] Add kapacitor alert node structs --- chronograf.go | 33 ++++++++++++++++++++++++--------- server/swagger.json | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/chronograf.go b/chronograf.go index b3c3e1c1ea..309ef998e9 100644 --- a/chronograf.go +++ b/chronograf.go @@ -104,15 +104,16 @@ type SourcesStore interface { // AlertRule represents rules for building a tickscript alerting task type AlertRule struct { - ID string `json:"id,omitempty"` // ID is the unique ID of the alert - Query QueryConfig `json:"query"` // Query is the filter of data for the alert. - Every string `json:"every"` // Every how often to check for the alerting criteria - Alerts []string `json:"alerts"` // AlertServices name all the services to notify (e.g. pagerduty) - Message string `json:"message"` // Message included with alert - Details string `json:"details"` // Details is generally used for the Email alert. If empty will not be added. - Trigger string `json:"trigger"` // Trigger is a type that defines when to trigger the alert - TriggerValues TriggerValues `json:"values"` // Defines the values that cause the alert to trigger - Name string `json:"name"` // Name is the user-defined name for the alert + ID string `json:"id,omitempty"` // ID is the unique ID of the alert + Query QueryConfig `json:"query"` // Query is the filter of data for the alert. + Every string `json:"every"` // Every how often to check for the alerting criteria + Alerts []string `json:"alerts"` // Alerts name all the services to notify (e.g. pagerduty) + AlertNodes []KapacitorNode `json:"alertNodes"` // AlertNodes define additional arguments to alerts + Message string `json:"message"` // Message included with alert + Details string `json:"details"` // Details is generally used for the Email alert. If empty will not be added. + Trigger string `json:"trigger"` // Trigger is a type that defines when to trigger the alert + TriggerValues TriggerValues `json:"values"` // Defines the values that cause the alert to trigger + Name string `json:"name"` // Name is the user-defined name for the alert } // AlertRulesStore stores rules for building tickscript alerting tasks @@ -173,6 +174,20 @@ type QueryConfig struct { RawText string `json:"rawText,omitempty"` } +// KapacitorNode adds arguments and properties to an alert +type KapacitorNode struct { + Name string `json:"name"` + Args []string `json:"args"` + Properties []*KapacitorProperty `json:"properties"` + // In the future we could add chaining methods here. +} + +// KapacitorProperty modifies the node they are called on +type KapacitorProperty struct { + Name string `json:"name"` + Args []string `json:"args"` +} + // Server represents a proxy connection to an HTTP server type Server struct { ID int // ID is the unique ID of the server diff --git a/server/swagger.json b/server/swagger.json index 309b10e535..37d4b8fec7 100644 --- a/server/swagger.json +++ b/server/swagger.json @@ -1714,6 +1714,8 @@ "items": { "type": "string", "enum": [ + "post", + "tcp", "hipchat", "opsgenie", "pagerduty",