indent sample config text, nuke verbose logging statement
This commit is contained in:
parent
7f3eccfc83
commit
6df384d02b
|
@ -30,7 +30,7 @@ type PD struct {
|
||||||
Metric string `toml:"metric"`
|
Metric string `toml:"metric"`
|
||||||
Field string `toml:"field"`
|
Field string `toml:"field"`
|
||||||
Expression string `toml:"expression"`
|
Expression string `toml:"expression"`
|
||||||
Tags map[string]string `toml:"tags"`
|
TagFilter map[string]string `toml:"tag_filter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
|
@ -42,6 +42,11 @@ metric = "cpu"
|
||||||
description = "Check CPU"
|
description = "Check CPU"
|
||||||
## Name of the metric field which will be used to check
|
## Name of the metric field which will be used to check
|
||||||
field = "time_iowait"
|
field = "time_iowait"
|
||||||
|
## Tag filter, when present only metrics with the specified tag value
|
||||||
|
## will be considered for further processing
|
||||||
|
tag_filter:
|
||||||
|
role: web-server
|
||||||
|
region: us-west1
|
||||||
## Expression is used to evaluate the alert
|
## Expression is used to evaluate the alert
|
||||||
expression = "> 50.0"
|
expression = "> 50.0"
|
||||||
`
|
`
|
||||||
|
@ -76,7 +81,7 @@ func (p *PD) Match(metric telegraf.Metric) bool {
|
||||||
log.Printf("Metric name is not matched. Expected: '%s' Found: '%s'", p.Metric, metric.Name())
|
log.Printf("Metric name is not matched. Expected: '%s' Found: '%s'", p.Metric, metric.Name())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for k, v := range p.Tags {
|
for k, v := range p.TagFilter {
|
||||||
t, ok := metric.Tags()[k]
|
t, ok := metric.Tags()[k]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("Tag value absent. Tag name: '%s'", k)
|
log.Printf("Tag value absent. Tag name: '%s'", k)
|
||||||
|
@ -122,7 +127,6 @@ func (p *PD) Write(metrics []telegraf.Metric) error {
|
||||||
}
|
}
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
if !p.Match(metric) {
|
if !p.Match(metric) {
|
||||||
log.Println("Metric is not matched by threshold, skipping")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
|
@ -135,7 +139,6 @@ func (p *PD) Write(metrics []telegraf.Metric) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Println("Created PagerDuty event for metric: ", metric.Name())
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue