I’m setting up some dashboards in code using grafonnet-lib, but I’m not able to add Alerts. Currently running Grafana 6.3.5. Below is a snippet of my dashboard:
graph.new(
title='Percentage Difference',
span=6,
format='percent',
min='0',
max='100',
legend_show=false,
datasource=datasource,
)
.addTarget(
sql.target(
rawSql='someRawSql',
datasource=datasource,
)
)
.addAlert(
new.alert(
)
),
.addAlert(
'Testing alerts',
executionErrorState='alerting',
frequency='1h',
handler=1,
message='Testing alerts in code',
noDataState='alerting',
notifications=[],
)
.addCondition(
alert.new(
evaluatorParams=[1],
evaluatorType='gt',
operatorType='and',
queryRefId='A',
queryTimeEnd='now',
queryTimeStart='24h',
# reducerParams=[],
# reducerType='avg',
)
)
Without the evaluatorParams the dashboard will fail to update without and error message
gerard1
September 9, 2020, 2:54pm
3
Hi all, I keep seeing Unknown variable: alert
when trying to add this.
What is the exact local ...
command I need to add?
local alertCondition = grafana.alertCondition;
stil gives me the error.
Thanks in advance!
gerard1
September 9, 2020, 3:02pm
4
Found the typo in the above code example.
replace alert
with alertCondition
.
alertCondition.new(
evaluatorParams=[1],
evaluatorType='gt',
operatorType='and',
queryRefId='A',
queryTimeEnd='now',
queryTimeStart='24h',
# reducerParams=[],
# reducerType='avg',
)
)```