Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions grizzly/grafana.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ local util = import 'util.libsonnet';
getFolder(main):: util.get(main, 'grafanaDashboardFolder', 'General'),

fromMap(dashboards, folder):: {
[k]: util.makeResource('Dashboard', k, dashboards[k], { folder: folder })
[k]: util.makeResource(
'Dashboard',
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
dashboards[k],
{ folder: folder }
)
for k in std.objectFields(dashboards)
},

Expand All @@ -14,7 +19,12 @@ local util = import 'util.libsonnet';
local mixin = mixins[key];
{
local folder = util.get(mixin, 'grafanaDashboardFolder', 'General'),
[k]: util.makeResource('Dashboard', k, mixin.grafanaDashboards[k], { folder: folder })
[k]: util.makeResource(
'Dashboard',
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
mixin.grafanaDashboards[k],
{ folder: folder }
)
for k in std.objectFieldsAll(util.get(mixin, 'grafanaDashboards', {}))
}
for key in std.objectFields(mixins)
Expand Down
9 changes: 7 additions & 2 deletions grizzly/prometheus.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ local resource = import 'resource.libsonnet';

fromMapsFiltered(rules, excludes):: {
local filterRules(rules, exclude_list) = [rule for rule in rules.groups if !std.member(exclude_list, rule.name)],
[k]: util.makeResource(kind, k, { groups: filterRules(rules, excludes) }, {})
[k]: util.makeResource(
kind,
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
{ groups: filterRules(rules, excludes) },
{}
)
for k in std.objectFields(rules)
},

fromMixins(mixins):: {
[if std.objectHasAll(mixins[key], alertRules) || std.objectHasAll(mixins[key], recordingRules) then key else null]:
util.makeResource(
kind,
key,
std.strReplace(std.strReplace(std.strReplace(key, '.json', ''), '.yaml', ''), '.yml', ''),
(if std.objectHasAll(mixins[key], alertRules) then mixins[key].prometheusAlerts else {})
+ (if std.objectHasAll(mixins[key], recordingRules) then mixins[key].prometheusRules else {})
)
Expand Down