opensearch-project / alerting-dashboards-plugin

📟 Manage your monitors, alerts and notifications in OpenSearch Dashboards
https://opensearch.org/docs/latest/monitoring-plugins/alerting/index/
Apache License 2.0
26 stars 87 forks source link

[BUG] Destination drop-down list remains empty when disallowed destinations still exist #1043

Open christiand93 opened 1 month ago

christiand93 commented 1 month ago

What is the bug?

When creating or updating the trigger action for an alerting monitor in OpenSearch Dashboards, the list of available destinations remains empty, even though destinations have been configured. The issue occurs only when there is at least one destination remaining whose types has been removed from the allow list.

How can one reproduce the bug? Steps to reproduce the behavior:

  1. Switch to alerting and create a destination with type "email".
  2. Create a second destination with a different type, e.g, "slack".
  3. Remove "email" from the list of allowed destination types in the OpenSearch configuration:
     plugins.alerting.destination.allow_list: ["chime", "slack", "custom_webhook", "test_action"]
  4. Switch to alerting again and create a new monitor.
  5. Add a trigger and try to select a destination from the drop-down list. The list of destination remains empty although the "slack" destination should show up.

What is the expected behavior? All destinations with an allowed type should appear when creating or updating a trigger action.

Versions

Investigation We have found a problem in the getDestinations method in ConfigureActions.js: The destinations are filtered with the allowList in line 95, which is working fine. However, at the end of the method the following code fetches more destinations, if the total number reported by the API is not reached yet: https://github.com/opensearch-project/alerting-dashboards-plugin/blob/7c133586fec9cc4d0f3e4d98b2182e2e8563f3dc/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js#L98-L104 Unfortunately, the condition uses the already filtered list of destinations and not the number of destinations from the destinationsResponse. This means that if one or more destinations are filtered out previously, the method attempts to fetch more destinations. This eventually fails because index exceeds a certain limit (10,000 in our case).

dblock commented 2 weeks ago

[Catch All Triage - 1, 2, 3, 4, 5]