Skip to content

Fix rendering AlertRulev9 json for possible use in Alerting provisioning API #568

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add folderUid and ruleGroup in params to AlertRulev9
Signed-off-by: Ilia Ilin <[email protected]>
  • Loading branch information
bkmz committed Jan 27, 2023
commit d634ffa9b155a36631140b771baafa430b2b4cf2
6 changes: 5 additions & 1 deletion grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,8 @@ class AlertRulev9(object):
triggers = attr.ib(default=[], validator=is_valid_triggersv9)
annotations = attr.ib(default={}, validator=instance_of(dict))
labels = attr.ib(default={}, validator=instance_of(dict))
folderUid = attr.ib(default=None, validator=attr.validators.optional(instance_of(str)))
ruleGroup = attr.ib(default=None, validator=attr.validators.optional(instance_of(str)))
Comment on lines +1596 to +1597
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add document string for these


evaluateFor = attr.ib(default=DEFAULT_ALERT_EVALUATE_FOR, validator=instance_of(str))
noDataAlertState = attr.ib(
Expand Down Expand Up @@ -1660,7 +1662,9 @@ def to_json_data(self):
"annotations": self.annotations,
"data": data,
"noDataState": self.noDataAlertState,
"execErrState": self.errorAlertState
"execErrState": self.errorAlertState,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this model is correct? According to this API: https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/pkg/services/ngalert/api/tooling/post.json looks that grafana_alert object is required for grafana managed alerts 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you remove this part from the PR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"execErrState": self.errorAlertState,

"folderUid": self.folderUid,
"ruleGroup": self.ruleGroup,
}


Expand Down