Documentation ¶
Index ¶
- Constants
- Variables
- func AlertServices(rule chronograf.AlertRule) (string, error)
- func Data(rule chronograf.AlertRule) (string, error)
- func Escape(str string) string
- func HTTPOut(rule chronograf.AlertRule) (string, error)
- func HrefOutput(ID string) string
- func InfluxOut(rule chronograf.AlertRule) (string, error)
- func MarshalTICK(script string) ([]byte, error)
- func Reverse(script chronograf.TICKScript) (chronograf.AlertRule, error)
- func Trigger(rule chronograf.AlertRule) (string, error)
- func UnmarshalTICK(octets []byte) (string, error)
- func ValidateAlert(service string) error
- func Vars(rule chronograf.AlertRule) (string, error)
- type Alert
- type Client
- func (c *Client) All(ctx context.Context) (map[string]*Task, error)
- func (c *Client) Create(ctx context.Context, rule chronograf.AlertRule) (*Task, error)
- func (c *Client) Delete(ctx context.Context, href string) error
- func (c *Client) Disable(ctx context.Context, href string) (*Task, error)
- func (c *Client) Enable(ctx context.Context, href string) (*Task, error)
- func (c *Client) Get(ctx context.Context, id string) (*Task, error)
- func (c *Client) Href(ID string) string
- func (c *Client) HrefOutput(ID string) string
- func (c *Client) Reverse(id string, script chronograf.TICKScript) chronograf.AlertRule
- func (c *Client) Status(ctx context.Context, href string) (string, error)
- func (c *Client) Update(ctx context.Context, href string, rule chronograf.AlertRule) (*Task, error)
- type CommonVars
- type CritCondition
- type DeadmanVars
- type Error
- type FieldFunc
- type KapaClient
- type NotEmpty
- type PaginatingKapaClient
- type RangeVars
- type RelativeVars
- type Task
- type ThresholdVars
- type WhereFilter
Constants ¶
const ( // Prefix is prepended to the ID of all alerts Prefix = "chronograf-v1-" // FetchRate is the rate Paginating Kapacitor Clients will consume responses FetchRate = 100 )
const ( // ListTaskWorkers describes the number of workers concurrently fetching // tasks from Kapacitor. This constant was chosen after some benchmarking // work and should likely work well for quad-core systems ListTaskWorkers = 4 // TaskGatherers is the number of workers collating responses from // ListTaskWorkers. There can only be one without additional synchronization // around the output buffer from ListTasks TaskGatherers = 1 )
const ( // Deadman triggers when data is missing for a period of time Deadman = "deadman" // Relative triggers when the value has changed compared to the past Relative = "relative" // Threshold triggers when value crosses a threshold Threshold = "threshold" // ThresholdRange triggers when a value is inside or outside a range ThresholdRange = "range" // ChangePercent triggers a relative alert when value changed by a percentage ChangePercent = "% change" // ChangeAmount triggers a relative alert when the value change by some amount ChangeAmount = "change" )
const ErrNotChronoTickscript = Error("TICKscript not built with chronograf builder")
ErrNotChronoTickscript signals a TICKscript that cannot be parsed into chronograf data structure.
const HTTPEndpoint = "output"
HTTPEndpoint is the default location of the tickscript output
Variables ¶
var ( // Database is the output database for alerts. Database = "chronograf" // RP will be autogen for alerts because it is default. RP = "autogen" // Measurement will be alerts so that the app knows where to get this data. Measurement = "alerts" // IDTag is the output tag key for the ID of the alert IDTag = "alertID" //LevelTag is the output tag key for the alert level information LevelTag = "level" // MessageField is the output field key for the message in the alert MessageField = "message" // DurationField is the output field key for the duration of the alert DurationField = "duration" )
var AllAlerts = `` /* 131-byte string literal not displayed */
AllAlerts are properties all alert types will have
var DeadmanTrigger = `
var trigger = data|deadman(threshold, period)
`
DeadmanTrigger checks if any data has been streamed in the last period of time
var Details = `
.details(details)
`
Details is used only for alerts that specify detail string
var RelativeAbsoluteTrigger = `` /* 244-byte string literal not displayed */
RelativeAbsoluteTrigger compares one window of data versus another (current - past)
var RelativePercentTrigger = `` /* 277-byte string literal not displayed */
RelativePercentTrigger compares one window of data versus another as a percent change.
var ThresholdRangeTrigger = `
var trigger = data
|alert()
.crit(lambda: "value" %s lower %s "value" %s upper)
`
ThresholdRangeTrigger is the alert when data does not intersect the range.
var ThresholdTrigger = `
var trigger = data
|alert()
.crit(lambda: "value" %s crit)
`
ThresholdTrigger is the tickscript trigger for alerts that exceed a value
Functions ¶
func AlertServices ¶
func AlertServices(rule chronograf.AlertRule) (string, error)
AlertServices generates alert chaining methods to be attached to an alert from all rule Services
func Data ¶
func Data(rule chronograf.AlertRule) (string, error)
Data returns the tickscript data section for querying
func HTTPOut ¶
func HTTPOut(rule chronograf.AlertRule) (string, error)
HTTPOut adds a kapacitor httpOutput to a tickscript
func HrefOutput ¶
HrefOutput returns the link to a kapacitor task httpOut Node given an id
func InfluxOut ¶
func InfluxOut(rule chronograf.AlertRule) (string, error)
InfluxOut creates a kapacitor influxDBOut node to write alert data to Database, RP, Measurement.
func MarshalTICK ¶
MarshalTICK converts tickscript to JSON representation
func Reverse ¶
func Reverse(script chronograf.TICKScript) (chronograf.AlertRule, error)
Reverse converts tickscript to an AlertRule
func Trigger ¶
func Trigger(rule chronograf.AlertRule) (string, error)
Trigger returns the trigger mechanism for a tickscript
func UnmarshalTICK ¶
UnmarshalTICK converts JSON to tickscript
func ValidateAlert ¶
ValidateAlert checks if the alert is a valid kapacitor alert service.
Types ¶
type Alert ¶
type Alert struct{}
Alert defines alerting strings in template rendering
func (*Alert) Generate ¶
func (a *Alert) Generate(rule chronograf.AlertRule) (chronograf.TICKScript, error)
Generate creates a Tickscript from the alertrule
type Client ¶
type Client struct { URL string Username string Password string InsecureSkipVerify bool ID chronograf.ID Ticker chronograf.Ticker // contains filtered or unexported fields }
Client communicates to kapacitor
func (*Client) HrefOutput ¶
HrefOutput returns the link to a kapacitor task httpOut Node given an id
func (*Client) Reverse ¶
func (c *Client) Reverse(id string, script chronograf.TICKScript) chronograf.AlertRule
Reverse builds a chronograf.AlertRule and its QueryConfig from a tickscript
type CommonVars ¶
type CommonVars struct { DB string RP string Measurement string Name string Message string TriggerType string GroupBy []string Filter WhereFilter Period string Every string Detail string }
CommonVars includes all the variables of a chronograf TICKScript
type CritCondition ¶
type CritCondition struct {
Operators []string
}
CritCondition represents the operators that determine when the alert should go critical
type Error ¶
type Error string
Error are kapacitor errors due to communication or processing of TICKscript to kapacitor
type FieldFunc ¶
FieldFunc represents the field used as the alert value and its optional aggregate function
type KapaClient ¶
type KapaClient interface { CreateTask(opt client.CreateTaskOptions) (client.Task, error) Task(link client.Link, opt *client.TaskOptions) (client.Task, error) ListTasks(opt *client.ListTasksOptions) ([]client.Task, error) UpdateTask(link client.Link, opt client.UpdateTaskOptions) (client.Task, error) DeleteTask(link client.Link) error }
KapaClient represents a connection to a kapacitor instance
func NewKapaClient ¶
func NewKapaClient(url, username, password string, insecureSkipVerify bool) (KapaClient, error)
NewKapaClient creates a Kapacitor client connection
type NotEmpty ¶
type NotEmpty struct {
Err error
}
NotEmpty is an error collector checking if strings are empty values
type PaginatingKapaClient ¶
type PaginatingKapaClient struct { KapaClient FetchRate int // specifies the number of elements to fetch from Kapacitor at a time }
PaginatingKapaClient is a Kapacitor client that automatically navigates through Kapacitor's pagination to fetch all results
func (*PaginatingKapaClient) ListTasks ¶
func (p *PaginatingKapaClient) ListTasks(opts *client.ListTasksOptions) ([]client.Task, error)
ListTasks lists all available tasks from Kapacitor, navigating pagination as it fetches them
type RelativeVars ¶
RelativeVars represents the critical range and time in the past an alert occurs
type Task ¶
type Task struct { ID string // Kapacitor ID Href string // Kapacitor relative URI HrefOutput string // Kapacitor relative URI to HTTPOutNode Rule chronograf.AlertRule // Rule is the rule that represents this Task TICKScript chronograf.TICKScript // TICKScript is the running script }
Task represents a running kapacitor task
type ThresholdVars ¶
type ThresholdVars struct {
Crit string
}
ThresholdVars represents the critical value where an alert occurs
type WhereFilter ¶
type WhereFilter struct { TagValues map[string][]string // Tags are filtered by an array of values Operator string // Operator is == or != }
WhereFilter filters the stream data in a TICKScript