-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve jsonnet parser for rules #211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, looks otherwise done well, thanks!
pkg/grizzly/grizzly.jsonnet
Outdated
[ | ||
[ | ||
makeResource( | ||
'PrometheusRuleGroup', | ||
g.name, | ||
spec={ | ||
rules: g.rules, | ||
}, | ||
metadata={ namespace: ns } | ||
) | ||
for g in allNamespaced[ns].groups | ||
] | ||
for ns in std.objectFields(allNamespaced) | ||
] else []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if key in main
is true, then doesn't this result in an array within an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Still, grizzly tolerated that :) Updated to use nested loop without extra array in the result.
- Load all rule groups instead of the first one - Parse rule groups when they are not wrapped into namespace. This is extremely useful when working with monitoring-mixins.
c5626b8
to
fc27691
Compare
Co-authored-by: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for this.
Hi! Even though it says deprecated for using hidden fields, we still using it extensively for monitoring-mixins development, especially in
grr watch
mode.It works great for 'dashboards only' mixins that way, but unfortunately, it stops working when rules are present, error is recevied:
This is due grizzly.jsonnet expects rules to be wrapped in the namespace:
while monitoring-mixins by convention have alerts defined without one:
(some examples:
https://github.com/prometheus/node_exporter/blob/master/docs/node-mixin/alerts/alerts.libsonnet
https://github.com/prometheus/prometheus/blob/main/documentation/prometheus-mixin/alerts.libsonnet
)
So here is the suggested improvement for jsonnet rule parser that:
This fix not only allows loading of monitoring-mixins dashboards inside grafana without any grizzly specific changes to original mixin, but also can load monitoring-mixins alerts into cortex as well: