Description
Hi, im trying to send alerts to a google chat room using a webhook URL generated for the chatroom using HTTP/Post since kapacitor does not natively support Google Hangouts as an endpoint handler like grafana does. I am not able to get anything across, if someone has a clue or has had to deal with a similar situation, i would appreciate feedback. Also, maybe you guys could look into implementing Google chats as a handler in chronograf like grafana, thanks !
Here is the TICKScript:
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'mem'
var groupBy = []
var whereFilter = lambda: ("host" == 'Proxmox')
var name = 'Memory Alert'
var idVar = name
var message = ' {{.ID}} is {{.Level}} value: {{ index .Fields "value" }}'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 1
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "used")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.post('https://chat.googleapis.com/v1/spaces/AAAAi4UyLxA/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=2uf24LgaUpWc5esVflh52DzwGTbYjZdRTzuWMz-rhRE%3D')
.header('Content-Type', 'application/json')
trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')