The LogStash query functions are deprecated, and only for use with v1.x of ElasticSearch. If you are running v2 or above of ElasticSearch, then you should refer to the Elastic Query functions.
lscount
returns a time bucketed count of matching documents in the LogStash index, according to the specified filter.
A trivial use of this would be to check how many documents in total have been received in the 5 minutes, and alert if it is below a certain threshold.
A Bosun alert for this might look like:
alert logstash.docs {
$notes = This alerts if there hasn't been any logstash documents in the past 5 minutes
template = logstash.docs
$count_by_minute = lscount("logstash", "", "", "5m", "5m", "")
$count_graph = lscount("logstash", "", "", "1m", "60m", "")
$q = avg($count_by_minute)
crit = $q < 1
critNotification = default
}
template logstash.docs {
body = `{{template "header" .}}
{{.Graph .Alert.Vars.count_graph }}
{{template "def" .}}
{{template "computation" .}}`
subject = {{.Last.Status}}: Logstash docs per second: {{.Eval .Alert.Vars.q | printf "%.2f"}} in the past 5 minutes
}
This has two instances of lscount:
logstash
indexParameter | Details |
---|---|
indexRoot | The root name of the index to hit, the format is expected to be fmt.Sprintf("%s-%s", index_root, d.Format("2006.01.02")) |
keyString | Creates groups (like tagsets) and can also filter those groups. It is the format of "field:regex,field:regex..." . The :regex can be ommited. |
filterString | An Elastic regexp query that can be applied to any field. It is in the same format as the keystring argument. |
bucketDuration | The same format is an opentsdb duration, and is the size of buckets returned (i.e. counts for every 10 minutes) |
startDuration | set the time window from now - see the OpenTSDB q() function for more details. |
endDuration | set the time window from now - see the OpenTSDB q() function for more details. |