Skip to content

Commit

Permalink
Merge pull request #183 from grofers/adds-template-for-alertlist-pane…
Browse files Browse the repository at this point in the history
…l-type

adds alertlist panel type
  • Loading branch information
trotttrotttrott authored Apr 26, 2020
2 parents 0a085a0 + 1c04821 commit f1ceb29
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
27 changes: 27 additions & 0 deletions grafonnet/alertlist.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
new(
title='',
span=null,
show='current',
limit=10,
sortOrder=1,
stateFilter=[],
onlyAlertsOnDashboard=true,
transparent=null,
description=null,
datasource=null,
)::
{
[if transparent != null then 'transparent']: transparent,
title: title,
[if span != null then 'span']: span,
type: 'alertlist',
show: show,
limit: limit,
sortOrder: sortOrder,
[if show != 'changes' then 'stateFilter']: stateFilter,
onlyAlertsOnDashboard: onlyAlertsOnDashboard,
[if description != null then 'description']: description,
datasource: datasource,
},
}
1 change: 1 addition & 0 deletions grafonnet/grafana.libsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
alertlist:: import 'alertlist.libsonnet',
dashboard:: import 'dashboard.libsonnet',
template:: import 'template.libsonnet',
text:: import 'text.libsonnet',
Expand Down
21 changes: 21 additions & 0 deletions tests/alertlist/test.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local grafana = import 'grafonnet/grafana.libsonnet';
local alertlist = grafana.alertlist;

{
basic: alertlist.new(span=12),
advanced: alertlist.new(
title='Alerts List',
datasource='$PROMETHEUS',
description='description',
span=5,
show='current',
limit=20,
sortOrder=2,
stateFilter=[
'ok',
'pending',
],
onlyAlertsOnDashboard=true,
transparent=true,
),
}
29 changes: 29 additions & 0 deletions tests/alertlist/test_compiled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"advanced": {
"datasource": "$PROMETHEUS",
"description": "description",
"limit": 20,
"onlyAlertsOnDashboard": true,
"show": "current",
"sortOrder": 2,
"span": 5,
"stateFilter": [
"ok",
"pending"
],
"title": "Alerts List",
"transparent": true,
"type": "alertlist"
},
"basic": {
"datasource": null,
"limit": 10,
"onlyAlertsOnDashboard": true,
"show": "current",
"sortOrder": 1,
"span": 12,
"stateFilter": [ ],
"title": "",
"type": "alertlist"
}
}

0 comments on commit f1ceb29

Please sign in to comment.