-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# File based task/template/handler definition | ||
|
||
This proposal introduces directory based task, template, and handler definition. | ||
|
||
## Configuration | ||
|
||
``` | ||
[load] | ||
enabled = true | ||
hard = false | ||
dir="/path/to/directory" | ||
``` | ||
|
||
`dir` specifies the directory where the definition files exist. | ||
|
||
The specified directory should have three subdirectories `tasks`, `templates`, and `handlers`. | ||
|
||
The `tasks` directory will contain will contain task tickscripts. | ||
|
||
The `templates` directory will contain both template tickscripts and the associated templated task | ||
definition files (either yaml or json). | ||
|
||
The `handlers` directory will contain will contain all topic handler definitions in yaml or json. | ||
|
||
## tickscript (files with a `.tick` extension) | ||
|
||
Tickscripts can be marked up with commented key-value pairs for predefined attributes. | ||
Those attributes may be any of the following | ||
|
||
* `id` - the file name without the tick extension | ||
* `type` - determined by introspection of the task (stream, batch) | ||
* `kind` - task, template. defined using a `set statement` | ||
* `subscriptions` - defined using the `subscribe` keyword followed by a specified subscription | ||
|
||
For example | ||
``` | ||
dbrp "telegraf"."autogen" | ||
var measurement string | ||
var where_filter = lambda: TRUE | ||
var groups = [*] | ||
var field string | ||
var warn lambda | ||
var crit lambda | ||
var window = 5m | ||
var slack_channel = '#alerts' | ||
stream | ||
|from() | ||
.measurement(measurement) | ||
.where(where_filter) | ||
.groupBy(groups) | ||
|window() | ||
.period(window) | ||
.every(window) | ||
|mean(field) | ||
|alert() | ||
.warn(warn) | ||
.crit(crit) | ||
.slack() | ||
.channel(slack_channel) | ||
``` | ||
|
||
or | ||
|
||
``` | ||
dbrp "telegraf"."autogen" | ||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|alert() | ||
.warn(lambda: "usage_idle" < 20) | ||
.crit(lambda: "usage_idle" < 10) | ||
// Send alerts to the `cpu` topic | ||
.topic('cpu') | ||
``` | ||
|
||
### Template Vars | ||
|
||
Template variables may be added as either json or yaml. | ||
|
||
* `id` - filename without the `yaml` or `yml` extension | ||
* `dbrp` - required | ||
* `template` - required | ||
* `vars` - list of template vars | ||
|
||
```yaml | ||
dbrp: | ||
- telegraf.autogen | ||
- telegraf.not_autogen | ||
template: base_template | ||
vars: { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} | ||
``` | ||
|
||
or | ||
|
||
```json | ||
{ | ||
"dbrp": ["telegraf.autogen"], | ||
"template": "base_template", | ||
"vars": { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} | ||
} | ||
``` | ||
|
||
## Handlers | ||
|
||
Topic handlers must specify its associtated topic like so | ||
|
||
``` | ||
topic: cpu | ||
kind: slack | ||
match: changed() == TRUE | ||
options: | ||
channel: '#alerts' | ||
``` | ||
|
||
the name of the file will be used as the handler id. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
topic: cpu | ||
id: example | ||
kind: slack | ||
match: changed() == TRUE | ||
options: | ||
channel: '#alerts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
topic: cpu | ||
id: other | ||
kind: slack | ||
match: changed() == TRUE | ||
options: | ||
channel: '#alerts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dbrp "telegraf"."autogen" | ||
dbrp "telegraf"."autogen_not" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|alert() | ||
.warn(lambda: "usage_idle" < 20) | ||
.crit(lambda: "usage_idle" < 10) | ||
// Send alerts to the `cpu` topic | ||
.topic('cpu') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
|alert() | ||
.crit(lambda: "usage_idle" < 50.0) | ||
//.post('http://localhost:2345') | ||
.post('http://localhost:5555') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: another | ||
template-id: implicit_template | ||
vars: { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: base | ||
dbrps: | ||
- "telegraf.autogen" | ||
template-id: base_template | ||
vars: { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var measurement string | ||
var where_filter = lambda: TRUE | ||
var groups = [*] | ||
var field string | ||
var warn lambda | ||
var crit lambda | ||
var window = 5m | ||
var slack_channel = '#alerts' | ||
|
||
stream | ||
|from() | ||
.measurement(measurement) | ||
.where(where_filter) | ||
.groupBy(groups) | ||
|window() | ||
.period(window) | ||
.every(window) | ||
|mean(field) | ||
|alert() | ||
.warn(warn) | ||
.crit(crit) | ||
.slack() | ||
.channel(slack_channel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: implicit | ||
template-id: implicit_template | ||
vars: { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
dbrp "telegaf"."not_autogen" | ||
|
||
var measurement string | ||
var where_filter = lambda: TRUE | ||
var groups = [*] | ||
var field string | ||
var warn lambda | ||
var crit lambda | ||
var window = 5m | ||
var slack_channel = '#alerts' | ||
|
||
stream | ||
|from() | ||
.measurement(measurement) | ||
.where(where_filter) | ||
.groupBy(groups) | ||
|window() | ||
.period(window) | ||
.every(window) | ||
|mean(field) | ||
|alert() | ||
.warn(warn) | ||
.crit(crit) | ||
.slack() | ||
.channel(slack_channel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"id": "base", | ||
"dbrps": ["telegraf.autogen"], | ||
"template-id": "base_template", | ||
"vars": { | ||
"measurement": {"type" : "string", "value" : "cpu" }, | ||
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"}, | ||
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]}, | ||
"field": {"type" : "string", "value" : "usage_idle" }, | ||
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" }, | ||
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" }, | ||
"window": {"type" : "duration", "value" : "1m" }, | ||
"slack_channel": {"type" : "string", "value" : "#alerts_testing" } | ||
} | ||
} |