-- @interval 30s
-- @name goroutines
local prom1 = require('datasource.prometheus.prom1')
local alert = require('alert')
local chart = require('chart')
local storage = require('storage.s3.dev')
local now = os.time(os.date("!*t"))
rangeOptions = {
['start'] = now - 86400,
['end'] = now,
['step'] = '3600'
}
res = prom1.range('sum(go_goroutines)', rangeOptions)
local chartOptions = {
['series'] = {
{
['color'] = 'red',
['line_color'] = 'blue',
["data"] = res[1].values,
}
}
}
chartBinData = chart.render('Goroutines', chartOptions)
imageURL = storage.uploadPNG(chartBinData)
local alertOptions = {
['image'] = imageURL
}
lastValue = res[1].values[#res[1].values].value
if lastValue > 100 then
alert.on('goroutines', 'Goroutines count greater than 100', alertOptions)
else
alert.off('goroutines', 'Goroutines count ok', alertOptions)
end
Examples:
Slack:
Telegram: