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: Add optional metadata via query param to silence GET requests #88000

Merged
merged 19 commits into from
May 30, 2024

Conversation

JacobsonMT
Copy link
Member

@JacobsonMT JacobsonMT commented May 16, 2024

What is this feature?

Adds a query param options ruleMetadata=true and accesscontrol=true to /alertmanager/grafana/api/v2/silences and alertmanager/grafana/api/v2/silence/{SilenceId}

ruleMetadata=true will add a new metadata field containing rule_uid, rule_title, folder_uid for rule-specific silences.
accessconntrol=true will add a top-level accessControl field containing user permissions on each silence (read/write/create)

Ex:

{
  "accessControl": {
    "create": false,
    "read": true,
    "write": false
  },
  "comment": "test comment",
  "createdBy": "someone",
  "endsAt": "2026-04-18T18:07:26.993Z",
  "id": "e95bcdc3-97a2-44c1-9361-5ec1d12f9f9e",
  "matchers": [{"isEqual": true,"isRegex": false,"name": "__alert_rule_uid__","value": "load_folder0_group3_alert1"}],
  "metadata": {
    "rule_uid": "load_folder0_group3_alert1",
    "rule_title": "group3_alert1",
    "folder_uid": "edmpbowggnm68d"
  },
  "startsAt": "2024-05-24T20:06:18.670Z",
  "status": {
    "state": "active"
  },
  "updatedAt": "2024-05-24T20:06:18.670Z"
}

Why do we need this feature?

This is needed to:

  • Allow the UI to display useful rule information for rule-specific silences without heavy cross-reference API calls.
  • Allow the UI to simplify logic on access control for deciding when to display permission-specific components.

@JacobsonMT JacobsonMT added this to the 11.1.x milestone May 16, 2024
@JacobsonMT JacobsonMT changed the base branch from main to jacobsonmt/silence-ac-refactor May 16, 2024 17:01
Base automatically changed from jacobsonmt/silence-ac-refactor to main May 23, 2024 16:34
@JacobsonMT JacobsonMT force-pushed the jacobsonmt/silence-with-metadata branch from d0473d6 to 4c61016 Compare May 23, 2024 16:39
@JacobsonMT JacobsonMT force-pushed the jacobsonmt/silence-with-metadata branch from 4c61016 to d142d37 Compare May 24, 2024 17:00
@JacobsonMT JacobsonMT changed the base branch from main to jacobsonmt/extend-rule-ac-for-single-rule May 24, 2024 17:00
@JacobsonMT JacobsonMT force-pushed the jacobsonmt/silence-with-metadata branch 2 times, most recently from 73d9f22 to 5fbbf06 Compare May 27, 2024 17:20
Base automatically changed from jacobsonmt/extend-rule-ac-for-single-rule to main May 28, 2024 14:49
@JacobsonMT JacobsonMT force-pushed the jacobsonmt/silence-with-metadata branch from 1a44689 to 483a72a Compare May 28, 2024 14:51
@JacobsonMT JacobsonMT marked this pull request as ready for review May 28, 2024 14:53
@JacobsonMT JacobsonMT requested a review from a team as a code owner May 28, 2024 14:53
@JacobsonMT JacobsonMT requested review from jtheory, rwwiv, yuri-tceretian and grobinson-grafana and removed request for a team May 28, 2024 14:53
Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

I tested it and it works as expected. Just few comments\suggestions in comments and

  1. I am not sure create field makes sense in per-silence access control field. WDYT?
  2. It would be great to update our integration tests. Separate PR is fine, though.

Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

LGTM! Really like the direction we're taking!

@tomratcliffe
Copy link
Member

I checked with my changes from the UI portion and it looks to be working great on my setup 💯 query params/property names are all aligned now, thanks!

@JacobsonMT JacobsonMT merged commit 09cb3a6 into main May 30, 2024
12 checks passed
@JacobsonMT JacobsonMT deleted the jacobsonmt/silence-with-metadata branch May 30, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants