Skip to content

[BUG] Bug in create monitor API #2025

@vikhy-aws

Description

@vikhy-aws

What is the bug?
Currently the create monitor does not throw an error even if action_execution_policy is not specified in the monitor document and creates a monitor. However, the edit monitor UI page breaks if action_execution_policy is not specified in the monitor. So, the monitor creation should be blocked and an appropriate error message should be thrown if action_execution_policy configuration is missing in monitor creation.

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

  1. Go to dev tools
  2. Create a monitor using the following command after replacing placeholders
POST _plugins/_alerting/monitors
{
  "type": "monitor",
  "schema_version": 8,
  "name": "test monitor",
  "monitor_type": "bucket_level_monitor",
  "enabled": true,
  "enabled_time": 1700000000000,
  "schedule": {
      "period": {
          "interval": 60,
          "unit": "MINUTES"
      }
  },
  "inputs": [
      {
          "search": {
              "indices": [
                  "test-index"
              ],
              "query": {
                  "size": 0,
                  "query": {
                      "bool": {
                          "filter": [
                              {
                                  "term": {
                                      "some_term": {
                                          "value": "some_value",
                                      }
                                  }
                              },
                              {
                                  "match_phrase": {
                                      "message": {
                                          "query": <query>,
                                      }
                                  }
                              },
                              {
                                  "range": {
                                      "@timestamp": {
                                          "from": "{{period_end}}||-1h",
                                          "to": "{{period_end}}",
                                          "include_lower": true,
                                          "include_upper": true,
                                          "boost": 1
                                      }
                                  }
                              }
                          ],
                          "adjust_pure_negative": true,
                          "boost": 1
                      }
                  },
                  "aggregations": {}
              }
          }
      }
  ],
  "triggers": [
      {
          "bucket_level_trigger": {
              "id": "id",
              "name": "trigger name",
              "severity": "2",
              "condition": <some_condition>,
              "actions": [
                  {
                      "id": "id",
                      "name": "notif channel",
                      "destination_id": "id",
                      "message_template": {
                          "source": <source>,
                          "lang": "mustache"
                      },
                      "throttle_enabled": false,
                      "subject_template": {
                          "source": "test",
                          "lang": "mustache"
                      },
                  }
              ]
          }
      }
  ],
  "last_update_time": 1700000000000,
  "data_sources": {
      "query_index": ".opensearch-alerting-queries",
      "findings_index": ".opensearch-alerting-finding-history-write",
      "findings_index_pattern": "<.opensearch-alerting-finding-history-{now/d}-1>",
      "alerts_index": ".opendistro-alerting-alerts",
      "alerts_history_index": ".opendistro-alerting-alert-history-write",
      "alerts_history_index_pattern": "<.opendistro-alerting-alert-history-{now/d}-1>",
      "query_index_mappings_by_type": {},
      "findings_enabled": false
  },
  "owner": "alerting",
  "associated_workflows": [],
  "associatedCompositeMonitorCnt": 0,
  "item_type": "bucket_level_monitor",
  "id": "id",
  "version": 1
}
  1. Go to monitor details page and click on edit monitor button to go into edit monitor page.
  2. The page breaks.

What is the expected behavior?
Monitor creation should be blocked and an error message should be displayed to the user if action_execution_policy is missing. Also, edit monitor page should not break.

What is your host/environment?

  • OS: iOS
  • Version: 2.9
  • Plugins: Alerting

Do you have any screenshots?
No

Do you have any additional context?
No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions