-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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 actions extension point to alert instances table view #77900
Conversation
a6f90ef
to
68f5fa9
Compare
This PR adds a new [extension point][] to each row of the alert instances table. This allows plugins to add actions to a dropdown menu in the rightmost column of the table. Those actions are passed the alert instance so can use it for contextual handling. See grafana/machine-learning#3461 for an example of how this can be used (e.g. by Grafana Sift here).
68f5fa9
to
5df9f51
Compare
e197881
to
869f79b
Compare
The rule will be very useful for users to be able to access things like the name and query string.
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.
I think this looks great, but would like someone with more experience from working with extensions to have a look too. @mckn @leventebalogh can you review?
Regarding the icon button. This doesn't feel totally intuitive to me. Think there's an ellipsis
icon in grafana ui. Can you try that instead?
A tiny nit that perhaps the title should include "table view" - I got terrified for a second as I thought this was referring to the alert instance database table. |
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.
Code changes look good, thanks @sd2k! Couple of small nits and some changes on the UI / interaction model.
Tagging @dhalachliyski here to drop some thoughts on that :)
return ( | ||
<> | ||
<Dropdown placement="bottom-start" overlay={menu}> | ||
<IconButton name="ellipsis-v" aria-label="Actions" disabled={extensions.length === 0} variant="secondary" /> |
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.
I believe we can improve this part of the UI; there's generally two patterns we tend to use in Alerting.
- We don't show the dropdown at all if no actions can be taken, a disabled button with no explanation is a tad confusing :)
- We always show the dropdown, with all of the actions but disable the actions the user has no permissions for are cannot take for some other reason.
If 2 we try to wrap the item with a tooltip explaining why we've disabled the action if we know the reason for it (insufficient permissions, x is not installed / configured, etc)
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.
Makes sense! Happy to add either of those. 1. would be easier for sure, otherwise we'll need to customise the AlertExtensionPointMenu
(or possibly upstream some improvements to the ToolbarExtensionPointMenu
we're hijacking).
I'll wait for @dhalachliyski's feedback before changing it.
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 modifications need to happen to support the second pattern let's go with the first one to unblock this PR – that should be good from a UX perspective :)
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.
LGTM (mostly from a plugin-extensions perspective) 👍
Code changes aside, does this warrant adding to the changelog / what's new if public plugins can inject actions? Do we need to update docs in this PR? |
I guess that's an alerting decision, but from my perspective it might be nice to call out in the changelog that users may find some new actions in their alert instances lists, depending on the plugins they have installed. I'm not sure how that should be documented from a user's POV though, since we don't know what other plugins will extend it. From a dev POV, maybe the plugin extension docs should be updated to reference the new extension point, but I'll leave that up to the plugin extensions folks to decide! |
Instead of showing a disabled dropdown menu (which can be confusing), just don't show the menu at all if no extensions are registered for the alert instance extension point.
It could be a fairly generic statement such as "Application plugins can contribute extensions which allow you to take actions based on a given alert, such as running a Sift investigation to help uncover the route cause of the alert" (I'm not sure on an appropriate location within the alerting docs)
Would welcome a PR to add it to the list here https://grafana.com/developers/plugin-tools/ui-extensions/register-an-extension#available-extension-points-within-grafana 🙏 |
If/when grafana/grafana#77900 is merged there will be a new extension point which plugin developers can register against. This PR adds the ID of the extension point to the `register-an-extension` docs. Keeping as draft for now since the upstream PR isn't merged yet.
Thanks for all the reviews folks. @gillesdemey I'll leave the final decision to merge up to you - happy to contribute some docs if you'd like some, but I'm not 100% sure where they live! @sympatheticmoose I've got a draft PR in place for the plugin tools docs 👍 |
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.
This is mostly for our own plugins for now – so I think it's fine to merge without docs update :)
LGTM! 🚀
…77900) This PR adds a new [extension point][] to each row of the alert instances table. This allows plugins to add actions to a dropdown menu in the rightmost column of the table. Those actions are passed the alert instance so can use it for contextual handling. See grafana/machine-learning#3461 for an example of how this can be used (e.g. by Grafana Sift here).
This PR adds an [extension point] to the Grafana plugin, allowing other plugins to add menu items to the dropdown independently of this plugin. It also moves the 'Declare incident' button into the 'Actions' menu representing the extension point, and displays it conditionally; the menu item is shown if all of the following are true: 1. the Grafana Incident plugin is installed (using the `PluginBridge` as before) 2. the alert group has a valid Grafana Incident URL 3. the alert group hasn't already been linked to an Incident 4. the Grafana Incident plugin hasn't _also_ configured an identical extension link to show in the dropdown. Ideally the Grafana Incident plugin would soon configure an extension using this extension point, at which point we can remove the custom 'Declare incident' button (and the `PluginBridge`) from the OnCall app. --- The main use case I have for this is to be able to run a Sift investigation from an OnCall alert group, similar to how it can be done from a Grafana alert instance as of [this PR][pr]. I'll try and get the Grafana ML and Incident plugins running in the same Grafana instance as this to test it out more thoroughly! Part of grafana/machine-learning#3558. [extension point]: https://grafana.com/developers/plugin-tools/ui-extensions/create-an-extension-point [pr]: grafana/grafana#77900
# What this PR does This PR adds an [extension point] to the Grafana plugin, allowing other plugins to add menu items to the dropdown independently of this plugin. It also moves the 'Declare incident' button into the 'Actions' menu representing the extension point, and displays it conditionally; the menu item is shown if all of the following are true: 1. the Grafana Incident plugin is installed (using the `PluginBridge` as before) 2. the alert group has a valid Grafana Incident URL 3. the alert group hasn't already been linked to an Incident 4. the Grafana Incident plugin hasn't _also_ configured an identical extension link to show in the dropdown. Ideally the Grafana Incident plugin would soon configure an extension using this extension point, at which point we can remove the custom 'Declare incident' button (and the `PluginBridge`) from the OnCall app. --- The main use case I have for this is to be able to run a Sift investigation from an OnCall alert group, similar to how it can be done from a Grafana alert instance as of [this PR][pr]. I'll try and get the Grafana ML and Incident plugins running in the same Grafana instance as this to test it out more thoroughly! Note: this is heavily inspired by, and in some case stolen from, the [Explore toolbar extension point in Grafana](https://github.com/grafana/grafana/blob/main/public/app/features/explore/extensions/ToolbarExtensionPoint.tsx). ## Which issue(s) this PR fixes Part of grafana/machine-learning#3558. ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) [extension point]: https://grafana.com/developers/plugin-tools/ui-extensions/create-an-extension-point [pr]: grafana/grafana#77900
What is this feature?
This PR adds a new extension point to each row of the alert instances table, which is shown in both the 'Rule list' and the 'Rule details' pages. This allows plugins to add actions to a dropdown menu in the rightmost column of the table. Those actions are passed the alert instance so can use it for contextual handling. This is similar to the dropdown menu in the 'Explore' page (when you click 'Add') or in the panel menu dropdown (under 'Extensions').
See https://github.com/grafana/machine-learning/pull/3461 for an video example of how this can be used (e.g. by Grafana Sift here).
Why do we need this feature?
So far if plugins have wanted to add functionality to the alerting page it's been O(N) in the number of UI features added - e.g. adding the Grafana Incident button required work on the alerting page that was specific to that plugin. By adding a plugin extension point, any plugin can easily inject useful functionality in a non-intrusive way without needing further development on the alerting side.
Who is this feature for?
Plugin developers who would like to hook into the alerting page (specifically the Sift team, right now), and users who can then interact with alert instances in more varied ways.
Which issue(s) does this PR fix?:
Fixes https://github.com/grafana/machine-learning/issues/3458.
Special notes for your reviewer:
Things to consider:
PluginExtensionAlertInstanceContext
should probably be exported as part of@grafana/data
(similar toPluginExtensionPanelContext
), but it contains private types i.e. (Alert
). Is there a subset of thisAlert
interface we could add to@grafana/data
?Screenshots:
unexpanded:
expanded with one action:
Please check that: