Skip to content

feat(contact-point): support retrieval by name #135

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

Conversation

Saurus119
Copy link

  • Adds support for retrieving a contact point by its exact name.
  • If multiple contact points share the same name, the method will return all matching contact points in a list.
  • This can occur, for example, when an alert rule uses contact points that implement multiple actions. In Grafana’s UI, such contact points are grouped by name, but they are stored as separate contact points in the backend.

@Saurus119
Copy link
Author

@ZPascal

@ZPascal ZPascal self-assigned this Aug 12, 2025
@ZPascal ZPascal self-requested a review August 12, 2025 07:19
@ZPascal ZPascal assigned Saurus119 and unassigned ZPascal Aug 12, 2025
@@ -226,6 +226,30 @@ def get_all_contact_points(self) -> list:
else:
return api_call

def get_contact_point(self, name: str) -> list:
Copy link
Owner

Choose a reason for hiding this comment

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

Can you please contribute unit tests for the functionality?

Copy link
Author

Choose a reason for hiding this comment

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

Added, I also modified little bit existing test to get all:contact_points so it is crystal clear that it can return multiple, not only one.

  • Modified get_contact_point because the response list() is valid response from the grafana API if you don´t have a match. So when you do call for the contact point that doesn´t exists you shouldn´t raise exception on empty list response.

@Saurus119 Saurus119 requested a review from ZPascal August 12, 2025 18:56
@Saurus119
Copy link
Author

  • Maybe would be good to add functionality to create conditions as "Expressions". Based on your Models for alerts it doesnt exactly match the grafana API, for some functionality I had to just use your api_call and create payloads manually.
  • Conditions (legacy) are pretty old and mostly when you have grafana sourced, you use "expressions", which is we can say condition but more smart. So maybe some "ExpressionCondition", where you can specify type as "Math", "Reduce", and so on would be nice to add and direclty use if you need. My usecase is: I created a queries to this queries I want to link Expressions where N of them are type of "Reduce" and one "Math" where I combine multiple conditions but I am not sure if you would welcome this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants