I have around 300 servers, and all have different threshold values for CPU that should be alerted on. Please guide how best can be done on Kapacitor Tick script.
Thanks,
I have around 300 servers, and all have different threshold values for CPU that should be alerted on. Please guide how best can be done on Kapacitor Tick script.
Thanks,
@errishma The best way to handle this usecase is with Kapacitor Template Tasks. Instantiate a new template instance for each server.
Thanks Jack.
Does it mean that I will have to define mulitple tick scripts based on template ?
@errishma That means you will need one tick script and one *.json
file for each different instance of that tick script running.
Thanks Jack. I tested the template and it is working. So here is my understanding:
For all the 300 servers there would be 300 json files and one tick script and 300 definitions with different names. Is that correct?
@errishma That is correct. If every server requires special configuration yes.
Thank you Jack.
I see one issue with this approach. Since if I update the tick script and any update in tick script , will ask me to disable all the objects running (JSON) running for this script.
Is there any way I can put the eval expression in JSON file:- So that I need to update the tick script as I need to rename any tag and disable and enable all JSON files.Please guide.
Below is the template:
var measurement string
// Optional where filter
var where_filter = lambda: TRUE
// Optional list of group by dimensions
var groups = [*]
// Which field to process
var field string
// Warning criteria, has access to ‘mean’ field
var warn lambda
// Critical criteria, has access to ‘mean’ field
var crit lambda
// How much data to window
var window = 5m
stream
|from()
.measurement(measurement)
.groupBy(groups)
|eval(lambda: “team”)
.as(‘team1’)
.keep()
.quiet()
|where(where_filter)
|window()
.period(window)
.every(window)
|mean(field).as(‘mean’)
|alert()
.id(’{{ index .Tags “path” }}-{{ index .Tags “host” }}’)
.details(’{{ .ID }} is {{ .Level }} Current average Disk Utilization value past 15m is: {{ index .Fields “mean” }} exceeds threshold of {{ if eq .Level “WARNING” }} 90% with Severity:2 {{ else
if eq .Level “CRITICAL” }} 95% with Severity:1 {{ end }})’)
.warn(warn)
.crit(crit)