Skip to content
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

Alerting: /api/prometheus/grafana/api/v1/alerts uses invalid state names #52453

Open
piotrp opened this issue Jul 19, 2022 · 5 comments
Open
Labels
area/alerting/compliance Issues that are related to alert generator compliance area/alerting Grafana Alerting breaking change Relevant for changelog generation stale Issue with no recent activity

Comments

@piotrp
Copy link

piotrp commented Jul 19, 2022

/api/prometheus/grafana/api/v1/alerts endpoints returns alert's state as Normal/Pending/Alerting, instead of inactive/pending/firing as required by https://github.com/prometheus/compliance/blob/main/alert_generator/specification.md.

Looks like Grafana passes string value of its internal alert state, without any translation:

State: alertState.State.String(),

type State int
const (
// Normal is the eval state for an alert instance condition
// that evaluated to false.
Normal State = iota
// Alerting is the eval state for an alert instance condition
// that evaluated to true (Alerting).
Alerting
// Pending is the eval state for an alert instance condition
// that evaluated to true (Alerting) but has not yet met
// the For duration defined in AlertRule.
Pending
// NoData is the eval state for an alert rule condition
// that evaluated to NoData.
NoData
// Error is the eval state for an alert rule condition
// that evaluated to Error.
Error
)

Tested on Grafana 8.5.6.

@zoltanbedi zoltanbedi added the area/alerting Grafana Alerting label Jul 19, 2022
@piotrp
Copy link
Author

piotrp commented Jul 20, 2022

After looking at this a bit longer I think it's by design, and this endpoint is only inspired by Alert Generator spec, and doesn't try to follow it

@JohnnyQQQQ
Copy link
Member

Thanks for reaching out @piotrp, we already run the alert generator spec against grafana alerting and we are not fully compliant yet. Our goal is to become eventually compliant.

I will keep this issue open to track this part of the effort.

@JohnnyQQQQ JohnnyQQQQ added the area/alerting/compliance Issues that are related to alert generator compliance label Jul 21, 2022
@piotrp
Copy link
Author

piotrp commented Jul 21, 2022

Thank you, it's good to know where this is going. I'm writing custom integration that puts all active alerts into a table and sends it via email, so I'm looking closely at what is available in current APIs, and what can be inferred by looking at available annotations/labels.

@piotrp
Copy link
Author

piotrp commented Jul 22, 2022

Small update, for completeness sake:

  • health - error is reported by "error" instead of "err" (plus there's additional "nodata" health state)
  • there's also "NoData" alert state

For my use it would be ideal to have additional Grafana-specific information present in additional attributes (or private annotations?):

  • explicit nodata indicator (because compliance means that this will disappear from places where it's currently present, and would need to be inferred from present labels)
  • multiple values coming from firing alert with classic condition, here even having __value_string__ annotation, like in /alertmanager, would work as this can be parsed to extract metric names and values
  • some way to tell whether alert is silenced

@JohnnyQQQQ JohnnyQQQQ removed their assignment Aug 1, 2022
@armandgrillet armandgrillet added the breaking change Relevant for changelog generation label Sep 23, 2022
@JohnnyQQQQ JohnnyQQQQ removed their assignment May 4, 2023
Copy link
Contributor

github-actions bot commented May 4, 2024

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale Issue with no recent activity label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alerting/compliance Issues that are related to alert generator compliance area/alerting Grafana Alerting breaking change Relevant for changelog generation stale Issue with no recent activity
Projects
Status: Backlog
Development

No branches or pull requests

4 participants