diff --git a/.buildkite/scripts/steps/capture_oas_snapshot.sh b/.buildkite/scripts/steps/capture_oas_snapshot.sh index fadd7276b47cc..9768ff50c8fa5 100755 --- a/.buildkite/scripts/steps/capture_oas_snapshot.sh +++ b/.buildkite/scripts/steps/capture_oas_snapshot.sh @@ -5,7 +5,7 @@ set -euo pipefail source .buildkite/scripts/common/util.sh echo --- Capture OAS snapshot -cmd="node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules" +cmd="node scripts/capture_oas_snapshot --include-path /api/status" if is_pr && ! is_auto_commit_disabled; then cmd="$cmd --update" fi diff --git a/.github/workflows/alert-failed-test.yml b/.github/workflows/alert-failed-test.yml index 92916629d80f3..4d465b03dd43f 100644 --- a/.github/workflows/alert-failed-test.yml +++ b/.github/workflows/alert-failed-test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout kibana-operations - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-operations' ref: main diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c4819f86fa1f9..66f99a95a3b2c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: ${{ matrix.branch }} diff --git a/.github/workflows/fix-version-gaps.yml b/.github/workflows/fix-version-gaps.yml index 77a56a268f20d..1e89ec2553457 100644 --- a/.github/workflows/fix-version-gaps.yml +++ b/.github/workflows/fix-version-gaps.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-github-actions' ref: main diff --git a/.github/workflows/label-failed-test.yml b/.github/workflows/label-failed-test.yml index ec5114803639e..358ff08edecd1 100644 --- a/.github/workflows/label-failed-test.yml +++ b/.github/workflows/label-failed-test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout kibana-operations - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-operations' ref: main diff --git a/.github/workflows/launchdarkly-code-references.yml b/.github/workflows/launchdarkly-code-references.yml index ab888da06c97a..3f6c4b1ead69f 100644 --- a/.github/workflows/launchdarkly-code-references.yml +++ b/.github/workflows/launchdarkly-code-references.yml @@ -16,7 +16,7 @@ jobs: if: github.event.repository.fork == false runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 11 # This value must be set if the lookback configuration option is not disabled for find-code-references. Read more: https://github.com/launchdarkly/ld-find-code-refs#searching-for-unused-flags-extinctions - name: LaunchDarkly Code References diff --git a/.github/workflows/on-merge.yml b/.github/workflows/on-merge.yml index b02129edb6fe0..421e4825d1a6a 100644 --- a/.github/workflows/on-merge.yml +++ b/.github/workflows/on-merge.yml @@ -24,7 +24,7 @@ jobs: ) steps: - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-github-actions' ref: main diff --git a/.github/workflows/skip-failed-test.yml b/.github/workflows/skip-failed-test.yml index 4c6d7c94b808d..913ba7b9648d4 100644 --- a/.github/workflows/skip-failed-test.yml +++ b/.github/workflows/skip-failed-test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-github-actions' ref: main @@ -30,7 +30,7 @@ jobs: token: ${{secrets.KIBANAMACHINE_TOKEN}} - name: Checkout kibana-operations - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: 'elastic/kibana-operations' ref: main diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index fbf194c8491a2..3c6756b1da369 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -344,4713 +344,9 @@ }, "openapi": "3.0.0", "paths": { - "/api/alerting/rule/{id}": { - "delete": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#2", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Delete a rule", - "tags": [ - "alerting" - ] - }, - "get": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Get rule details", - "tags": [ - "alerting" - ] - }, - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%3F%7D#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule. If it is omitted, an ID is randomly generated.", - "in": "path", - "name": "id", - "required": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "default": [], - "items": { - "additionalProperties": false, - "description": "An action that runs under defined conditions.", - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Conditions that affect whether the action runs. If you specify multiple conditions, all conditions must be met for the action to run. For example, if an alert occurs within the specified time frame and matches the query, the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "description": "Defines the range of time in a day that the action can run. If the `start` value is `00:00` and the `end` value is `24:00`, actions be generated all day.", - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if `notify_when` is set to `onThrottleInterval`. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id" - ], - "type": "object" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "enabled": { - "default": true, - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "name": { - "description": "The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule.", - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "schedule": { - "additionalProperties": false, - "description": "The check interval, which specifies how frequently the rule conditions are checked.", - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "tags": { - "default": [], - "description": "The tags for the rule.", - "items": { - "type": "string" - }, - "type": "array" - }, - "throttle": { - "description": "Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "name", - "rule_type_id", - "consumer", - "schedule" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Create a rule", - "tags": [ - "alerting" - ] - }, - "put": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#1", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "default": [], - "items": { - "additionalProperties": false, - "description": "An action that runs under defined conditions.", - "properties": { - "alerts_filter": { - "additionalProperties": false, - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "description": "Defines the range of time in a day that the action can run. If the `start` value is `00:00` and the `end` value is `24:00`, actions be generated all day.", - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if `notify_when` is set to `onThrottleInterval`. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id" - ], - "type": "object" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "name": { - "description": "The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule.", - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "tags": { - "default": [], - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "description": "Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "name", - "schedule" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Update a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_disable": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_disable#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "nullable": true, - "properties": { - "untrack": { - "description": "Defines whether this rule's alerts should be untracked.", - "type": "boolean" - } - }, - "type": "object", - "x-oas-optional": true - } - } - } - }, - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Disable a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_enable": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_enable#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Enable a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_mute_all": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_mute_all#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Mute all alerts", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_unmute_all": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_unmute_all#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Unmute all alerts", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_update_api_key": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_update_api_key#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Update the API key for a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{rule_id}/alert/{alert_id}/_mute": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Brule_id%7D%2Falert%2F%7Balert_id%7D%2F_mute#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "rule_id", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "The identifier for the alert.", - "in": "path", - "name": "alert_id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Mute an alert", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{rule_id}/alert/{alert_id}/_unmute": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Brule_id%7D%2Falert%2F%7Balert_id%7D%2F_unmute#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "rule_id", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "The identifier for the alert.", - "in": "path", - "name": "alert_id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Unmute an alert", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rules/_find": { - "get": { - "operationId": "%2Fapi%2Falerting%2Frules%2F_find#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "The number of rules to return per page.", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 10, - "minimum": 0, - "type": "number" - } - }, - { - "description": "The page number to return.", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "minimum": 1, - "type": "number" - } - }, - { - "description": "An Elasticsearch simple_query_string query that filters the objects in the response.", - "in": "query", - "name": "search", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "The default operator to use for the simple_query_string.", - "in": "query", - "name": "default_search_operator", - "required": false, - "schema": { - "default": "OR", - "enum": [ - "OR", - "AND" - ], - "type": "string" - } - }, - { - "description": "The fields to perform the simple_query_string parsed query against.", - "in": "query", - "name": "search_fields", - "required": false, - "schema": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "string" - } - ] - } - }, - { - "description": "Determines which field is used to sort the results. The field must exist in the `attributes` key of the response.", - "in": "query", - "name": "sort_field", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Determines the sort order.", - "in": "query", - "name": "sort_order", - "required": false, - "schema": { - "enum": [ - "asc", - "desc" - ], - "type": "string" - } - }, - { - "description": "Filters the rules that have a relation with the reference objects with a specific type and identifier.", - "in": "query", - "name": "has_reference", - "required": false, - "schema": { - "additionalProperties": false, - "nullable": true, - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string" - } - }, - "required": [ - "type", - "id" - ], - "type": "object" - } - }, - { - "in": "query", - "name": "fields", - "required": false, - "schema": { - "items": { - "description": "The fields to return in the `attributes` key of the response.", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "A KQL string that you filter with an attribute from your saved object. It should look like `savedObjectType.attributes.title: \"myTitle\"`. However, if you used a direct attribute of a saved object, such as `updatedAt`, you must define your filter, for example, `savedObjectType.updatedAt > 2018-12-22`.", - "in": "query", - "name": "filter", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "filter_consumers", - "required": false, - "schema": { - "items": { - "description": "List of consumers to filter.", - "type": "string" - }, - "type": "array" - } - } - ], - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Get information about rules", - "tags": [ - "alerting" - ] - } - }, "/api/status": { "get": { - "operationId": "%2Fapi%2Fstatus#0", + "operationId": "/api/status#0", "parameters": [ { "description": "The version of the API to use", @@ -5139,9 +435,6 @@ } ], "tags": [ - { - "name": "alerting" - }, { "name": "system" } diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index fbf194c8491a2..3c6756b1da369 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -344,4713 +344,9 @@ }, "openapi": "3.0.0", "paths": { - "/api/alerting/rule/{id}": { - "delete": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#2", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Delete a rule", - "tags": [ - "alerting" - ] - }, - "get": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Get rule details", - "tags": [ - "alerting" - ] - }, - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%3F%7D#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule. If it is omitted, an ID is randomly generated.", - "in": "path", - "name": "id", - "required": false, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "default": [], - "items": { - "additionalProperties": false, - "description": "An action that runs under defined conditions.", - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Conditions that affect whether the action runs. If you specify multiple conditions, all conditions must be met for the action to run. For example, if an alert occurs within the specified time frame and matches the query, the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "description": "Defines the range of time in a day that the action can run. If the `start` value is `00:00` and the `end` value is `24:00`, actions be generated all day.", - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if `notify_when` is set to `onThrottleInterval`. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id" - ], - "type": "object" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "enabled": { - "default": true, - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "name": { - "description": "The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule.", - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "schedule": { - "additionalProperties": false, - "description": "The check interval, which specifies how frequently the rule conditions are checked.", - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "tags": { - "default": [], - "description": "The tags for the rule.", - "items": { - "type": "string" - }, - "type": "array" - }, - "throttle": { - "description": "Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "name", - "rule_type_id", - "consumer", - "schedule" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Create a rule", - "tags": [ - "alerting" - ] - }, - "put": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#1", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "default": [], - "items": { - "additionalProperties": false, - "description": "An action that runs under defined conditions.", - "properties": { - "alerts_filter": { - "additionalProperties": false, - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "description": "Defines the range of time in a day that the action can run. If the `start` value is `00:00` and the `end` value is `24:00`, actions be generated all day.", - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if `notify_when` is set to `onThrottleInterval`. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id" - ], - "type": "object" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "name": { - "description": "The name of the rule. While this name does not have to be unique, a distinctive name can help you identify a rule.", - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "default": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "tags": { - "default": [], - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "description": "Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "name", - "schedule" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Update a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_disable": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_disable#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "nullable": true, - "properties": { - "untrack": { - "description": "Defines whether this rule's alerts should be untracked.", - "type": "boolean" - } - }, - "type": "object", - "x-oas-optional": true - } - } - } - }, - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Disable a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_enable": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_enable#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Enable a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_mute_all": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_mute_all#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Mute all alerts", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_unmute_all": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_unmute_all#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Unmute all alerts", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{id}/_update_api_key": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D%2F_update_api_key#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Update the API key for a rule", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{rule_id}/alert/{alert_id}/_mute": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Brule_id%7D%2Falert%2F%7Balert_id%7D%2F_mute#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "rule_id", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "The identifier for the alert.", - "in": "path", - "name": "alert_id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Mute an alert", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rule/{rule_id}/alert/{alert_id}/_unmute": { - "post": { - "operationId": "%2Fapi%2Falerting%2Frule%2F%7Brule_id%7D%2Falert%2F%7Balert_id%7D%2F_unmute#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - }, - { - "description": "The identifier for the rule.", - "in": "path", - "name": "rule_id", - "required": true, - "schema": { - "type": "string" - } - }, - { - "description": "The identifier for the alert.", - "in": "path", - "name": "alert_id", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "Indicates a successful call." - } - }, - "summary": "Unmute an alert", - "tags": [ - "alerting" - ] - } - }, - "/api/alerting/rules/_find": { - "get": { - "operationId": "%2Fapi%2Falerting%2Frules%2F_find#0", - "parameters": [ - { - "description": "The version of the API to use", - "in": "header", - "name": "elastic-api-version", - "schema": { - "default": "2023-10-31", - "enum": [ - "2023-10-31" - ], - "type": "string" - } - }, - { - "description": "The number of rules to return per page.", - "in": "query", - "name": "per_page", - "required": false, - "schema": { - "default": 10, - "minimum": 0, - "type": "number" - } - }, - { - "description": "The page number to return.", - "in": "query", - "name": "page", - "required": false, - "schema": { - "default": 1, - "minimum": 1, - "type": "number" - } - }, - { - "description": "An Elasticsearch simple_query_string query that filters the objects in the response.", - "in": "query", - "name": "search", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "The default operator to use for the simple_query_string.", - "in": "query", - "name": "default_search_operator", - "required": false, - "schema": { - "default": "OR", - "enum": [ - "OR", - "AND" - ], - "type": "string" - } - }, - { - "description": "The fields to perform the simple_query_string parsed query against.", - "in": "query", - "name": "search_fields", - "required": false, - "schema": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "string" - } - ] - } - }, - { - "description": "Determines which field is used to sort the results. The field must exist in the `attributes` key of the response.", - "in": "query", - "name": "sort_field", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Determines the sort order.", - "in": "query", - "name": "sort_order", - "required": false, - "schema": { - "enum": [ - "asc", - "desc" - ], - "type": "string" - } - }, - { - "description": "Filters the rules that have a relation with the reference objects with a specific type and identifier.", - "in": "query", - "name": "has_reference", - "required": false, - "schema": { - "additionalProperties": false, - "nullable": true, - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string" - } - }, - "required": [ - "type", - "id" - ], - "type": "object" - } - }, - { - "in": "query", - "name": "fields", - "required": false, - "schema": { - "items": { - "description": "The fields to return in the `attributes` key of the response.", - "type": "string" - }, - "type": "array" - } - }, - { - "description": "A KQL string that you filter with an attribute from your saved object. It should look like `savedObjectType.attributes.title: \"myTitle\"`. However, if you used a direct attribute of a saved object, such as `updatedAt`, you must define your filter, for example, `savedObjectType.updatedAt > 2018-12-22`.", - "in": "query", - "name": "filter", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "filter_consumers", - "required": false, - "schema": { - "items": { - "description": "List of consumers to filter.", - "type": "string" - }, - "type": "array" - } - } - ], - "responses": { - "200": { - "content": { - "application/json; Elastic-Api-Version=2023-10-31": { - "schema": { - "additionalProperties": false, - "properties": { - "actions": { - "items": { - "additionalProperties": false, - "properties": { - "alerts_filter": { - "additionalProperties": false, - "description": "Defines a period that limits whether the action runs.", - "properties": { - "query": { - "additionalProperties": false, - "properties": { - "dsl": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL).", - "type": "string" - }, - "filters": { - "description": "A filter written in Elasticsearch Query Domain Specific Language (DSL) as defined in the `kbn-es-query` package.", - "items": { - "additionalProperties": false, - "properties": { - "$state": { - "additionalProperties": false, - "properties": { - "store": { - "description": "A filter can be either specific to an application context or applied globally.", - "enum": [ - "appState", - "globalState" - ], - "type": "string" - } - }, - "required": [ - "store" - ], - "type": "object" - }, - "meta": { - "additionalProperties": {}, - "type": "object" - }, - "query": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "meta" - ], - "type": "object" - }, - "type": "array" - }, - "kql": { - "description": "A filter written in Kibana Query Language (KQL).", - "type": "string" - } - }, - "required": [ - "kql", - "filters" - ], - "type": "object" - }, - "timeframe": { - "additionalProperties": false, - "properties": { - "days": { - "description": "Defines the days of the week that the action can run, represented as an array of numbers. For example, `1` represents Monday. An empty array is equivalent to specifying all the days of the week.", - "items": { - "enum": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - "type": "integer" - }, - "type": "array" - }, - "hours": { - "additionalProperties": false, - "properties": { - "end": { - "description": "The end of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - }, - "start": { - "description": "The start of the time frame in 24-hour notation (`hh:mm`).", - "type": "string" - } - }, - "required": [ - "start", - "end" - ], - "type": "object" - }, - "timezone": { - "description": "The ISO time zone for the `hours` values. Values such as `UTC` and `UTC+1` also work but lack built-in daylight savings time support and are not recommended.", - "type": "string" - } - }, - "required": [ - "days", - "hours", - "timezone" - ], - "type": "object" - } - }, - "type": "object" - }, - "connector_type_id": { - "description": "The type of connector. This property appears in responses but cannot be set in requests.", - "type": "string" - }, - "frequency": { - "additionalProperties": false, - "properties": { - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "type": "string" - }, - "summary": { - "description": "Indicates whether the action is a summary.", - "type": "boolean" - }, - "throttle": { - "description": "The throttle interval, which defines how often an alert generates repeated actions. It is specified in seconds, minutes, hours, or days and is applicable only if 'notify_when' is set to 'onThrottleInterval'. NOTE: You cannot specify the throttle interval at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "summary", - "notify_when", - "throttle" - ], - "type": "object" - }, - "group": { - "description": "The group name, which affects when the action runs (for example, when the threshold is met or when the alert is recovered). Each rule type has a list of valid action group names. If you don't need to group actions, set to `default`.", - "type": "string" - }, - "id": { - "description": "The identifier for the connector saved object.", - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the action, which are sent to the connector. The `params` are handled as Mustache templates and passed a default set of context.", - "type": "object" - }, - "use_alert_data_for_template": { - "description": "Indicates whether to use alert data as a template.", - "type": "boolean" - }, - "uuid": { - "description": "A universally unique identifier (UUID) for the action.", - "type": "string" - } - }, - "required": [ - "id", - "connector_type_id", - "params" - ], - "type": "object" - }, - "type": "array" - }, - "active_snoozes": { - "items": { - "description": "List of active snoozes for the rule.", - "type": "string" - }, - "type": "array" - }, - "alert_delay": { - "additionalProperties": false, - "description": "Indicates that an alert occurs only when the specified number of consecutive runs met the rule conditions.", - "properties": { - "active": { - "description": "The number of consecutive runs that must meet the rule conditions.", - "type": "number" - } - }, - "required": [ - "active" - ], - "type": "object" - }, - "api_key_created_by_user": { - "description": "Indicates whether the API key that is associated with the rule was created by the user.", - "nullable": true, - "type": "boolean" - }, - "api_key_owner": { - "description": "The owner of the API key that is associated with the rule and used to run background tasks.", - "nullable": true, - "type": "string" - }, - "consumer": { - "description": "The name of the application or feature that owns the rule. For example: `alerts`, `apm`, `discover`, `infrastructure`, `logs`, `metrics`, `ml`, `monitoring`, `securitySolution`, `siem`, `stackAlerts`, or `uptime`.", - "type": "string" - }, - "created_at": { - "description": "The date and time that the rule was created.", - "type": "string" - }, - "created_by": { - "description": "The identifier for the user that created the rule.", - "nullable": true, - "type": "string" - }, - "enabled": { - "description": "Indicates whether you want to run the rule on an interval basis after it is created.", - "type": "boolean" - }, - "execution_status": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Error message.", - "type": "string" - }, - "reason": { - "description": "Reason for error.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - }, - "last_duration": { - "description": "Duration of last execution of the rule.", - "type": "number" - }, - "last_execution_date": { - "description": "The date and time when rule was executed last.", - "type": "string" - }, - "status": { - "description": "Status of rule execution.", - "enum": [ - "ok", - "active", - "error", - "warning", - "pending", - "unknown" - ], - "type": "string" - }, - "warning": { - "additionalProperties": false, - "properties": { - "message": { - "description": "Warning message.", - "type": "string" - }, - "reason": { - "description": "Reason for warning.", - "enum": [ - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "type": "string" - } - }, - "required": [ - "reason", - "message" - ], - "type": "object" - } - }, - "required": [ - "status", - "last_execution_date" - ], - "type": "object" - }, - "id": { - "description": "The identifier for the rule.", - "type": "string" - }, - "is_snoozed_until": { - "description": "The date when the rule will no longer be snoozed.", - "nullable": true, - "type": "string" - }, - "last_run": { - "additionalProperties": false, - "nullable": true, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "mapped_params": { - "additionalProperties": {}, - "type": "object" - }, - "monitoring": { - "additionalProperties": false, - "description": "Monitoring details of the rule.", - "properties": { - "run": { - "additionalProperties": false, - "description": "Rule run details.", - "properties": { - "calculated_metrics": { - "additionalProperties": false, - "description": "Calculation of different percentiles and success ratio.", - "properties": { - "p50": { - "type": "number" - }, - "p95": { - "type": "number" - }, - "p99": { - "type": "number" - }, - "success_ratio": { - "type": "number" - } - }, - "required": [ - "success_ratio" - ], - "type": "object" - }, - "history": { - "description": "History of the rule run.", - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule run.", - "type": "number" - }, - "outcome": { - "additionalProperties": false, - "properties": { - "alerts_count": { - "additionalProperties": false, - "properties": { - "active": { - "description": "Number of active alerts during last run.", - "nullable": true, - "type": "number" - }, - "ignored": { - "description": "Number of ignored alerts during last run.", - "nullable": true, - "type": "number" - }, - "new": { - "description": "Number of new alerts during last run.", - "nullable": true, - "type": "number" - }, - "recovered": { - "description": "Number of recovered alerts during last run.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "outcome": { - "description": "Outcome of last run of the rule. Value could be succeeded, warning or failed.", - "enum": [ - "succeeded", - "warning", - "failed" - ], - "type": "string" - }, - "outcome_msg": { - "items": { - "description": "Outcome message generated during last rule run.", - "type": "string" - }, - "nullable": true, - "type": "array" - }, - "outcome_order": { - "description": "Order of the outcome.", - "type": "number" - }, - "warning": { - "description": "Warning of last rule execution.", - "enum": [ - "read", - "decrypt", - "execute", - "unknown", - "license", - "timeout", - "disabled", - "validate", - "maxExecutableActions", - "maxAlerts", - "maxQueuedActions" - ], - "nullable": true, - "type": "string" - } - }, - "required": [ - "outcome", - "alerts_count" - ], - "type": "object" - }, - "success": { - "description": "Indicates whether the rule run was successful.", - "type": "boolean" - }, - "timestamp": { - "description": "Time of rule run.", - "type": "number" - } - }, - "required": [ - "success", - "timestamp" - ], - "type": "object" - }, - "type": "array" - }, - "last_run": { - "additionalProperties": false, - "properties": { - "metrics": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of most recent rule run.", - "type": "number" - }, - "gap_duration_s": { - "description": "Duration in seconds of rule run gap.", - "nullable": true, - "type": "number" - }, - "total_alerts_created": { - "description": "Total number of alerts created during last rule run.", - "nullable": true, - "type": "number" - }, - "total_alerts_detected": { - "description": "Total number of alerts detected during last rule run.", - "nullable": true, - "type": "number" - }, - "total_indexing_duration_ms": { - "description": "Total time spent indexing documents during last rule run in milliseconds.", - "nullable": true, - "type": "number" - }, - "total_search_duration_ms": { - "description": "Total time spent performing Elasticsearch searches as measured by Kibana; includes network latency and time spent serializing or deserializing the request and response.", - "nullable": true, - "type": "number" - } - }, - "type": "object" - }, - "timestamp": { - "description": "Time of the most recent rule run.", - "type": "string" - } - }, - "required": [ - "timestamp", - "metrics" - ], - "type": "object" - } - }, - "required": [ - "history", - "calculated_metrics", - "last_run" - ], - "type": "object" - } - }, - "required": [ - "run" - ], - "type": "object" - }, - "mute_all": { - "description": "Indicates whether all alerts are muted.", - "type": "boolean" - }, - "muted_alert_ids": { - "items": { - "description": "List of identifiers of muted alerts. ", - "type": "string" - }, - "type": "array" - }, - "name": { - "description": " The name of the rule.", - "type": "string" - }, - "next_run": { - "description": "Date and time of the next run of the rule.", - "nullable": true, - "type": "string" - }, - "notify_when": { - "description": "Indicates how often alerts generate actions. Valid values include: `onActionGroupChange`: Actions run when the alert status changes; `onActiveAlert`: Actions run when the alert becomes active and at each check interval while the rule conditions are met; `onThrottleInterval`: Actions run when the alert becomes active and at the interval specified in the throttle property while the rule conditions are met. NOTE: You cannot specify `notify_when` at both the rule and action level. The recommended method is to set it for each action. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "enum": [ - "onActionGroupChange", - "onActiveAlert", - "onThrottleInterval" - ], - "nullable": true, - "type": "string" - }, - "params": { - "additionalProperties": {}, - "description": "The parameters for the rule.", - "type": "object" - }, - "revision": { - "description": "The rule revision number.", - "type": "number" - }, - "rule_type_id": { - "description": "The rule type identifier.", - "type": "string" - }, - "running": { - "description": "Indicates whether the rule is running.", - "nullable": true, - "type": "boolean" - }, - "schedule": { - "additionalProperties": false, - "properties": { - "interval": { - "description": "The interval is specified in seconds, minutes, hours, or days.", - "type": "string" - } - }, - "required": [ - "interval" - ], - "type": "object" - }, - "scheduled_task_id": { - "description": "Identifier of the scheduled task.", - "type": "string" - }, - "snooze_schedule": { - "items": { - "additionalProperties": false, - "properties": { - "duration": { - "description": "Duration of the rule snooze schedule.", - "type": "number" - }, - "id": { - "description": "Identifier of the rule snooze schedule.", - "type": "string" - }, - "rRule": { - "additionalProperties": false, - "properties": { - "byhour": { - "items": { - "description": "Indicates hours of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "byminute": { - "items": { - "description": "Indicates minutes of the hour to recur.", - "type": "number" - }, - "type": "array" - }, - "bymonth": { - "items": { - "description": "Indicates months of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "bymonthday": { - "items": { - "description": "Indicates the days of the month to recur.", - "type": "number" - }, - "type": "array" - }, - "bysecond": { - "items": { - "description": "Indicates seconds of the day to recur.", - "type": "number" - }, - "type": "array" - }, - "bysetpos": { - "items": { - "description": "A positive or negative integer affecting the nth day of the month. For example, -2 combined with `byweekday` of FR is 2nd to last Friday of the month. It is recommended to not set this manually and just use `byweekday`.", - "type": "number" - }, - "type": "array" - }, - "byweekday": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ], - "description": "Indicates the days of the week to recur or else nth-day-of-month strings. For example, \"+2TU\" second Tuesday of month, \"-1FR\" last Friday of the month, which are internally converted to a `byweekday/bysetpos` combination." - }, - "type": "array" - }, - "byweekno": { - "items": { - "description": "Indicates number of the week hours to recur.", - "type": "number" - }, - "type": "array" - }, - "byyearday": { - "items": { - "description": "Indicates the days of the year that this rule should recur.", - "type": "number" - }, - "type": "array" - }, - "count": { - "description": "Number of times the rule should recur until it stops.", - "type": "number" - }, - "dtstart": { - "description": "Rule start date in Coordinated Universal Time (UTC).", - "type": "string" - }, - "freq": { - "description": "Indicates frequency of the rule. Options are YEARLY, MONTHLY, WEEKLY, DAILY.", - "enum": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ], - "type": "integer" - }, - "interval": { - "description": "Indicates the interval of frequency. For example, 1 and YEARLY is every 1 year, 2 and WEEKLY is every 2 weeks.", - "type": "number" - }, - "tzid": { - "description": "Indicates timezone abbreviation.", - "type": "string" - }, - "until": { - "description": "Recur the rule until this date.", - "type": "string" - }, - "wkst": { - "description": "Indicates the start of week, defaults to Monday.", - "enum": [ - "MO", - "TU", - "WE", - "TH", - "FR", - "SA", - "SU" - ], - "type": "string" - } - }, - "required": [ - "dtstart", - "tzid" - ], - "type": "object" - }, - "skipRecurrences": { - "items": { - "description": "Skips recurrence of rule on this date.", - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "duration", - "rRule" - ], - "type": "object" - }, - "type": "array" - }, - "tags": { - "items": { - "description": "The tags for the rule.", - "type": "string" - }, - "type": "array" - }, - "throttle": { - "deprecated": true, - "description": "Deprecated in 8.13.0. Use the `throttle` property in the action `frequency` object instead. The throttle interval, which defines how often an alert generates repeated actions. NOTE: You cannot specify the throttle interval at both the rule and action level. If you set it at the rule level then update the rule in Kibana, it is automatically changed to use action-specific values.", - "nullable": true, - "type": "string" - }, - "updated_at": { - "description": "The date and time that the rule was updated most recently.", - "type": "string" - }, - "updated_by": { - "description": "The identifier for the user that updated this rule most recently.", - "nullable": true, - "type": "string" - }, - "view_in_app_relative_url": { - "description": "Relative URL to view rule in the app.", - "nullable": true, - "type": "string" - } - }, - "required": [ - "id", - "enabled", - "name", - "tags", - "rule_type_id", - "consumer", - "schedule", - "actions", - "params", - "created_by", - "updated_by", - "created_at", - "updated_at", - "api_key_owner", - "mute_all", - "muted_alert_ids", - "execution_status", - "revision" - ], - "type": "object" - } - } - }, - "description": "Indicates a successful call." - } - }, - "summary": "Get information about rules", - "tags": [ - "alerting" - ] - } - }, "/api/status": { "get": { - "operationId": "%2Fapi%2Fstatus#0", + "operationId": "/api/status#0", "parameters": [ { "description": "The version of the API to use", @@ -5139,9 +435,6 @@ } ], "tags": [ - { - "name": "alerting" - }, { "name": "system" } diff --git a/packages/core/plugins/core-plugins-server-internal/src/create_browser_config.test.ts b/packages/core/plugins/core-plugins-server-internal/src/create_browser_config.test.ts index 11f55d1bc1edb..41da3f1ce2cef 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/create_browser_config.test.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/create_browser_config.test.ts @@ -69,7 +69,7 @@ describe('createBrowserConfig', () => { exposedConfigKeys: { exposed1: 'string', 'nested.exposed2': 'boolean', - 'nested.exposed3': 'number', + 'nested.exposed3': 'number?', // notExposed4 is not present }, }); @@ -182,7 +182,7 @@ describe('createBrowserConfig', () => { exposedConfigKeys: { exposed1: 'string', 'deeply.exposed2': 'boolean', - 'deeply.nested.exposed3': 'number', + 'deeply.nested.exposed3': 'number?', 'deeply.nested.structure.exposed4': 'string', // notExposed5, notExposed6, notExposed7, and notExposed8 are not present }, diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugins_service.test.ts b/packages/core/plugins/core-plugins-server-internal/src/plugins_service.test.ts index 076245a07b758..3320fe22d7d62 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugins_service.test.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugins_service.test.ts @@ -1046,7 +1046,7 @@ describe('PluginsService', () => { const prebootUIConfig$ = preboot.uiPlugins.browserConfigs.get('plugin-with-expose-preboot')!; await expect(prebootUIConfig$.pipe(take(1)).toPromise()).resolves.toEqual({ browserConfig: { sharedProp: 'sharedProp default value plugin-with-expose-preboot' }, - exposedConfigKeys: { sharedProp: 'string' }, + exposedConfigKeys: { sharedProp: 'string?' }, }); const standardUIConfig$ = standard.uiPlugins.browserConfigs.get( @@ -1054,7 +1054,7 @@ describe('PluginsService', () => { )!; await expect(standardUIConfig$.pipe(take(1)).toPromise()).resolves.toEqual({ browserConfig: { sharedProp: 'sharedProp default value plugin-with-expose-standard' }, - exposedConfigKeys: { sharedProp: 'string' }, + exposedConfigKeys: { sharedProp: 'string?' }, }); }); diff --git a/packages/kbn-config-schema/src/types/object_type.test.ts b/packages/kbn-config-schema/src/types/object_type.test.ts index d12688fa04099..d8828f566d007 100644 --- a/packages/kbn-config-schema/src/types/object_type.test.ts +++ b/packages/kbn-config-schema/src/types/object_type.test.ts @@ -8,7 +8,7 @@ import { get } from 'lodash'; import { expectType } from 'tsd'; -import { schema } from '../..'; +import { offeringBasedSchema, schema } from '../..'; import { TypeOf } from './object_type'; test('returns value by default', () => { @@ -682,6 +682,10 @@ test('returns schema structure', () => { boolean: schema.boolean(), buffer: schema.buffer(), byteSize: schema.byteSize(), + svlConditional: offeringBasedSchema({ + serverless: schema.literal('serverless'), + traditional: schema.literal('stateful'), + }), conditional: schema.conditional( schema.contextRef('context_value_1'), schema.contextRef('context_value_2'), @@ -699,8 +703,9 @@ test('returns schema structure', () => { record: schema.recordOf(schema.string(), schema.string()), stream: schema.stream(), string: schema.string(), - union: schema.oneOf([schema.string()]), + union: schema.oneOf([schema.string(), schema.number(), schema.boolean()]), uri: schema.uri(), + null: schema.literal(null), }); const type = objSchema.extends({ nested: objSchema, @@ -711,39 +716,43 @@ test('returns schema structure', () => { { path: ['boolean'], type: 'boolean' }, { path: ['buffer'], type: 'binary' }, { path: ['byteSize'], type: 'bytes' }, - { path: ['conditional'], type: 'any' }, + { path: ['svlConditional'], type: 'serverless|stateful' }, + { path: ['conditional'], type: 'string' }, { path: ['duration'], type: 'duration' }, { path: ['ip'], type: 'string' }, - { path: ['literal'], type: 'any' }, + { path: ['literal'], type: 'foo' }, { path: ['map'], type: 'map' }, - { path: ['maybe'], type: 'string' }, - { path: ['never'], type: 'any' }, - { path: ['nullable'], type: 'alternatives' }, + { path: ['maybe'], type: 'string?' }, + { path: ['never'], type: 'never' }, + { path: ['nullable'], type: 'string?|null' }, { path: ['number'], type: 'number' }, { path: ['record'], type: 'record' }, { path: ['stream'], type: 'stream' }, { path: ['string'], type: 'string' }, - { path: ['union'], type: 'alternatives' }, + { path: ['union'], type: 'string|number|boolean' }, { path: ['uri'], type: 'string' }, + { path: ['null'], type: 'null' }, { path: ['nested', 'any'], type: 'any' }, { path: ['nested', 'array'], type: 'array' }, { path: ['nested', 'boolean'], type: 'boolean' }, { path: ['nested', 'buffer'], type: 'binary' }, { path: ['nested', 'byteSize'], type: 'bytes' }, - { path: ['nested', 'conditional'], type: 'any' }, + { path: ['nested', 'svlConditional'], type: 'serverless|stateful' }, + { path: ['nested', 'conditional'], type: 'string' }, { path: ['nested', 'duration'], type: 'duration' }, { path: ['nested', 'ip'], type: 'string' }, - { path: ['nested', 'literal'], type: 'any' }, + { path: ['nested', 'literal'], type: 'foo' }, { path: ['nested', 'map'], type: 'map' }, - { path: ['nested', 'maybe'], type: 'string' }, - { path: ['nested', 'never'], type: 'any' }, - { path: ['nested', 'nullable'], type: 'alternatives' }, + { path: ['nested', 'maybe'], type: 'string?' }, + { path: ['nested', 'never'], type: 'never' }, + { path: ['nested', 'nullable'], type: 'string?|null' }, { path: ['nested', 'number'], type: 'number' }, { path: ['nested', 'record'], type: 'record' }, { path: ['nested', 'stream'], type: 'stream' }, { path: ['nested', 'string'], type: 'string' }, - { path: ['nested', 'union'], type: 'alternatives' }, + { path: ['nested', 'union'], type: 'string|number|boolean' }, { path: ['nested', 'uri'], type: 'string' }, + { path: ['nested', 'null'], type: 'null' }, ]); }); diff --git a/packages/kbn-config-schema/src/types/type.ts b/packages/kbn-config-schema/src/types/type.ts index d7e02e439ae3b..eee480723c623 100644 --- a/packages/kbn-config-schema/src/types/type.ts +++ b/packages/kbn-config-schema/src/types/type.ts @@ -6,7 +6,15 @@ * Side Public License, v 1. */ -import type { AnySchema, CustomValidator, ErrorReport } from 'joi'; +import { + isSchema, + type CustomValidator, + type ErrorReport, + type Schema, + type SchemaLike, + type WhenOptions, + CustomHelpers, +} from 'joi'; import { META_FIELD_X_OAS_DEPRECATED } from '../oas_meta_fields'; import { SchemaTypeError, ValidationError } from '../errors'; import { Reference } from '../references'; @@ -91,9 +99,9 @@ export abstract class Type { * Internal "schema" backed by Joi. * @type {Schema} */ - protected readonly internalSchema: AnySchema; + protected readonly internalSchema: Schema; - protected constructor(schema: AnySchema, options: TypeOptions = {}) { + protected constructor(schema: Schema, options: TypeOptions = {}) { if (options.defaultValue !== undefined) { schema = schema.optional(); @@ -214,7 +222,7 @@ export abstract class Type { } } -function recursiveGetSchemaStructure(internalSchema: AnySchema, path: string[] = []) { +function recursiveGetSchemaStructure(internalSchema: Schema, path: string[] = []) { const array: SchemaStructureEntry[] = []; // Note: we are relying on Joi internals to obtain the schema structure (recursive keys). // This is not ideal, but it works for now and we only need it for some integration test assertions. @@ -222,8 +230,69 @@ function recursiveGetSchemaStructure(internalSchema: AnySchema, path: string[] = for (const [key, val] of (internalSchema as any)._ids._byKey.entries()) { array.push(...recursiveGetSchemaStructure(val.schema, [...path, key])); } + if (!array.length) { - array.push({ path, type: internalSchema.type ?? 'unknown' }); + let type: string; + try { + type = prettyPrintType(internalSchema, path); + } catch (error) { + // failed to find special type, might need to update for new joi versions or type usages + type = internalSchema.type || 'unknown'; + } + + array.push({ + path, + type, + }); } return array; } + +/** + * Returns a more accurate type from complex schema definitions. + * + * For example, conditional values resolve to type `any` when the nested value is only ever a `string`. + * + * @param internalSchema + * @param path of current schema + * @returns schema type + */ +function prettyPrintType(schema?: SchemaLike, path: string[] = []): string { + // takes array of possible values and de-dups and joins + return [...new Set([prettyPrintTypeParts(schema, false, path)].flat())].filter(Boolean).join('|'); +} + +/** + * Recursively collects all possible nested schema types. + */ +function prettyPrintTypeParts( + schema?: SchemaLike, + optional = false, + path: string[] = [] +): string | string[] { + if (!isSchema(schema)) { + if (schema === null) return 'null'; + return `${schema ?? 'unknown'}${optional ? '?' : ''}`; + } + + const isOptionalType = optional || schema._flags?.presence === 'optional'; + // For explicit custom schema.never + if (schema._flags?.presence === 'forbidden') return 'never'; + // For offeringBasedSchema, schema.when, schema.conditional + if (schema.$_terms?.whens?.length > 0) + return (schema.$_terms.whens as WhenOptions[]).flatMap((when) => + [when?.then, when?.otherwise].flatMap((s) => prettyPrintTypeParts(s, isOptionalType, path)) + ); + // schema.oneOf, schema.allOf, etc. + if (schema.$_terms?.matches?.length > 0) + return (schema.$_terms.matches as CustomHelpers[]).flatMap((s) => + prettyPrintTypeParts(s.schema, isOptionalType, path) + ); + // schema.literal + if (schema._flags?.only && (schema as any)._valids?._values?.size > 0) + return [...(schema as any)._valids._values.keys()].flatMap((v) => + prettyPrintTypeParts(v, isOptionalType, path) + ); + + return `${schema?.type || 'unknown'}${isOptionalType ? '?' : ''}`; +} diff --git a/packages/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap b/packages/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap index a3c634f582d43..3e16455f5006e 100644 --- a/packages/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap +++ b/packages/kbn-router-to-openapispec/src/__snapshots__/generate_oas.test.ts.snap @@ -44,7 +44,7 @@ Object { "paths": Object { "/foo/{id}": Object { "get": Object { - "operationId": "%2Ffoo%2F%7Bid%7D#0", + "operationId": "/foo/{id}#0", "parameters": Array [ Object { "description": "The version of the API to use", @@ -138,7 +138,7 @@ Object { "/bar": Object { "get": Object { "deprecated": true, - "operationId": "%2Fbar#0", + "operationId": "/bar#0", "parameters": Array [ Object { "description": "The version of the API to use", @@ -229,7 +229,7 @@ OK response oas-test-version-2", "/foo/{id}/{path*}": Object { "delete": Object { "description": "route description", - "operationId": "%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#2", + "operationId": "/foo/{id}/{path*}#2", "parameters": Array [ Object { "description": "The version of the API to use", @@ -267,7 +267,7 @@ OK response oas-test-version-2", }, "get": Object { "description": "route description", - "operationId": "%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#0", + "operationId": "/foo/{id}/{path*}#0", "parameters": Array [ Object { "description": "The version of the API to use", @@ -413,7 +413,7 @@ OK response oas-test-version-2", }, "post": Object { "description": "route description", - "operationId": "%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#1", + "operationId": "/foo/{id}/{path*}#1", "parameters": Array [ Object { "description": "The version of the API to use", @@ -570,7 +570,7 @@ OK response oas-test-version-2", }, "/no-xsrf/{id}/{path*}": Object { "post": Object { - "operationId": "%2Fno-xsrf%2F%7Bid%7D%2F%7Bpath*%7D#1", + "operationId": "/no-xsrf/{id}/{path*}#1", "parameters": Array [ Object { "description": "The version of the API to use", @@ -721,7 +721,7 @@ Object { "paths": Object { "/recursive": Object { "get": Object { - "operationId": "%2Frecursive#0", + "operationId": "/recursive#0", "parameters": Array [ Object { "description": "The version of the API to use", @@ -804,7 +804,7 @@ Object { "paths": Object { "/foo/{id}": Object { "get": Object { - "operationId": "%2Ffoo%2F%7Bid%7D#0", + "operationId": "/foo/{id}#0", "parameters": Array [ Object { "description": "The version of the API to use", @@ -842,7 +842,7 @@ Object { }, "/test": Object { "get": Object { - "operationId": "%2Ftest#0", + "operationId": "/test#0", "parameters": Array [ Object { "description": "The version of the API to use", diff --git a/packages/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts b/packages/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts index 760deff020022..09bb6064c2bcb 100644 --- a/packages/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts +++ b/packages/kbn-router-to-openapispec/src/generate_oas.test.fixture.ts @@ -33,7 +33,7 @@ export const sharedOas = { '/bar': { get: { deprecated: true, - operationId: '%2Fbar#0', + operationId: '/bar#0', parameters: [ { description: 'The version of the API to use', @@ -152,7 +152,7 @@ export const sharedOas = { '/foo/{id}/{path*}': { get: { description: 'route description', - operationId: '%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#0', + operationId: '/foo/{id}/{path*}#0', parameters: [ { description: 'The version of the API to use', @@ -276,7 +276,7 @@ export const sharedOas = { }, post: { description: 'route description', - operationId: '%2Ffoo%2F%7Bid%7D%2F%7Bpath*%7D#1', + operationId: '/foo/{id}/{path*}#1', parameters: [ { description: 'The version of the API to use', diff --git a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.test.ts b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.test.ts index 71f3ff1eeca70..5c783e739d045 100644 --- a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.test.ts +++ b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.test.ts @@ -110,39 +110,6 @@ describe('processEnum', () => { ], }, }, - { - name: 'correctly transforms schema.nullable inputs', - input: { - anyOf: [ - { - description: 'test', - type: 'object', - properties: { - test: { - type: 'string', - }, - }, - required: ['test'], - }, - { - enum: [], - nullable: true, - type: undefined, - }, - ], - } as OpenAPIV3.SchemaObject, - expected: { - description: 'test', - type: 'object', - properties: { - test: { - type: 'string', - }, - }, - required: ['test'], - nullable: true, - }, - }, ])('$name', ({ input, expected }) => { processEnum(input); expect(input).toEqual(expected); diff --git a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.ts b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.ts index fb2e3856ae495..7bbb7ae2c26d0 100644 --- a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.ts +++ b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/enum.ts @@ -9,38 +9,8 @@ import type { OpenAPIV3 } from 'openapi-types'; import { isReferenceObject } from '../../../common'; -/** Identify special case output of schema.nullable() */ -const isNullableOutput = (schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject) => { - return ( - !isReferenceObject(schema) && - Object.keys(schema).length === 3 && - schema.enum?.length === 0 && - schema.nullable === true && - schema.type === undefined - ); -}; - -/** - * Handle special case output of schema.nullable() - * - * We go from: - * { anyOf: [ { type: 'string' }, { nullable: true, enum: [] } ] } - * - * To: - * { type: 'string', nullable: true } - */ -const processNullableOutput = (schema: OpenAPIV3.SchemaObject) => { - if (schema.anyOf!.length !== 2) return false; - const idx = schema.anyOf!.findIndex((item) => isNullableOutput(item)); - if (idx === -1) return false; - const anyOf = schema.anyOf!; - delete schema.anyOf; - schema.nullable = true; - Object.assign(schema, anyOf[1 - idx]); - return true; -}; - -const prettifyEnum = (schema: OpenAPIV3.SchemaObject) => { +export const processEnum = (schema: OpenAPIV3.SchemaObject) => { + if (!schema.anyOf) return; const result: unknown[] = []; let type: OpenAPIV3.SchemaObject['type']; for (const item of schema.anyOf!) { @@ -54,9 +24,3 @@ const prettifyEnum = (schema: OpenAPIV3.SchemaObject) => { schema.enum = result; delete schema.anyOf; }; - -export const processEnum = (schema: OpenAPIV3.SchemaObject) => { - if (!schema.anyOf) return; - if (processNullableOutput(schema)) return; - prettifyEnum(schema); -}; diff --git a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.test.ts b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.test.ts index ae257aaec1edf..fd7b127ef8726 100644 --- a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.test.ts +++ b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.test.ts @@ -11,10 +11,13 @@ import { joi2JsonInternal } from '../../parse'; import { processObject } from './object'; test.each([ - [schema.object({}), { type: 'object', properties: {}, additionalProperties: false }], + [ + schema.object({}), + { type: 'object', properties: {}, additionalProperties: false, required: [] }, + ], [ schema.object({ never: schema.never() }), - { type: 'object', properties: {}, additionalProperties: false }, + { type: 'object', properties: {}, additionalProperties: false, required: [] }, ], [ schema.object( diff --git a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.ts b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.ts index 0b21134061c78..ec5888f986bd6 100644 --- a/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.ts +++ b/packages/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/post_process_mutations/mutations/object.ts @@ -38,7 +38,7 @@ const populateRequiredFields = (schema: OpenAPIV3.SchemaObject): void => { } } - if (required.length > 0) schema.required = required; + schema.required = required; }; const removeNeverType = (schema: OpenAPIV3.SchemaObject): void => { diff --git a/packages/kbn-router-to-openapispec/src/operation_id_counter.test.ts b/packages/kbn-router-to-openapispec/src/operation_id_counter.test.ts deleted file mode 100644 index 270b6b6e2c982..0000000000000 --- a/packages/kbn-router-to-openapispec/src/operation_id_counter.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { createOperationIdCounter } from './operation_id_counter'; - -test('empty case', () => { - const opIdCounter = createOperationIdCounter(); - expect(opIdCounter('')).toBe('#0'); -}); - -test('other cases', () => { - const opIdCounter = createOperationIdCounter(); - const tests = [ - ['/', '%2F#0'], - ['/api/cool', '%2Fapi%2Fcool#0'], - ['/api/cool', '%2Fapi%2Fcool#1'], - ['/api/cool', '%2Fapi%2Fcool#2'], - ['/api/cool/{variable}', '%2Fapi%2Fcool%2F%7Bvariable%7D#0'], - ['/api/cool/{optionalVariable?}', '%2Fapi%2Fcool%2F%7BoptionalVariable%3F%7D#0'], - ['/api/cool/{optionalVariable?}', '%2Fapi%2Fcool%2F%7BoptionalVariable%3F%7D#1'], - ]; - - tests.forEach(([input, expected]) => { - expect(opIdCounter(input)).toBe(expected); - }); -}); diff --git a/packages/kbn-router-to-openapispec/src/operation_id_counter.ts b/packages/kbn-router-to-openapispec/src/operation_id_counter.ts index 0842ec88d094f..91fe2adf395d8 100644 --- a/packages/kbn-router-to-openapispec/src/operation_id_counter.ts +++ b/packages/kbn-router-to-openapispec/src/operation_id_counter.ts @@ -11,7 +11,6 @@ export type OperationIdCounter = (name: string) => string; export const createOperationIdCounter = () => { const operationIdCounters = new Map(); return (name: string): string => { - name = encodeURIComponent(name); // Aliases an operationId to ensure it is unique across // multiple method+path combinations sharing a name. // "search" -> "search#0", "search#1", etc. diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index ba6ff39066939..a2e957f96d934 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -100,211 +100,209 @@ export default function ({ getService }: PluginFunctionalProviderContext) { // what types of config settings can be exposed to the browser. // When plugin owners make a change that exposes additional config values, the changes will be reflected in this test assertion. // Ensure that your change does not unintentionally expose any sensitive values! - 'console.autocompleteDefinitions.endpointsAvailability (alternatives)', - 'console.dev.enableMonaco (boolean)', - 'console.ui.enabled (boolean)', - 'console.ui.embeddedEnabled (boolean)', - 'dashboard.allowByValueEmbeddables (boolean)', - 'unifiedSearch.autocomplete.querySuggestions.enabled (boolean)', - 'unifiedSearch.autocomplete.valueSuggestions.enabled (boolean)', - 'unifiedSearch.autocomplete.valueSuggestions.terminateAfter (duration)', - 'unifiedSearch.autocomplete.valueSuggestions.tiers (array)', - 'unifiedSearch.autocomplete.valueSuggestions.timeout (duration)', - 'data.search.aggs.shardDelay.enabled (boolean)', - 'data.search.asyncSearch.batchedReduceSize (number)', - 'data.search.asyncSearch.keepAlive (duration)', - 'data.search.asyncSearch.waitForCompletion (duration)', - 'data.search.asyncSearch.pollInterval (number)', - 'data.search.sessions.defaultExpiration (duration)', - 'data.search.sessions.enabled (boolean)', - 'data.search.sessions.management.expiresSoonWarning (duration)', - 'data.search.sessions.management.maxSessions (number)', - 'data.search.sessions.management.refreshInterval (duration)', - 'data.search.sessions.management.refreshTimeout (duration)', - 'data.search.sessions.maxUpdateRetries (number)', - 'data.search.sessions.notTouchedTimeout (duration)', - 'data_views.scriptedFieldsEnabled (any)', // It's a boolean (any because schema.conditional) + 'console.autocompleteDefinitions.endpointsAvailability (stack?|serverless?)', + 'console.dev.enableMonaco (boolean?)', + 'console.ui.enabled (boolean?)', + 'console.ui.embeddedEnabled (boolean?)', + 'dashboard.allowByValueEmbeddables (boolean?)', + 'unifiedSearch.autocomplete.querySuggestions.enabled (boolean?)', + 'unifiedSearch.autocomplete.valueSuggestions.enabled (boolean?)', + 'unifiedSearch.autocomplete.valueSuggestions.terminateAfter (duration?)', + 'unifiedSearch.autocomplete.valueSuggestions.tiers (array?)', + 'unifiedSearch.autocomplete.valueSuggestions.timeout (duration?)', + 'data.search.aggs.shardDelay.enabled (boolean?)', + 'data.search.asyncSearch.batchedReduceSize (number?)', + 'data.search.asyncSearch.keepAlive (duration?)', + 'data.search.asyncSearch.waitForCompletion (duration?)', + 'data.search.asyncSearch.pollInterval (number?)', + 'data.search.sessions.defaultExpiration (duration?)', + 'data.search.sessions.enabled (boolean?)', + 'data.search.sessions.management.expiresSoonWarning (duration?)', + 'data.search.sessions.management.maxSessions (number?)', + 'data.search.sessions.management.refreshInterval (duration?)', + 'data.search.sessions.management.refreshTimeout (duration?)', + 'data.search.sessions.maxUpdateRetries (number?)', + 'data.search.sessions.notTouchedTimeout (duration?)', + 'data_views.scriptedFieldsEnabled (boolean?|never)', 'data_visualizer.resultLinks.fileBeat.enabled (boolean)', - 'dev_tools.deeplinks.navLinkStatus (string)', - 'discover.experimental.enabledProfiles (array)', - 'enterpriseSearch.canDeployEntSearch (boolean)', - 'enterpriseSearch.host (string)', - 'enterpriseSearch.ui.enabled (boolean)', - 'home.disableWelcomeScreen (boolean)', - 'management.deeplinks.navLinkStatus (string)', - 'map.emsFileApiUrl (string)', - 'map.emsFontLibraryUrl (string)', - 'map.emsLandingPageUrl (string)', - 'map.emsTileApiUrl (string)', - 'map.emsTileLayerId.bright (string)', - 'map.emsTileLayerId.dark (string)', - 'map.emsTileLayerId.desaturated (string)', - 'map.emsUrl (string)', - 'map.includeElasticMapsService (boolean)', - 'map.tilemap.options.attribution (string)', - 'map.tilemap.options.bounds (array)', - 'map.tilemap.options.default (boolean)', - 'map.tilemap.options.errorTileUrl (string)', - 'map.tilemap.options.maxZoom (number)', - 'map.tilemap.options.minZoom (number)', - 'map.tilemap.options.reuseTiles (boolean)', - 'map.tilemap.options.subdomains (array)', - 'map.tilemap.options.tileSize (number)', - 'map.tilemap.options.tms (boolean)', - 'map.tilemap.url (string)', - 'monitoring.kibana.collection.enabled (boolean)', - 'monitoring.kibana.collection.interval (number)', - 'monitoring.ui.ccs.enabled (boolean)', - 'monitoring.ui.kibana.reporting.stale_status_threshold_seconds (number)', - 'monitoring.ui.container.apm.enabled (boolean)', - 'monitoring.ui.container.elasticsearch.enabled (boolean)', - 'monitoring.ui.container.logstash.enabled (boolean)', - 'monitoring.ui.enabled (boolean)', - 'monitoring.ui.min_interval_seconds (number)', - 'monitoring.ui.show_license_expiration (boolean)', - 'newsfeed.fetchInterval (duration)', - 'newsfeed.mainInterval (duration)', - 'newsfeed.service.pathTemplate (string)', - 'newsfeed.service.urlRoot (string)', - 'no_data_page.analyticsNoDataPageFlavor (any)', // It's a string (any because schema.conditional) - 'telemetry.allowChangingOptInStatus (boolean)', - 'telemetry.appendServerlessChannelsSuffix (any)', // It's a boolean (any because schema.conditional) - 'telemetry.banner (boolean)', - 'telemetry.labels.branch (string)', - 'telemetry.labels.ciBuildId (string)', - 'telemetry.labels.ciBuildJobId (string)', - 'telemetry.labels.ciBuildNumber (number)', - 'telemetry.labels.environment (string)', - 'telemetry.labels.ftrConfig (string)', - 'telemetry.labels.gitRev (string)', - 'telemetry.labels.isPr (boolean)', - 'telemetry.labels.journeyName (string)', - 'telemetry.labels.prId (number)', - 'telemetry.labels.testBuildId (string)', - 'telemetry.labels.testJobId (string)', - 'telemetry.labels.ciBuildName (string)', - 'telemetry.labels.performancePhase (string)', - 'telemetry.labels.serverless (any)', // It's the project type (string), claims any because schema.conditional. Can only be set on Serverless. - 'telemetry.hidePrivacyStatement (boolean)', - 'telemetry.optIn (boolean)', - 'telemetry.sendUsageFrom (alternatives)', - 'telemetry.sendUsageTo (any)', - 'usageCollection.uiCounters.debug (boolean)', - 'usageCollection.uiCounters.enabled (boolean)', - // readOnly is boolean flag - 'input_control_vis.readOnly (any)', - 'vis_type_gauge.readOnly (any)', - 'vis_type_heatmap.readOnly (any)', - 'vis_type_metric.readOnly (any)', - 'vis_type_pie.readOnly (any)', - 'vis_type_table.readOnly (any)', - 'vis_type_tagcloud.readOnly (any)', - 'vis_type_timelion.readOnly (any)', - 'vis_type_timeseries.readOnly (any)', - 'vis_type_vislib.readOnly (any)', - 'vis_type_xy.readOnly (any)', - 'vis_type_vega.enableExternalUrls (boolean)', + 'dev_tools.deeplinks.navLinkStatus (string?)', + 'discover.experimental.enabledProfiles (array?)', + 'enterpriseSearch.canDeployEntSearch (boolean?)', + 'enterpriseSearch.host (string?)', + 'enterpriseSearch.ui.enabled (boolean?)', + 'home.disableWelcomeScreen (boolean?)', + 'management.deeplinks.navLinkStatus (string?)', + 'map.emsFileApiUrl (string?)', + 'map.emsFontLibraryUrl (string?)', + 'map.emsLandingPageUrl (string?)', + 'map.emsTileApiUrl (string?)', + 'map.emsTileLayerId.bright (string?)', + 'map.emsTileLayerId.dark (string?)', + 'map.emsTileLayerId.desaturated (string?)', + 'map.emsUrl (string?)', + 'map.includeElasticMapsService (boolean?)', + 'map.tilemap.options.attribution (string?)', + 'map.tilemap.options.bounds (array?)', + 'map.tilemap.options.default (boolean?)', + 'map.tilemap.options.errorTileUrl (string?)', + 'map.tilemap.options.maxZoom (number?)', + 'map.tilemap.options.minZoom (number?)', + 'map.tilemap.options.reuseTiles (boolean?)', + 'map.tilemap.options.subdomains (array?)', + 'map.tilemap.options.tileSize (number?)', + 'map.tilemap.options.tms (boolean?)', + 'map.tilemap.url (string?)', + 'monitoring.kibana.collection.enabled (boolean?)', + 'monitoring.kibana.collection.interval (number?)', + 'monitoring.ui.ccs.enabled (boolean?)', + 'monitoring.ui.kibana.reporting.stale_status_threshold_seconds (number?)', + 'monitoring.ui.container.apm.enabled (boolean?)', + 'monitoring.ui.container.elasticsearch.enabled (boolean?)', + 'monitoring.ui.container.logstash.enabled (boolean?)', + 'monitoring.ui.enabled (boolean?)', + 'monitoring.ui.min_interval_seconds (number?)', + 'monitoring.ui.show_license_expiration (boolean?)', + 'newsfeed.fetchInterval (duration?)', + 'newsfeed.mainInterval (duration?)', + 'newsfeed.service.pathTemplate (string?)', + 'newsfeed.service.urlRoot (string?)', + 'no_data_page.analyticsNoDataPageFlavor (kibana?|serverless_search?|serverless_observability?|never)', + 'telemetry.allowChangingOptInStatus (boolean?)', + 'telemetry.appendServerlessChannelsSuffix (true?|false?)', + 'telemetry.banner (boolean?)', + 'telemetry.labels.branch (string?)', + 'telemetry.labels.ciBuildId (string?)', + 'telemetry.labels.ciBuildJobId (string?)', + 'telemetry.labels.ciBuildNumber (number?)', + 'telemetry.labels.environment (string?)', + 'telemetry.labels.ftrConfig (string?)', + 'telemetry.labels.gitRev (string?)', + 'telemetry.labels.isPr (boolean?)', + 'telemetry.labels.journeyName (string?)', + 'telemetry.labels.prId (number?)', + 'telemetry.labels.testBuildId (string?)', + 'telemetry.labels.testJobId (string?)', + 'telemetry.labels.ciBuildName (string?)', + 'telemetry.labels.performancePhase (string?)', + 'telemetry.labels.serverless (string?|never)', // Can only be set on Serverless. + 'telemetry.hidePrivacyStatement (boolean?)', + 'telemetry.optIn (boolean?)', + 'telemetry.sendUsageFrom (server?|browser?)', + 'telemetry.sendUsageTo (prod?|staging?)', + 'usageCollection.uiCounters.debug (boolean?)', + 'usageCollection.uiCounters.enabled (boolean?)', + 'input_control_vis.readOnly (boolean?|never)', + 'vis_type_gauge.readOnly (boolean?|never)', + 'vis_type_heatmap.readOnly (boolean?|never)', + 'vis_type_metric.readOnly (boolean?|never)', + 'vis_type_pie.readOnly (boolean?|never)', + 'vis_type_table.readOnly (boolean?|never)', + 'vis_type_tagcloud.readOnly (boolean?|never)', + 'vis_type_timelion.readOnly (boolean?|never)', + 'vis_type_timeseries.readOnly (boolean?|never)', + 'vis_type_vislib.readOnly (boolean?|never)', + 'vis_type_xy.readOnly (boolean?|never)', + 'vis_type_vega.enableExternalUrls (boolean?)', 'xpack.actions.email.domain_allowlist (array)', - 'xpack.apm.serviceMapEnabled (boolean)', - 'xpack.apm.ui.enabled (boolean)', - 'xpack.apm.ui.maxTraceItems (number)', - 'xpack.apm.managedServiceUrl (any)', - 'xpack.apm.serverlessOnboarding (any)', - 'xpack.apm.latestAgentVersionsUrl (string)', - 'xpack.apm.featureFlags.agentConfigurationAvailable (any)', - 'xpack.apm.featureFlags.configurableIndicesAvailable (any)', - 'xpack.apm.featureFlags.infrastructureTabAvailable (any)', - 'xpack.apm.featureFlags.infraUiAvailable (any)', - 'xpack.apm.featureFlags.migrationToFleetAvailable (any)', - 'xpack.apm.featureFlags.sourcemapApiAvailable (any)', - 'xpack.apm.featureFlags.storageExplorerAvailable (any)', - 'xpack.apm.featureFlags.profilingIntegrationAvailable (boolean)', - 'xpack.apm.serverless.enabled (any)', // It's a boolean (any because schema.conditional) - 'xpack.observability_onboarding.serverless.enabled (any)', // It's a boolean (any because schema.conditional) - 'xpack.cases.files.allowedMimeTypes (array)', - 'xpack.cases.files.maxSize (number)', - 'xpack.cases.markdownPlugins.lens (boolean)', - 'xpack.cases.stack.enabled (boolean)', - 'xpack.ccr.ui.enabled (boolean)', - 'xpack.cloud.base_url (string)', - 'xpack.cloud.cname (string)', - 'xpack.cloud.deployment_url (string)', - 'xpack.cloud.deployments_url (string)', - 'xpack.cloud.is_elastic_staff_owned (boolean)', - 'xpack.cloud.trial_end_date (string)', - 'xpack.cloud_integrations.chat.chatURL (string)', - 'xpack.cloud_integrations.chat.trialBuffer (number)', + 'xpack.apm.serviceMapEnabled (boolean?)', + 'xpack.apm.ui.enabled (boolean?)', + 'xpack.apm.ui.maxTraceItems (number?)', + 'xpack.apm.managedServiceUrl (string?|never)', + 'xpack.apm.serverlessOnboarding (boolean?|never)', + 'xpack.apm.latestAgentVersionsUrl (string?)', + 'xpack.apm.featureFlags.agentConfigurationAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.configurableIndicesAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.infrastructureTabAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.infraUiAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.migrationToFleetAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.sourcemapApiAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.storageExplorerAvailable (boolean?|true?)', + 'xpack.apm.featureFlags.profilingIntegrationAvailable (boolean?)', + 'xpack.apm.serverless.enabled (true?|never)', + 'xpack.observability_onboarding.serverless.enabled (true?|never)', + 'xpack.cases.files.allowedMimeTypes (array?)', + 'xpack.cases.files.maxSize (number?)', + 'xpack.cases.markdownPlugins.lens (boolean?)', + 'xpack.cases.stack.enabled (boolean?)', + 'xpack.ccr.ui.enabled (boolean?)', + 'xpack.cloud.base_url (string?)', + 'xpack.cloud.cname (string?)', + 'xpack.cloud.deployment_url (string?)', + 'xpack.cloud.deployments_url (string?)', + 'xpack.cloud.is_elastic_staff_owned (boolean?)', + 'xpack.cloud.trial_end_date (string?)', + 'xpack.cloud_integrations.chat.chatURL (string?)', + 'xpack.cloud_integrations.chat.trialBuffer (number?)', // No PII. This is an escape patch to override LaunchDarkly's flag resolution mechanism for testing or quick fix. - 'xpack.cloud_integrations.experiments.flag_overrides (record)', + 'xpack.cloud_integrations.experiments.flag_overrides (record?)', // Commented because it's inside a schema conditional, and the test is not able to resolve it. But it's shared. // Added here for documentation purposes. // 'xpack.cloud_integrations.experiments.launch_darkly.client_id (string)', // 'xpack.cloud_integrations.experiments.launch_darkly.client_log_level (string)', - 'xpack.cloud_integrations.experiments.metadata_refresh_interval (duration)', - 'xpack.cloud_integrations.full_story.org_id (any)', + 'xpack.cloud_integrations.experiments.metadata_refresh_interval (duration?)', + 'xpack.cloud_integrations.full_story.org_id (string|string?)', // No PII. Just the list of event types we want to forward to FullStory. - 'xpack.cloud_integrations.full_story.eventTypesAllowlist (array)', - 'xpack.cloud_integrations.full_story.pageVarsDebounceTime (duration)', - 'xpack.cloud.id (string)', - 'xpack.cloud.organization_id (string)', - 'xpack.cloud.organization_url (string)', - 'xpack.cloud.billing_url (string)', - 'xpack.cloud.profile_url (string)', - 'xpack.cloud.performance_url (string)', - 'xpack.cloud.users_and_roles_url (string)', - 'xpack.cloud.projects_url (any)', // It's a string (any because schema.conditional) + 'xpack.cloud_integrations.full_story.eventTypesAllowlist (array?)', + 'xpack.cloud_integrations.full_story.pageVarsDebounceTime (duration?)', + 'xpack.cloud.id (string?)', + 'xpack.cloud.organization_id (string?)', + 'xpack.cloud.organization_url (string?)', + 'xpack.cloud.billing_url (string?)', + 'xpack.cloud.profile_url (string?)', + 'xpack.cloud.performance_url (string?)', + 'xpack.cloud.users_and_roles_url (string?)', + 'xpack.cloud.projects_url (string?|never)', // can't be used to infer urls or customer id from the outside - 'xpack.cloud.serverless.project_id (string)', - 'xpack.cloud.serverless.project_name (string)', - 'xpack.cloud.serverless.project_type (string)', - 'xpack.cloud.serverless.orchestrator_target (string)', - 'xpack.cloud.onboarding.default_solution (string)', - 'xpack.discoverEnhanced.actions.exploreDataInChart.enabled (boolean)', - 'xpack.discoverEnhanced.actions.exploreDataInContextMenu.enabled (boolean)', - 'xpack.fleet.agents.enabled (boolean)', + 'xpack.cloud.serverless.project_id (string?)', + 'xpack.cloud.serverless.project_name (string?)', + 'xpack.cloud.serverless.project_type (string?)', + 'xpack.cloud.serverless.orchestrator_target (string?)', + 'xpack.cloud.onboarding.default_solution (string?)', + 'xpack.discoverEnhanced.actions.exploreDataInChart.enabled (boolean?)', + 'xpack.discoverEnhanced.actions.exploreDataInContextMenu.enabled (boolean?)', + 'xpack.fleet.agents.enabled (boolean?)', 'xpack.fleet.agentless.api.url (string)', - 'xpack.fleet.enableExperimental (array)', - 'xpack.fleet.internal.activeAgentsSoftLimit (number)', - 'xpack.fleet.internal.fleetServerStandalone (boolean)', - 'xpack.fleet.internal.onlyAllowAgentUpgradeToKnownVersions (boolean)', - 'xpack.fleet.developer.maxAgentPoliciesWithInactivityTimeout (number)', - 'xpack.global_search.search_timeout (duration)', - 'xpack.global_search_bar.input_max_limit (number)', - 'xpack.graph.canEditDrillDownUrls (boolean)', - 'xpack.graph.savePolicy (alternatives)', - 'xpack.ilm.ui.enabled (boolean)', - 'xpack.index_management.ui.enabled (boolean)', - 'xpack.infra.sources.default.fields.message (array)', - 'xpack.index_management.enableTogglingDataRetention (any)', // It's a boolean (any because schema.conditional) + 'xpack.fleet.enableExperimental (array?)', + 'xpack.fleet.internal.activeAgentsSoftLimit (number?)', + 'xpack.fleet.internal.fleetServerStandalone (boolean?)', + 'xpack.fleet.internal.onlyAllowAgentUpgradeToKnownVersions (boolean?)', + 'xpack.fleet.developer.maxAgentPoliciesWithInactivityTimeout (number?)', + 'xpack.global_search.search_timeout (duration?)', + 'xpack.global_search_bar.input_max_limit (number?)', + 'xpack.graph.canEditDrillDownUrls (boolean?)', + 'xpack.graph.savePolicy (none?|config?|configAndData?|configAndDataWithConsent?)', + 'xpack.ilm.ui.enabled (boolean?)', + 'xpack.index_management.ui.enabled (boolean?)', + 'xpack.infra.sources.default.fields.message (array?)', + 'xpack.index_management.enableTogglingDataRetention (boolean?|never)', /** * Feature flags bellow are conditional based on traditional/serverless offering - * and will all resolve to xpack.infra.featureFlags.* (boolean) */ - 'xpack.infra.featureFlags.metricsExplorerEnabled (any)', - 'xpack.infra.featureFlags.customThresholdAlertsEnabled (any)', - 'xpack.infra.featureFlags.osqueryEnabled (boolean)', - 'xpack.infra.featureFlags.inventoryThresholdAlertRuleEnabled (any)', - 'xpack.infra.featureFlags.metricThresholdAlertRuleEnabled (any)', - 'xpack.infra.featureFlags.logThresholdAlertRuleEnabled (any)', - 'xpack.infra.featureFlags.logsUIEnabled (any)', - 'xpack.infra.featureFlags.alertsAndRulesDropdownEnabled (any)', - 'xpack.infra.featureFlags.profilingEnabled (boolean)', - - 'xpack.index_management.enableIndexActions (any)', - 'xpack.index_management.enableLegacyTemplates (any)', - 'xpack.index_management.enableIndexStats (any)', - 'xpack.index_management.enableDataStreamStats (any)', - 'xpack.index_management.editableIndexSettings (any)', - 'xpack.index_management.enableMappingsSourceFieldSection (any)', - 'xpack.index_management.dev.enableSemanticText (boolean)', - 'xpack.license_management.ui.enabled (boolean)', - 'xpack.maps.preserveDrawingBuffer (boolean)', - 'xpack.maps.showMapsInspectorAdapter (boolean)', + 'xpack.infra.featureFlags.metricsExplorerEnabled (boolean?)', + 'xpack.infra.featureFlags.customThresholdAlertsEnabled (boolean?)', + 'xpack.infra.featureFlags.osqueryEnabled (boolean?)', + 'xpack.infra.featureFlags.inventoryThresholdAlertRuleEnabled (boolean?)', + 'xpack.infra.featureFlags.metricThresholdAlertRuleEnabled (boolean?)', + 'xpack.infra.featureFlags.logThresholdAlertRuleEnabled (boolean?)', + 'xpack.infra.featureFlags.logsUIEnabled (boolean?)', + 'xpack.infra.featureFlags.alertsAndRulesDropdownEnabled (boolean?)', + 'xpack.infra.featureFlags.profilingEnabled (boolean?)', + + 'xpack.index_management.enableIndexActions (boolean?|never)', + 'xpack.index_management.enableLegacyTemplates (boolean?|never)', + 'xpack.index_management.enableIndexStats (boolean?|never)', + 'xpack.index_management.enableDataStreamStats (boolean?|never)', + 'xpack.index_management.editableIndexSettings (all?|limited?|never)', + 'xpack.index_management.enableMappingsSourceFieldSection (boolean?|never)', + 'xpack.index_management.dev.enableSemanticText (boolean?)', + 'xpack.license_management.ui.enabled (boolean?)', + 'xpack.maps.preserveDrawingBuffer (boolean?)', + 'xpack.maps.showMapsInspectorAdapter (boolean?)', 'xpack.ml.ad.enabled (boolean)', 'xpack.ml.dfa.enabled (boolean)', 'xpack.ml.nlp.enabled (boolean)', - 'xpack.osquery.actionEnabled (boolean)', - 'xpack.remote_clusters.ui.enabled (boolean)', + 'xpack.osquery.actionEnabled (boolean?)', + 'xpack.remote_clusters.ui.enabled (boolean?)', /** * NOTE: The Reporting plugin is currently disabled in functional tests (see test/functional/config.base.js). * It will be re-enabled once #102552 is completed. @@ -315,54 +313,54 @@ export default function ({ getService }: PluginFunctionalProviderContext) { // 'xpack.reporting.poll.jobCompletionNotifier.intervalErrorMultiplier (number)', // 'xpack.reporting.poll.jobsRefresh.interval (number)', // 'xpack.reporting.poll.jobsRefresh.intervalErrorMultiplier (number)', - 'xpack.rollup.ui.enabled (boolean)', - 'xpack.saved_object_tagging.cache_refresh_interval (duration)', - 'xpack.search.homepage.ui.enabled (boolean)', - 'xpack.searchInferenceEndpoints.ui.enabled (boolean)', - 'xpack.searchPlayground.ui.enabled (boolean)', - 'xpack.security.loginAssistanceMessage (string)', - 'xpack.security.sameSiteCookies (alternatives)', - 'xpack.security.showInsecureClusterWarning (boolean)', - 'xpack.security.showNavLinks (boolean)', - 'xpack.security.ui (any)', - 'xpack.security.roleManagementEnabled (any)', - 'xpack.spaces.maxSpaces (number)', - 'xpack.spaces.allowFeatureVisibility (any)', - 'xpack.spaces.allowSolutionVisibility (any)', - 'xpack.securitySolution.enableExperimental (array)', - 'xpack.securitySolution.prebuiltRulesPackageVersion (string)', - 'xpack.securitySolution.offeringSettings (record)', - 'xpack.snapshot_restore.slm_ui.enabled (boolean)', - 'xpack.snapshot_restore.ui.enabled (boolean)', - 'xpack.stack_connectors.enableExperimental (array)', - 'xpack.trigger_actions_ui.enableExperimental (array)', - 'xpack.trigger_actions_ui.enableGeoTrackingThresholdAlert (boolean)', - 'xpack.timelines.enableExperimental (array)', - 'xpack.alerting.rules.run.alerts.max (number)', - 'xpack.upgrade_assistant.featureSet.migrateSystemIndices (boolean)', - 'xpack.upgrade_assistant.featureSet.mlSnapshots (boolean)', - 'xpack.upgrade_assistant.featureSet.reindexCorrectiveActions (boolean)', - 'xpack.upgrade_assistant.ui.enabled (boolean)', - 'xpack.observability.unsafe.alertDetails.metrics.enabled (boolean)', - 'xpack.observability.unsafe.alertDetails.logs.enabled (boolean)', - 'xpack.observability.unsafe.alertDetails.uptime.enabled (boolean)', - 'xpack.observability.unsafe.alertDetails.observability.enabled (boolean)', - 'xpack.observability.unsafe.thresholdRule.enabled (any)', // conditional, is actually a boolean - 'xpack.observability_onboarding.ui.enabled (boolean)', - 'xpack.observabilityLogsExplorer.navigation.showAppLink (any)', // conditional, is actually a boolean - 'share.new_version.enabled (boolean)', - 'aiAssistantManagementSelection.preferredAIAssistantType (alternatives)', + 'xpack.rollup.ui.enabled (boolean?)', + 'xpack.saved_object_tagging.cache_refresh_interval (duration?)', + 'xpack.search.homepage.ui.enabled (boolean?)', + 'xpack.searchInferenceEndpoints.ui.enabled (boolean?)', + 'xpack.searchPlayground.ui.enabled (boolean?)', + 'xpack.security.loginAssistanceMessage (string?)', + 'xpack.security.sameSiteCookies (Strict?|Lax?|None?)', + 'xpack.security.showInsecureClusterWarning (boolean?)', + 'xpack.security.showNavLinks (boolean?)', + 'xpack.security.ui (object?|never)', + 'xpack.security.roleManagementEnabled (boolean?|never)', + 'xpack.spaces.maxSpaces (number?)', + 'xpack.spaces.allowFeatureVisibility (false|boolean?)', + 'xpack.spaces.allowSolutionVisibility (false|boolean?)', + 'xpack.securitySolution.enableExperimental (array?)', + 'xpack.securitySolution.prebuiltRulesPackageVersion (string?)', + 'xpack.securitySolution.offeringSettings (record?)', + 'xpack.snapshot_restore.slm_ui.enabled (boolean?)', + 'xpack.snapshot_restore.ui.enabled (boolean?)', + 'xpack.stack_connectors.enableExperimental (array?)', + 'xpack.trigger_actions_ui.enableExperimental (array?)', + 'xpack.trigger_actions_ui.enableGeoTrackingThresholdAlert (boolean?)', + 'xpack.timelines.enableExperimental (array?)', + 'xpack.alerting.rules.run.alerts.max (number?)', + 'xpack.upgrade_assistant.featureSet.migrateSystemIndices (boolean?)', + 'xpack.upgrade_assistant.featureSet.mlSnapshots (boolean?)', + 'xpack.upgrade_assistant.featureSet.reindexCorrectiveActions (boolean?)', + 'xpack.upgrade_assistant.ui.enabled (boolean?)', + 'xpack.observability.unsafe.alertDetails.metrics.enabled (boolean?)', + 'xpack.observability.unsafe.alertDetails.logs.enabled (boolean?)', + 'xpack.observability.unsafe.alertDetails.uptime.enabled (boolean?)', + 'xpack.observability.unsafe.alertDetails.observability.enabled (boolean?)', + 'xpack.observability.unsafe.thresholdRule.enabled (boolean?)', + 'xpack.observability_onboarding.ui.enabled (boolean?)', + 'xpack.observabilityLogsExplorer.navigation.showAppLink (boolean?|never)', + 'share.new_version.enabled (boolean?)', + 'aiAssistantManagementSelection.preferredAIAssistantType (default?|never?|observability?)', /** * Rule form V2 feature flags */ - 'discover.experimental.ruleFormV2Enabled (boolean)', - 'xpack.infra.featureFlags.ruleFormV2Enabled (boolean)', - 'xpack.legacy_uptime.experimental.ruleFormV2Enabled (boolean)', + 'discover.experimental.ruleFormV2Enabled (boolean?)', + 'xpack.infra.featureFlags.ruleFormV2Enabled (boolean?)', + 'xpack.legacy_uptime.experimental.ruleFormV2Enabled (boolean?)', 'xpack.ml.experimental.ruleFormV2.enabled (boolean)', - 'xpack.transform.experimental.ruleFormV2Enabled (boolean)', - 'xpack.apm.featureFlags.ruleFormV2Enabled (boolean)', - 'xpack.observability.unsafe.ruleFormV2.enabled (boolean)', - 'xpack.slo.experimental.ruleFormV2.enabled (boolean)', + 'xpack.transform.experimental.ruleFormV2Enabled (boolean?)', + 'xpack.apm.featureFlags.ruleFormV2Enabled (boolean?)', + 'xpack.observability.unsafe.ruleFormV2.enabled (boolean?)', + 'xpack.slo.experimental.ruleFormV2.enabled (boolean?)', /**/ ]; // We don't assert that actualExposedConfigKeys and expectedExposedConfigKeys are equal, because test failure messages with large @@ -401,37 +399,37 @@ export default function ({ getService }: PluginFunctionalProviderContext) { // what types of config settings can be exposed to the browser. // When plugin owners make a change that exposes additional config values, the changes will be reflected in this test assertion. // Ensure that your change does not unintentionally expose any sensitive values! - 'xpack.security.loginAssistanceMessage (string)', - 'xpack.security.sameSiteCookies (alternatives)', - 'xpack.security.showInsecureClusterWarning (boolean)', - 'xpack.security.showNavLinks (boolean)', - 'xpack.security.ui (any)', - 'xpack.security.roleManagementEnabled (any)', - - 'telemetry.allowChangingOptInStatus (boolean)', - 'telemetry.appendServerlessChannelsSuffix (any)', // It's a boolean (any because schema.conditional) - 'telemetry.banner (boolean)', - 'telemetry.labels.branch (string)', - 'telemetry.labels.ciBuildId (string)', - 'telemetry.labels.ciBuildJobId (string)', - 'telemetry.labels.ciBuildNumber (number)', - 'telemetry.labels.environment (string)', - 'telemetry.labels.ftrConfig (string)', - 'telemetry.labels.gitRev (string)', - 'telemetry.labels.isPr (boolean)', - 'telemetry.labels.journeyName (string)', - 'telemetry.labels.prId (number)', - 'telemetry.labels.testBuildId (string)', - 'telemetry.labels.testJobId (string)', - 'telemetry.labels.ciBuildName (string)', - 'telemetry.labels.performancePhase (string)', - 'telemetry.labels.serverless (any)', // It's the project type (string), claims any because schema.conditional. Can only be set on Serverless. - 'telemetry.hidePrivacyStatement (boolean)', - 'telemetry.optIn (boolean)', - 'telemetry.sendUsageFrom (alternatives)', - 'telemetry.sendUsageTo (any)', - 'usageCollection.uiCounters.debug (boolean)', - 'usageCollection.uiCounters.enabled (boolean)', + 'xpack.security.loginAssistanceMessage (string?)', + 'xpack.security.sameSiteCookies (Strict?|Lax?|None?)', + 'xpack.security.showInsecureClusterWarning (boolean?)', + 'xpack.security.showNavLinks (boolean?)', + 'xpack.security.ui (object?|never)', + 'xpack.security.roleManagementEnabled (boolean?|never)', + + 'telemetry.allowChangingOptInStatus (boolean?)', + 'telemetry.appendServerlessChannelsSuffix (true?|false?)', + 'telemetry.banner (boolean?)', + 'telemetry.labels.branch (string?)', + 'telemetry.labels.ciBuildId (string?)', + 'telemetry.labels.ciBuildJobId (string?)', + 'telemetry.labels.ciBuildNumber (number?)', + 'telemetry.labels.environment (string?)', + 'telemetry.labels.ftrConfig (string?)', + 'telemetry.labels.gitRev (string?)', + 'telemetry.labels.isPr (boolean?)', + 'telemetry.labels.journeyName (string?)', + 'telemetry.labels.prId (number?)', + 'telemetry.labels.testBuildId (string?)', + 'telemetry.labels.testJobId (string?)', + 'telemetry.labels.ciBuildName (string?)', + 'telemetry.labels.performancePhase (string?)', + 'telemetry.labels.serverless (string?|never)', // Can only be set on Serverless. + 'telemetry.hidePrivacyStatement (boolean?)', + 'telemetry.optIn (boolean?)', + 'telemetry.sendUsageFrom (server?|browser?)', + 'telemetry.sendUsageTo (prod?|staging?)', + 'usageCollection.uiCounters.debug (boolean?)', + 'usageCollection.uiCounters.enabled (boolean?)', ]; // We don't assert that actualExposedConfigKeys and expectedExposedConfigKeys are equal, because test failure messages with large // arrays are hard to grok. Instead, we take the difference between the two arrays and assert them separately, that way it's diff --git a/x-pack/plugins/observability_solution/synthetics/common/constants/synthetics_alerts.ts b/x-pack/plugins/observability_solution/synthetics/common/constants/synthetics_alerts.ts index 620c5c88033a7..4f525bda17564 100644 --- a/x-pack/plugins/observability_solution/synthetics/common/constants/synthetics_alerts.ts +++ b/x-pack/plugins/observability_solution/synthetics/common/constants/synthetics_alerts.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ActionGroup } from '@kbn/alerting-plugin/common'; +import type { ActionGroup } from '@kbn/alerting-plugin/common'; import { i18n } from '@kbn/i18n'; export type MonitorStatusActionGroup = diff --git a/x-pack/plugins/observability_solution/synthetics/common/runtime_types/monitor_management/state.ts b/x-pack/plugins/observability_solution/synthetics/common/runtime_types/monitor_management/state.ts index 9fbda10dfba56..0c546eb431dea 100644 --- a/x-pack/plugins/observability_solution/synthetics/common/runtime_types/monitor_management/state.ts +++ b/x-pack/plugins/observability_solution/synthetics/common/runtime_types/monitor_management/state.ts @@ -34,6 +34,7 @@ export const FetchMonitorOverviewQueryArgsCodec = t.partial({ projects: t.array(t.string), schedules: t.array(t.string), monitorTypes: t.array(t.string), + monitorQueryIds: t.array(t.string), sortField: t.string, sortOrder: t.string, }); diff --git a/x-pack/plugins/observability_solution/synthetics/common/runtime_types/ping/ping.ts b/x-pack/plugins/observability_solution/synthetics/common/runtime_types/ping/ping.ts index 5d481038b0869..2e9e36460c7be 100644 --- a/x-pack/plugins/observability_solution/synthetics/common/runtime_types/ping/ping.ts +++ b/x-pack/plugins/observability_solution/synthetics/common/runtime_types/ping/ping.ts @@ -16,7 +16,7 @@ export const PingErrorType = t.intersection([ t.partial({ code: t.string, id: t.string, - stack_trace: t.string, + stack_trace: t.union([t.string, t.null]), type: t.string, }), t.type({ diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/field_selector.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/field_selector.tsx new file mode 100644 index 0000000000000..0bb37e6c4e736 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/field_selector.tsx @@ -0,0 +1,128 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React, { ReactNode, useState } from 'react'; +import { EuiComboBox, EuiComboBoxOptionOption, EuiFlexItem, EuiFormRow } from '@elastic/eui'; +import { debounce } from 'lodash'; +import { Controller, FieldPath, useFormContext } from 'react-hook-form'; +import { + Suggestion, + useFetchSyntheticsSuggestions, +} from '../hooks/use_fetch_synthetics_suggestions'; +import { OptionalText } from './optional_text'; +import { MonitorFilters } from '../monitors_overview/types'; + +interface Option { + label: string; + value: string; +} + +export interface Props { + dataTestSubj: string; + label: string; + name: FieldPath; + placeholder: string; + tooltip?: ReactNode; + suggestions?: Suggestion[]; + isLoading?: boolean; + required?: boolean; +} + +export function FieldSelector({ + dataTestSubj, + label, + name, + placeholder, + tooltip, + required, +}: Props) { + const { control, getFieldState } = useFormContext(); + const [search, setSearch] = useState(''); + + const { suggestions = [], isLoading } = useFetchSyntheticsSuggestions({ + search, + fieldName: name, + }); + + const debouncedSearch = debounce((value) => setSearch(value), 200); + + return ( + + + {label} {tooltip} + + ) : ( + label + ) + } + isInvalid={getFieldState(name).invalid} + fullWidth + labelAppend={!required ? : undefined} + > + { + const selectedOptions = + !!Array.isArray(field.value) && field.value.length + ? createSelectedOptions(field.value, suggestions) + : []; + + return ( + { + if (selected.length) { + field.onChange( + selected.map((option) => ({ + label: option.label, + value: option.value, + })) + ); + return; + } + field.onChange([]); + }} + onSearchChange={(value: string) => debouncedSearch(value)} + options={createOptions(suggestions)} + placeholder={placeholder} + selectedOptions={selectedOptions} + /> + ); + }} + /> + + + ); +} + +function createOptions(suggestions: Suggestion[] = []): Option[] { + return suggestions + .map((suggestion) => ({ label: suggestion.label, value: suggestion.value })) + .sort((a, b) => String(a.label).localeCompare(b.label)); +} + +function createSelectedOptions(selected: Option[] = [], suggestions: Suggestion[] = []): Option[] { + return selected.map((value) => { + const suggestion = suggestions.find((s) => s.value === value.value); + if (!suggestion) { + return { label: value.value, value: value.value }; + } + return { label: suggestion.label, value: suggestion.value }; + }); +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_configuration.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_configuration.tsx new file mode 100644 index 0000000000000..24995e898b3a1 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_configuration.tsx @@ -0,0 +1,120 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { + EuiButton, + EuiButtonEmpty, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutHeader, + EuiFlyoutBody, + EuiFlyoutFooter, + EuiTitle, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { i18n } from '@kbn/i18n'; +import { FormProvider, useForm } from 'react-hook-form'; +import { MonitorFilters } from '../monitors_overview/types'; +import { MonitorFiltersForm } from './monitor_filters_form'; + +interface MonitorConfigurationProps { + initialInput?: { + filters: MonitorFilters; + }; + onCreate: (props: { filters: MonitorFilters }) => void; + onCancel: () => void; +} + +export function MonitorConfiguration({ + initialInput, + onCreate, + onCancel, +}: MonitorConfigurationProps) { + const methods = useForm({ + defaultValues: { + monitorIds: [], + projects: [], + tags: [], + monitorTypes: [], + locations: [], + }, + values: initialInput?.filters, + mode: 'all', + }); + const { getValues, formState } = methods; + + const onConfirmClick = () => { + const newFilters = getValues(); + onCreate({ + filters: newFilters, + }); + }; + + return ( + + + + + +

+ {i18n.translate( + 'xpack.synthetics.overviewEmbeddable.config.sloSelector.headerTitle', + { + defaultMessage: 'Overview configuration', + } + )} +

+
+
+
+
+ + <> + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ); +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_filters_form.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_filters_form.tsx new file mode 100644 index 0000000000000..80d2f3aa072cd --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitor_filters_form.tsx @@ -0,0 +1,94 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { EuiFlexGroup, EuiIconTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { FieldSelector } from './field_selector'; + +export function MonitorFiltersForm() { + return ( + + + + } + /> + + + + + + + ); +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitors_open_configuration.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitors_open_configuration.tsx new file mode 100644 index 0000000000000..48dbcb085b806 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/monitors_open_configuration.tsx @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { CoreStart } from '@kbn/core/public'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { toMountPoint } from '@kbn/react-kibana-mount'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { MonitorFilters } from '../monitors_overview/types'; +import { ClientPluginsStart } from '../../../plugin'; +import { MonitorConfiguration } from './monitor_configuration'; + +export async function openMonitorConfiguration({ + coreStart, + pluginStart, + initialState, +}: { + coreStart: CoreStart; + pluginStart: ClientPluginsStart; + initialState?: { filters: MonitorFilters }; +}): Promise<{ filters: MonitorFilters }> { + const { overlays } = coreStart; + const queryClient = new QueryClient(); + return new Promise(async (resolve, reject) => { + try { + const flyoutSession = overlays.openFlyout( + toMountPoint( + + + { + flyoutSession.close(); + resolve(update); + }} + onCancel={() => { + flyoutSession.close(); + reject(); + }} + /> + + , + coreStart + ) + ); + } catch (error) { + reject(error); + } + }); +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/optional_text.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/optional_text.tsx new file mode 100644 index 0000000000000..28bd67301af16 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/optional_text.tsx @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiText } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; + +export function OptionalText() { + return ( + + {i18n.translate('xpack.synthetics.formEdit.optionalLabel', { + defaultMessage: 'Optional', + })} + + ); +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/show_selected_filters.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/show_selected_filters.tsx new file mode 100644 index 0000000000000..0a6f6ab515d94 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/common/show_selected_filters.tsx @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiBadgeGroup, EuiBadge } from '@elastic/eui'; +import { MonitorFilters } from '../monitors_overview/types'; + +export const ShowSelectedFilters = ({ filters }: { filters: MonitorFilters }) => { + return ( + + {Object.entries(filters).map(([key, filter]) => { + if (!filter || !filter.length) { + return null; + } + const values = filter + .map((f: { label: string; value: string }) => f.label || f.value) + .join(', '); + + return ( + + {i18n.translate('xpack.synthetics.showSelectedFilters.monitorBadgeLabel', { + defaultMessage: '{label}: {value}', + values: { label: labels[key], value: values }, + })} + + ); + })} + + ); +}; + +const labels: Record = { + monitorIds: i18n.translate('xpack.synthetics.showSelectedFilters.monitorIdLabel', { + defaultMessage: 'Monitor', + }), + tags: i18n.translate('xpack.synthetics.showSelectedFilters.tagsLabel', { + defaultMessage: 'Tags', + }), + locations: i18n.translate('xpack.synthetics.showSelectedFilters.locationsLabel', { + defaultMessage: 'Location', + }), + monitorTypes: i18n.translate('xpack.synthetics.showSelectedFilters.monitorTypeLabel', { + defaultMessage: 'Type', + }), + projects: i18n.translate('xpack.synthetics.showSelectedFilters.presetLabel', { + defaultMessage: 'Project', + }), +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/constants.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/constants.ts index b471d46ac3832..5afcf2d3026b4 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/constants.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/constants.ts @@ -5,4 +5,22 @@ * 2.0. */ -export const SYNTHETICS_OVERVIEW_EMBEDDABLE = 'SYNTHETICS_OVERVIEW_EMBEDDABLE'; +import { i18n } from '@kbn/i18n'; + +export const SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE = 'SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE'; +export const SYNTHETICS_MONITORS_EMBEDDABLE = 'SYNTHETICS_MONITORS_EMBEDDABLE'; + +export const COMMON_SYNTHETICS_GROUPING = [ + { + id: 'synthetics', + getDisplayName: () => + i18n.translate('xpack.synthetics.common.constants.grouping.legacy', { + defaultMessage: 'Synthetics', + }), + getIconType: () => { + return 'online'; + }, + }, +]; + +export const ALL_VALUE = '*'; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/hooks/use_fetch_synthetics_suggestions.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/hooks/use_fetch_synthetics_suggestions.ts new file mode 100644 index 0000000000000..b9f838675bce4 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/hooks/use_fetch_synthetics_suggestions.ts @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useFetcher } from '@kbn/observability-shared-plugin/public'; +import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { ClientPluginsStart } from '../../../plugin'; + +export interface Suggestion { + label: string; + value: string; + count: number; +} + +export interface Params { + fieldName: string; + filters?: { + locations?: string[]; + monitorIds?: string[]; + tags?: string[]; + projects?: string[]; + }; + search: string; +} + +type ApiResponse = Record; + +export function useFetchSyntheticsSuggestions({ filters, fieldName, search }: Params) { + const { http } = useKibana().services; + const { locations, monitorIds, tags, projects } = filters || {}; + + const { loading, data } = useFetcher(async () => { + return await http.get('/internal/synthetics/suggestions', { + query: { + locations: locations || [], + monitorQueryIds: monitorIds || [], + tags: tags || [], + projects: projects || [], + query: search, + }, + }); + }, [http, locations, monitorIds, projects, search, tags]); + + return { + suggestions: data?.[fieldName] ?? [], + isLoading: Boolean(loading), + }; +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_embeddable_factory.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_embeddable_factory.tsx similarity index 57% rename from x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_embeddable_factory.tsx rename to x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_embeddable_factory.tsx index 3f7b3fcf13699..e23de3cc67a14 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_embeddable_factory.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_embeddable_factory.tsx @@ -5,9 +5,8 @@ * 2.0. */ -import { i18n } from '@kbn/i18n'; - import React, { useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; import { DefaultEmbeddableApi, ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { initializeTitles, @@ -16,25 +15,30 @@ import { PublishesWritablePanelTitle, PublishesPanelTitle, SerializedTitles, + HasEditCapabilities, } from '@kbn/presentation-publishing'; import { BehaviorSubject, Subject } from 'rxjs'; import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; -import { SYNTHETICS_OVERVIEW_EMBEDDABLE } from '../constants'; +import { MonitorFilters } from './types'; +import { StatusGridComponent } from './monitors_grid_component'; +import { SYNTHETICS_MONITORS_EMBEDDABLE } from '../constants'; import { ClientPluginsStart } from '../../../plugin'; -import { StatusOverviewComponent } from './status_overview_component'; export const getOverviewPanelTitle = () => - i18n.translate('xpack.synthetics.statusOverview.displayName', { - defaultMessage: 'Synthetics Status Overview', + i18n.translate('xpack.synthetics.monitors.displayName', { + defaultMessage: 'Synthetics Monitors', }); -export type OverviewEmbeddableState = SerializedTitles; +export type OverviewEmbeddableState = SerializedTitles & { + filters: MonitorFilters; +}; export type StatusOverviewApi = DefaultEmbeddableApi & PublishesWritablePanelTitle & - PublishesPanelTitle; + PublishesPanelTitle & + HasEditCapabilities; -export const getStatusOverviewEmbeddableFactory = ( +export const getMonitorsEmbeddableFactory = ( getStartServices: StartServicesAccessor ) => { const factory: ReactEmbeddableFactory< @@ -42,29 +46,57 @@ export const getStatusOverviewEmbeddableFactory = ( OverviewEmbeddableState, StatusOverviewApi > = { - type: SYNTHETICS_OVERVIEW_EMBEDDABLE, + type: SYNTHETICS_MONITORS_EMBEDDABLE, deserializeState: (state) => { return state.rawState as OverviewEmbeddableState; }, buildEmbeddable: async (state, buildApi, uuid, parentApi) => { + const [coreStart, pluginStart] = await getStartServices(); + const { titlesApi, titleComparators, serializeTitles } = initializeTitles(state); const defaultTitle$ = new BehaviorSubject(getOverviewPanelTitle()); const reload$ = new Subject(); + const filters$ = new BehaviorSubject(state.filters); const api = buildApi( { ...titlesApi, defaultPanelTitle: defaultTitle$, + getTypeDisplayName: () => + i18n.translate('xpack.synthetics.editSloOverviewEmbeddableTitle.typeDisplayName', { + defaultMessage: 'filters', + }), + isEditingEnabled: () => true, serializeState: () => { return { rawState: { ...serializeTitles(), + filters: filters$.getValue(), }, }; }, + onEdit: async () => { + try { + const { openMonitorConfiguration } = await import( + '../common/monitors_open_configuration' + ); + + const result = await openMonitorConfiguration({ + coreStart, + pluginStart, + initialState: { + filters: filters$.getValue(), + }, + }); + filters$.next(result.filters); + } catch (e) { + return Promise.reject(); + } + }, }, { ...titleComparators, + filters: [filters$, (value) => filters$.next(value)], } ); @@ -77,7 +109,7 @@ export const getStatusOverviewEmbeddableFactory = ( return { api, Component: () => { - const [] = useBatchedPublishingSubjects(); + const [filters] = useBatchedPublishingSubjects(filters$); useEffect(() => { return () => { @@ -86,9 +118,14 @@ export const getStatusOverviewEmbeddableFactory = ( }, []); return (
- +
); }, diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_grid_component.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_grid_component.tsx new file mode 100644 index 0000000000000..c3801bb98ca9a --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/monitors_grid_component.tsx @@ -0,0 +1,60 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect, useRef } from 'react'; +import { Subject } from 'rxjs'; +import { i18n } from '@kbn/i18n'; +import { useDispatch } from 'react-redux'; +import { getOverviewStore } from './redux_store'; +import { ShowSelectedFilters } from '../common/show_selected_filters'; +import { setOverviewPageStateAction } from '../../synthetics/state'; +import { MonitorFilters } from './types'; +import { EmbeddablePanelWrapper } from '../../synthetics/components/common/components/embeddable_panel_wrapper'; +import { SyntheticsEmbeddableContext } from '../synthetics_embeddable_context'; +import { OverviewGrid } from '../../synthetics/components/monitors_page/overview/overview/overview_grid'; + +export const StatusGridComponent = ({ + reload$, + filters, +}: { + reload$: Subject; + filters: MonitorFilters; +}) => { + const overviewStore = useRef(getOverviewStore()); + + return ( + } + > + + + + + ); +}; + +const MonitorsOverviewList = ({ filters }: { filters: MonitorFilters }) => { + const dispatch = useDispatch(); + useEffect(() => { + if (!filters) return; + dispatch( + setOverviewPageStateAction({ + tags: filters.tags.map((tag) => tag.value), + locations: filters.locations.map((location) => location.value), + monitorTypes: filters.monitorTypes.map((monitorType) => monitorType.value), + monitorQueryIds: filters.monitorIds.map((monitorId) => monitorId.value), + projects: filters.projects.map((project) => project.value), + }) + ); + }, [dispatch, filters]); + + return ; +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/redux_store.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/redux_store.ts new file mode 100644 index 0000000000000..86bdd93311674 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/redux_store.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { configureStore } from '@reduxjs/toolkit'; +import createSagaMiddleware from 'redux-saga'; +import { rootReducer } from '../../synthetics/state/root_reducer'; +import { rootEffect } from '../../synthetics/state/root_effect'; + +export const getOverviewStore = () => { + const sagaMW = createSagaMiddleware(); + + const store = configureStore({ + reducer: rootReducer, + middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMW), + devTools: process.env.NODE_ENV !== 'production', + preloadedState: {}, + enhancers: [], + }); + sagaMW.run(rootEffect); + return store; +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/types.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/types.ts new file mode 100644 index 0000000000000..e8d1c71ee7d11 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/monitors_overview/types.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +interface Option { + label: string; + value: string; +} + +export interface MonitorFilters { + projects: Option[]; + tags: Option[]; + monitorIds: Option[]; + monitorTypes: Option[]; + locations: Option[]; +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/register_embeddables.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/register_embeddables.ts index fbc516a6f611b..3491df4dfc96f 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/register_embeddables.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/register_embeddables.ts @@ -7,42 +7,54 @@ import { CoreSetup } from '@kbn/core-lifecycle-browser'; -import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-browser/src'; -import { createStatusOverviewPanelAction } from './ui_actions/create_overview_panel_action'; import { ClientPluginsSetup, ClientPluginsStart } from '../../plugin'; -import { SYNTHETICS_OVERVIEW_EMBEDDABLE } from './constants'; +import { SYNTHETICS_MONITORS_EMBEDDABLE, SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE } from './constants'; export const registerSyntheticsEmbeddables = ( core: CoreSetup, pluginsSetup: ClientPluginsSetup ) => { pluginsSetup.embeddable.registerReactEmbeddableFactory( - SYNTHETICS_OVERVIEW_EMBEDDABLE, + SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE, async () => { - const { getStatusOverviewEmbeddableFactory } = await import( - './status_overview/status_overview_embeddable_factory' + const { getStatsOverviewEmbeddableFactory } = await import( + './stats_overview/stats_overview_embeddable_factory' ); - return getStatusOverviewEmbeddableFactory(core.getStartServices); + return getStatsOverviewEmbeddableFactory(core.getStartServices); } ); - const { uiActions, cloud, serverless } = pluginsSetup; - - // Initialize actions - const addOverviewPanelAction = createStatusOverviewPanelAction(); + pluginsSetup.embeddable.registerReactEmbeddableFactory( + SYNTHETICS_MONITORS_EMBEDDABLE, + async () => { + const { getMonitorsEmbeddableFactory } = await import( + './monitors_overview/monitors_embeddable_factory' + ); + return getMonitorsEmbeddableFactory(core.getStartServices); + } + ); core.getStartServices().then(([_, pluginsStart]) => { pluginsStart.dashboard.registerDashboardPanelPlacementSetting( - SYNTHETICS_OVERVIEW_EMBEDDABLE, + SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE, () => { return { width: 10, height: 8 }; } ); + pluginsStart.dashboard.registerDashboardPanelPlacementSetting( + SYNTHETICS_MONITORS_EMBEDDABLE, + () => { + return { width: 30, height: 12 }; + } + ); }); - // Assign triggers - // Only register these actions in stateful kibana, and the serverless observability project - if (Boolean((serverless && cloud?.serverless.projectType === 'observability') || !serverless)) { - uiActions.addTriggerAction(ADD_PANEL_TRIGGER, addOverviewPanelAction); - } + const registerAsyncUiActions = async () => { + if (pluginsSetup.uiActions) { + const { registerSyntheticsUiActions } = await import('./ui_actions/register_ui_actions'); + registerSyntheticsUiActions(core, pluginsSetup); + } + }; + // can be done async + registerAsyncUiActions(); }; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/redux_store.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/redux_store.ts new file mode 100644 index 0000000000000..8192b9a787ac7 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/redux_store.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { configureStore } from '@reduxjs/toolkit'; +import createSagaMiddleware from 'redux-saga'; +import { rootReducer } from '../../synthetics/state/root_reducer'; +import { rootEffect } from '../../synthetics/state/root_effect'; + +export const getStatsOverviewStore = () => { + const sagaMW = createSagaMiddleware(); + + const store = configureStore({ + reducer: rootReducer, + middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMW), + devTools: process.env.NODE_ENV !== 'production', + preloadedState: {}, + enhancers: [], + }); + sagaMW.run(rootEffect); + + return store; +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_component.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_component.tsx new file mode 100644 index 0000000000000..579596615ae72 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_component.tsx @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect, useRef } from 'react'; +import { Subject } from 'rxjs'; +import { useDispatch } from 'react-redux'; +import { getStatsOverviewStore } from './redux_store'; +import { ShowSelectedFilters } from '../common/show_selected_filters'; +import { MonitorFilters } from '../monitors_overview/types'; +import { setOverviewPageStateAction } from '../../synthetics/state'; +import { SyntheticsEmbeddableContext } from '../synthetics_embeddable_context'; +import { OverviewStatus } from '../../synthetics/components/monitors_page/overview/overview/overview_status'; + +export const StatsOverviewComponent = ({ + reload$, + filters, +}: { + reload$: Subject; + filters: MonitorFilters; +}) => { + const statsOverviewStore = useRef(getStatsOverviewStore()); + + return ( + + + + ); +}; + +const WithFiltersComponent = ({ filters }: { filters: MonitorFilters }) => { + const dispatch = useDispatch(); + useEffect(() => { + dispatch( + setOverviewPageStateAction({ + tags: filters.tags.map((tag) => tag.value), + locations: filters.locations.map((location) => location.value), + monitorTypes: filters.monitorTypes.map((monitorType) => monitorType.value), + monitorQueryIds: filters.monitorIds.map((monitorId) => monitorId.value), + projects: filters.projects.map((project) => project.value), + }) + ); + }, [dispatch, filters]); + + return } />; +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_embeddable_factory.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_embeddable_factory.tsx new file mode 100644 index 0000000000000..07f1e72fa1e98 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/stats_overview/stats_overview_embeddable_factory.tsx @@ -0,0 +1,135 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +import React, { useEffect } from 'react'; +import { DefaultEmbeddableApi, ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; +import { + initializeTitles, + useBatchedPublishingSubjects, + fetch$, + PublishesWritablePanelTitle, + PublishesPanelTitle, + SerializedTitles, + HasEditCapabilities, +} from '@kbn/presentation-publishing'; +import { BehaviorSubject, Subject } from 'rxjs'; +import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; +import { MonitorFilters } from '../monitors_overview/types'; +import { SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE } from '../constants'; +import { ClientPluginsStart } from '../../../plugin'; +import { StatsOverviewComponent } from './stats_overview_component'; + +export const getOverviewPanelTitle = () => + i18n.translate('xpack.synthetics.statusOverview.list.displayName', { + defaultMessage: 'Synthetics Stats Overview', + }); + +export type OverviewEmbeddableState = SerializedTitles & { + filters: MonitorFilters; +}; + +export type StatsOverviewApi = DefaultEmbeddableApi & + PublishesWritablePanelTitle & + PublishesPanelTitle & + HasEditCapabilities; + +export const getStatsOverviewEmbeddableFactory = ( + getStartServices: StartServicesAccessor +) => { + const factory: ReactEmbeddableFactory< + OverviewEmbeddableState, + OverviewEmbeddableState, + StatsOverviewApi + > = { + type: SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE, + deserializeState: (state) => { + return state.rawState as OverviewEmbeddableState; + }, + buildEmbeddable: async (state, buildApi, uuid, parentApi) => { + const [coreStart, pluginStart] = await getStartServices(); + + const { titlesApi, titleComparators, serializeTitles } = initializeTitles(state); + const defaultTitle$ = new BehaviorSubject(getOverviewPanelTitle()); + const reload$ = new Subject(); + const filters$ = new BehaviorSubject(state.filters); + + const api = buildApi( + { + ...titlesApi, + defaultPanelTitle: defaultTitle$, + getTypeDisplayName: () => + i18n.translate('xpack.synthetics.editSloOverviewEmbeddableTitle.typeDisplayName', { + defaultMessage: 'filters', + }), + isEditingEnabled: () => true, + onEdit: async () => { + try { + const { openMonitorConfiguration } = await import( + '../common/monitors_open_configuration' + ); + + const result = await openMonitorConfiguration({ + coreStart, + pluginStart, + initialState: { + filters: filters$.getValue(), + }, + }); + filters$.next(result.filters); + } catch (e) { + return Promise.reject(); + } + }, + serializeState: () => { + return { + rawState: { + ...serializeTitles(), + filters: filters$.getValue(), + }, + }; + }, + }, + { + ...titleComparators, + filters: [filters$, (value) => filters$.next(value)], + } + ); + + const fetchSubscription = fetch$(api) + .pipe() + .subscribe((next) => { + reload$.next(next.isReload); + }); + + return { + api, + Component: () => { + const [filters] = useBatchedPublishingSubjects(filters$); + + useEffect(() => { + return () => { + fetchSubscription.unsubscribe(); + }; + }, []); + return ( +
+ +
+ ); + }, + }; + }, + }; + return factory; +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_component.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_component.tsx deleted file mode 100644 index 1034f9ea959ec..0000000000000 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/status_overview/status_overview_component.tsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { Subject } from 'rxjs'; -import { OverviewStatus } from '../../synthetics/components/monitors_page/overview/overview/overview_status'; -import { SyntheticsEmbeddableContext } from '../synthetics_embeddable_context'; - -export const StatusOverviewComponent = ({ reload$ }: { reload$: Subject }) => { - return ( - - - - ); -}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/synthetics_embeddable_context.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/synthetics_embeddable_context.tsx index 0953fb79961b1..6e4cbd4748e95 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/synthetics_embeddable_context.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/synthetics_embeddable_context.tsx @@ -9,23 +9,32 @@ import React from 'react'; import { createBrowserHistory } from 'history'; import { EuiPanel } from '@elastic/eui'; import { Router } from '@kbn/shared-ux-router'; +import { Subject } from 'rxjs'; +import { Store } from 'redux'; import { SyntheticsSharedContext } from '../synthetics/contexts/synthetics_shared_context'; import { SyntheticsEmbeddableStateContextProvider } from '../synthetics/contexts/synthetics_embeddable_context'; import { getSyntheticsAppProps } from '../synthetics/render_app'; import { SyntheticsSettingsContextProvider } from '../synthetics/contexts'; -export const SyntheticsEmbeddableContext: React.FC<{ search?: string }> = ({ - search, - children, -}) => { +export const SyntheticsEmbeddableContext: React.FC<{ + reload$: Subject; + reduxStore?: Store; +}> = ({ reload$, children, reduxStore }) => { const props = getSyntheticsAppProps(); return ( - + - {children} + + {children} + diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_monitors_overview_panel_action.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_monitors_overview_panel_action.tsx new file mode 100644 index 0000000000000..aa7355c4e1fec --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_monitors_overview_panel_action.tsx @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { i18n } from '@kbn/i18n'; +import { apiIsPresentationContainer } from '@kbn/presentation-containers'; +import { + IncompatibleActionError, + type UiActionsActionDefinition, +} from '@kbn/ui-actions-plugin/public'; +import { EmbeddableApiContext } from '@kbn/presentation-publishing'; +import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; +import { ClientPluginsStart } from '../../../plugin'; +import { COMMON_SYNTHETICS_GROUPING, SYNTHETICS_MONITORS_EMBEDDABLE } from '../constants'; + +export const ADD_SYNTHETICS_MONITORS_OVERVIEW_ACTION_ID = + 'CREATE_SYNTHETICS_MONITORS_OVERVIEW_EMBEDDABLE'; + +export function createMonitorsOverviewPanelAction( + getStartServices: StartServicesAccessor +): UiActionsActionDefinition { + return { + id: ADD_SYNTHETICS_MONITORS_OVERVIEW_ACTION_ID, + grouping: COMMON_SYNTHETICS_GROUPING, + order: 30, + getIconType: () => 'play', + isCompatible: async ({ embeddable }) => { + return apiIsPresentationContainer(embeddable); + }, + execute: async ({ embeddable }) => { + if (!apiIsPresentationContainer(embeddable)) throw new IncompatibleActionError(); + const [coreStart, pluginStart] = await getStartServices(); + const { openMonitorConfiguration } = await import('../common/monitors_open_configuration'); + + const initialState = await openMonitorConfiguration({ + coreStart, + pluginStart, + }); + try { + embeddable.addNewPanel({ + panelType: SYNTHETICS_MONITORS_EMBEDDABLE, + initialState, + }); + } catch (e) { + return Promise.reject(); + } + }, + getDisplayName: () => + i18n.translate('xpack.synthetics.syntheticsEmbeddable.monitors.ariaLabel', { + defaultMessage: 'Monitors overview', + }), + }; +} diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_overview_panel_action.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_stats_overview_panel_action.tsx similarity index 57% rename from x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_overview_panel_action.tsx rename to x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_stats_overview_panel_action.tsx index 79c6a6c1195a9..a3b2c67be88fe 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_overview_panel_action.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/create_stats_overview_panel_action.tsx @@ -10,23 +10,15 @@ import { type UiActionsActionDefinition, } from '@kbn/ui-actions-plugin/public'; import { EmbeddableApiContext } from '@kbn/presentation-publishing'; -import { SYNTHETICS_OVERVIEW_EMBEDDABLE } from '../constants'; +import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; +import { ClientPluginsStart } from '../../../plugin'; +import { COMMON_SYNTHETICS_GROUPING, SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE } from '../constants'; -export const COMMON_SYNTHETICS_GROUPING = [ - { - id: 'synthetics', - getDisplayName: () => - i18n.translate('xpack.synthetics.common.constants.grouping.legacy', { - defaultMessage: 'Synthetics', - }), - getIconType: () => { - return 'online'; - }, - }, -]; -export const ADD_SYNTHETICS_OVERVIEW_ACTION_ID = 'CREATE_SYNTHETICS_OVERVIEW_EMBEDDABLE'; +export const ADD_SYNTHETICS_OVERVIEW_ACTION_ID = 'CREATE_SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE'; -export function createStatusOverviewPanelAction(): UiActionsActionDefinition { +export function createStatusOverviewPanelAction( + getStartServices: StartServicesAccessor +): UiActionsActionDefinition { return { id: ADD_SYNTHETICS_OVERVIEW_ACTION_ID, grouping: COMMON_SYNTHETICS_GROUPING, @@ -40,16 +32,24 @@ export function createStatusOverviewPanelAction(): UiActionsActionDefinition - i18n.translate('xpack.synthetics.syntheticsEmbeddable.ariaLabel', { - defaultMessage: 'Synthetics Overview', + i18n.translate('xpack.synthetics.syntheticsEmbeddable.stats.ariaLabel', { + defaultMessage: 'Monitors stats', }), }; } diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/register_ui_actions.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/register_ui_actions.ts new file mode 100644 index 0000000000000..6edc4bb40a028 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/embeddables/ui_actions/register_ui_actions.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ADD_PANEL_TRIGGER } from '@kbn/ui-actions-browser/src'; +import { CoreSetup } from '@kbn/core-lifecycle-browser'; +import { createStatusOverviewPanelAction } from './create_stats_overview_panel_action'; +import { createMonitorsOverviewPanelAction } from './create_monitors_overview_panel_action'; +import { ClientPluginsSetup, ClientPluginsStart } from '../../../plugin'; + +export const registerSyntheticsUiActions = async ( + core: CoreSetup, + pluginsSetup: ClientPluginsSetup +) => { + const { uiActions, cloud, serverless } = pluginsSetup; + + // Initialize actions + const addStatsOverviewPanelAction = createStatusOverviewPanelAction(core.getStartServices); + const addMonitorsOverviewPanelAction = createMonitorsOverviewPanelAction(core.getStartServices); + + // Assign triggers + // Only register these actions in stateful kibana, and the serverless observability project + if (Boolean((serverless && cloud?.serverless.projectType === 'observability') || !serverless)) { + uiActions.addTriggerAction(ADD_PANEL_TRIGGER, addStatsOverviewPanelAction); + uiActions.addTriggerAction(ADD_PANEL_TRIGGER, addMonitorsOverviewPanelAction); + } +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx new file mode 100644 index 0000000000000..2a910855aa245 --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx @@ -0,0 +1,142 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { + EuiButtonEmpty, + EuiButtonIcon, + EuiContextMenuItem, + EuiContextMenuPanel, + EuiPopover, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React, { useCallback } from 'react'; +import { + LazySavedObjectSaveModalDashboard, + SaveModalDashboardProps, + withSuspense, +} from '@kbn/presentation-util-plugin/public'; +import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { ClientPluginsStart } from '../../../../../plugin'; +import { + SYNTHETICS_MONITORS_EMBEDDABLE, + SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE, +} from '../../../../embeddables/constants'; + +const SavedObjectSaveModalDashboard = withSuspense(LazySavedObjectSaveModalDashboard); + +export const AddToDashboard = ({ + type, + asButton = false, +}: { + type: typeof SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE | typeof SYNTHETICS_MONITORS_EMBEDDABLE; + asButton?: boolean; +}) => { + const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); + const [isDashboardAttachmentReady, setDashboardAttachmentReady] = React.useState(false); + const closePopover = () => { + setIsPopoverOpen(false); + }; + + const { embeddable } = useKibana().services; + + const handleAttachToDashboardSave: SaveModalDashboardProps['onSave'] = useCallback( + ({ dashboardId, newTitle, newDescription }) => { + const stateTransfer = embeddable.getStateTransfer(); + const embeddableInput = {}; + + const state = { + input: embeddableInput, + type, + }; + + const path = dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`; + + stateTransfer.navigateToWithEmbeddablePackage('dashboards', { + state, + path, + }); + }, + [embeddable, type] + ); + const isSyntheticsApp = window.location.pathname.includes('/app/synthetics'); + + if (!isSyntheticsApp) { + return null; + } + + return ( + <> + {asButton ? ( + setDashboardAttachmentReady(true)} + > + {i18n.translate('xpack.synthetics.embeddablePanelWrapper.shareButtonLabel', { + defaultMessage: 'Add to dashboard', + })} + + ) : ( + setIsPopoverOpen(!isPopoverOpen)} + /> + } + isOpen={isPopoverOpen} + closePopover={closePopover} + > + { + setDashboardAttachmentReady(true); + closePopover(); + }} + > + {i18n.translate( + 'xpack.synthetics.embeddablePanelWrapper.shareContextMenuItemLabel', + { + defaultMessage: 'Add to dashboard', + } + )} + , + ]} + /> + + )} + {isDashboardAttachmentReady ? ( + { + setDashboardAttachmentReady(false); + }} + onSave={handleAttachToDashboardSave} + /> + ) : null} + + ); +}; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/embeddable_panel_wrapper.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/embeddable_panel_wrapper.tsx index cd73097c956a6..bb8ec04105167 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/embeddable_panel_wrapper.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/components/embeddable_panel_wrapper.tsx @@ -5,66 +5,18 @@ * 2.0. */ -import React, { FC, useCallback } from 'react'; -import { i18n } from '@kbn/i18n'; -import { - EuiButtonIcon, - EuiContextMenuItem, - EuiContextMenuPanel, - EuiFlexGroup, - EuiFlexItem, - EuiPanel, - EuiPopover, - EuiProgress, - EuiTitle, -} from '@elastic/eui'; -import { - LazySavedObjectSaveModalDashboard, - SaveModalDashboardProps, - withSuspense, -} from '@kbn/presentation-util-plugin/public'; -import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { SYNTHETICS_OVERVIEW_EMBEDDABLE } from '../../../../embeddables/constants'; -import { ClientPluginsStart } from '../../../../../plugin'; - -const SavedObjectSaveModalDashboard = withSuspense(LazySavedObjectSaveModalDashboard); +import React, { FC } from 'react'; +import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiProgress, EuiTitle } from '@elastic/eui'; +import { AddToDashboard } from './add_to_dashboard'; +import { SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE } from '../../../../embeddables/constants'; export const EmbeddablePanelWrapper: FC<{ title: string; loading?: boolean; -}> = ({ children, title, loading }) => { - const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); - - const [isDashboardAttachmentReady, setDashboardAttachmentReady] = React.useState(false); - - const closePopover = () => { - setIsPopoverOpen(false); - }; - - const { embeddable } = useKibana().services; - + titleAppend?: React.ReactNode; +}> = ({ children, title, loading, titleAppend }) => { const isSyntheticsApp = window.location.pathname.includes('/app/synthetics'); - const handleAttachToDashboardSave: SaveModalDashboardProps['onSave'] = useCallback( - ({ dashboardId, newTitle, newDescription }) => { - const stateTransfer = embeddable.getStateTransfer(); - const embeddableInput = {}; - - const state = { - input: embeddableInput, - type: SYNTHETICS_OVERVIEW_EMBEDDABLE, - }; - - const path = dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`; - - stateTransfer.navigateToWithEmbeddablePackage('dashboards', { - state, - path, - }); - }, - [embeddable] - ); - return ( <> @@ -77,63 +29,14 @@ export const EmbeddablePanelWrapper: FC<{ {isSyntheticsApp && ( - setIsPopoverOpen(!isPopoverOpen)} - /> - } - isOpen={isPopoverOpen} - closePopover={closePopover} - > - { - setDashboardAttachmentReady(true); - closePopover(); - }} - > - {i18n.translate( - 'xpack.synthetics.embeddablePanelWrapper.shareContextMenuItemLabel', - { defaultMessage: 'Add to dashboard' } - )} - , - ]} - /> - + )} + {titleAppend && {titleAppend}} {children} - {isDashboardAttachmentReady ? ( - { - setDashboardAttachmentReady(false); - }} - onSave={handleAttachToDashboardSave} - /> - ) : null} ); }; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx index 7e24a0726a829..a55a93853344b 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx @@ -30,6 +30,7 @@ import { EuiBadge, EuiToolTip, } from '@elastic/eui'; +import { kibanaService } from '../../../../../utils/kibana_service'; import { PROFILE_OPTIONS, ThrottlingConfigFieldProps, @@ -60,7 +61,6 @@ import { TextArea, ThrottlingWrapper, } from './field_wrappers'; -import { getDocLinks } from '../../../../../kibana_services'; import { useMonitorName } from '../../../hooks/use_monitor_name'; import { ConfigKey, @@ -1332,7 +1332,7 @@ export const FIELD = (readOnly?: boolean): FieldMap => ({ })} {i18n.translate('xpack.synthetics.monitorConfig.playwrightOptions.learnMore', { diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/grid_by_group/grid_group_item.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/grid_by_group/grid_group_item.tsx index 8f92887da6ba8..7fea62b348edd 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/grid_by_group/grid_group_item.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/grid_by_group/grid_group_item.tsx @@ -17,6 +17,7 @@ import { EuiTablePagination, } from '@elastic/eui'; import React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; import { useSelector } from 'react-redux'; import { useKey } from 'react-use'; import { OverviewLoader } from '../overview_loader'; @@ -49,7 +50,7 @@ export const GroupGridItem = ({ const downMonitors = groupMonitors.filter((monitor) => { const downConfigs = overviewStatus?.downConfigs; if (downConfigs) { - return downConfigs[`${monitor.configId}-${monitor.location?.label}`]?.status === 'down'; + return downConfigs[`${monitor.configId}-${monitor.location?.id}`]?.status === 'down'; } }); @@ -96,14 +97,17 @@ export const GroupGridItem = ({ } extraAction={ - + { if (fullScreenGroup) { setFullScreenGroup(''); @@ -117,7 +121,30 @@ export const GroupGridItem = ({ - {groupMonitors.length} Monitors + + {i18n.translate('xpack.synthetics.groupGridItem.monitorsBadgeLabel.downCount', { + defaultMessage: '{downCount} Down', + values: { downCount: downMonitorsCount }, + })} + + + + + + {i18n.translate('xpack.synthetics.groupGridItem.monitorsBadgeLabel.upCount', { + defaultMessage: '{upCount} Up', + values: { upCount: groupMonitors.length - downMonitorsCount }, + })} + + + + + + {i18n.translate('xpack.synthetics.groupGridItem.monitorsBadgeLabel.count', { + defaultMessage: '{count, number} {count, plural, one {monitor} other {monitors}}', + values: { count: groupMonitors.length }, + })} + } @@ -145,7 +172,10 @@ export const GroupGridItem = ({ )} { if (!urlGroupField && groupField !== 'none' && !isUrlHydratedFromRedux.current) { // Hydrate url only during initialization updateUrlParams({ groupBy: groupField, groupOrderBy: groupOrder }); - } else { - dispatch( - setOverviewGroupByAction({ - field: urlGroupField ?? 'none', - order: urlGroupOrderBy ?? 'asc', - }) - ); } } isUrlHydratedFromRedux.current = true; @@ -48,6 +41,21 @@ export const GroupFields = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [dispatch, groupField, groupOrder, urlGroupField, urlGroupOrderBy]); + const isUReduxHydratedFromUrl = useRef(false); + + useEffect(() => { + if (urlGroupField && urlGroupField !== groupField && !isUReduxHydratedFromUrl.current) { + dispatch( + setOverviewGroupByAction({ + field: urlGroupField ?? 'none', + order: urlGroupOrderBy ?? 'asc', + }) + ); + } + isUReduxHydratedFromUrl.current = true; + // Only depend on the serialized snapshot + }, [dispatch, groupField, groupOrder, urlGroupField, urlGroupOrderBy]); + const handleChange = (groupByState: GroupByState) => { dispatch(setOverviewGroupByAction(groupByState)); updateUrlParams({ groupBy: groupByState.field, groupOrderBy: groupByState.order }); diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/metric_item_icon.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/metric_item_icon.tsx index 7dacc511c2e70..8945726bc443b 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/metric_item_icon.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/metric_item_icon.tsx @@ -18,6 +18,8 @@ import { EuiCallOut, EuiFlexGroup, EuiFlexItem, + EuiLink, + EuiSpacer, } from '@elastic/eui'; import { useDispatch, useSelector } from 'react-redux'; import styled from 'styled-components'; @@ -148,6 +150,21 @@ export const MetricItemIcon = ({
+ {ping?.url?.full && ( + <> + {i18n.translate('xpack.synthetics.metricItemIcon.div.urlLabel', { + defaultMessage: 'URL: ', + })} + + {ping.url.full} + + + + )}
@@ -164,6 +181,23 @@ export const MetricItemIcon = ({ ); } else { + if (ping?.url) { + return ( + + + + ); + } return null; } }; @@ -184,8 +218,10 @@ const StyledIcon = euiStyled.div<{ boxShadow: string }>` gap: 10px; width: 32px; height: 32px; - background: #ffffff; - border: 1px solid #d3dae6; + background: ${({ theme }) => + theme.darkMode ? theme.eui.euiColorDarkestShade : theme.eui.euiColorLightestShade}; + border: 1px solid ${({ theme }) => + theme.darkMode ? theme.eui.euiColorDarkShade : theme.eui.euiColorLightShade}; ${({ boxShadow }) => boxShadow} border-radius: 16px; flex: none; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_grid.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_grid.tsx index 49f21acc20f10..3da7b03f3ad9e 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_grid.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_grid.tsx @@ -14,7 +14,10 @@ import { EuiSpacer, EuiButtonEmpty, EuiText, + EuiProgress, } from '@elastic/eui'; +import { SYNTHETICS_MONITORS_EMBEDDABLE } from '../../../../../embeddables/constants'; +import { AddToDashboard } from '../../../common/components/add_to_dashboard'; import { useOverviewStatus } from '../../hooks/use_overview_status'; import { useInfiniteScroll } from './use_infinite_scroll'; import { GridItemsByGroup } from './grid_by_group/grid_items_by_group'; @@ -40,6 +43,7 @@ export const OverviewGrid = memo(() => { data: { monitors }, flyoutConfig, loaded, + loading, pageState, groupBy: { field: groupField }, } = useSelector(selectOverviewState); @@ -76,7 +80,7 @@ export const OverviewGrid = memo(() => { <> @@ -87,6 +91,10 @@ export const OverviewGrid = memo(() => { total={status ? monitorsSortedByStatus.length : undefined} /> + + + + setPage(1)} /> @@ -94,7 +102,9 @@ export const OverviewGrid = memo(() => { - + + {loading && } + <> {groupField === 'none' ? ( loaded && currentMonitors.length ? ( diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_status.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_status.tsx index 28eaf97a37c5f..4f089b2464ed9 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_status.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_status.tsx @@ -9,8 +9,6 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiStat } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { Subject } from 'rxjs'; -import { useSyntheticsRefreshContext } from '../../../../contexts'; import { EmbeddablePanelWrapper } from '../../../common/components/embeddable_panel_wrapper'; import { clearOverviewStatusErrorAction } from '../../../../state/overview_status'; import { kibanaService } from '../../../../../../utils/kibana_service'; @@ -21,11 +19,9 @@ function title(t?: number) { return t ?? '-'; } -export function OverviewStatus({ reload$ }: { reload$?: Subject }) { +export function OverviewStatus({ titleAppend }: { titleAppend?: React.ReactNode }) { const { statusFilter } = useGetUrlParams(); - const { refreshApp } = useSyntheticsRefreshContext(); - const { status, error: statusError, @@ -39,14 +35,6 @@ export function OverviewStatus({ reload$ }: { reload$?: Subject }) { disabledCount: status?.disabledCount, }); - useEffect(() => { - const sub = reload$?.subscribe(() => { - refreshApp(); - }); - - return () => sub?.unsubscribe(); - }, [refreshApp, reload$]); - useEffect(() => { if (statusError) { dispatch(clearOverviewStatusErrorAction()); @@ -104,9 +92,9 @@ export function OverviewStatus({ reload$ }: { reload$?: Subject }) { }, [status, statusFilter]); return ( - + - + > = ({ children }) => { +export const SyntheticsRefreshContextProvider: FC<{ + reload$?: Subject; +}> = ({ children, reload$ }) => { const [lastRefresh, setLastRefresh] = useState(Date.now()); const refreshPaused = useSelector(selectRefreshPaused); @@ -51,6 +53,13 @@ export const SyntheticsRefreshContextProvider: FC> = } }, [refreshApp, refreshPaused]); + useEffect(() => { + const subscription = reload$?.subscribe(() => { + refreshApp(); + }); + return () => subscription?.unsubscribe(); + }, [reload$, refreshApp]); + const value = useMemo(() => { return { lastRefresh, diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/contexts/synthetics_shared_context.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/contexts/synthetics_shared_context.tsx index b4a2702626285..da35fb89dbf3b 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/contexts/synthetics_shared_context.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/contexts/synthetics_shared_context.tsx @@ -10,18 +10,16 @@ import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { Provider as ReduxProvider } from 'react-redux'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; +import { Subject } from 'rxjs'; +import { Store } from 'redux'; import { SyntheticsRefreshContextProvider } from './synthetics_refresh_context'; import { SyntheticsDataViewContextProvider } from './synthetics_data_view_context'; import { SyntheticsAppProps } from './synthetics_settings_context'; import { storage, store } from '../state'; -export const SyntheticsSharedContext: React.FC = ({ - coreStart, - setupPlugins, - startPlugins, - children, - darkMode, -}) => { +export const SyntheticsSharedContext: React.FC< + SyntheticsAppProps & { reload$?: Subject; reduxStore?: Store } +> = ({ reduxStore, coreStart, setupPlugins, startPlugins, children, darkMode, reload$ }) => { return ( = ({ }} > - - + + = (dependencies: { - core: CoreStart; - plugins: ClientPluginsStart; -}) => TAlertTypeModel; +import type { AlertTypeInitializer } from './types'; export const syntheticsAlertTypeInitializers: AlertTypeInitializer[] = [ initMonitorStatusAlertType, diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx index ba86407859408..5f63d6ac298c7 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx @@ -16,7 +16,8 @@ import { STATE_ID } from '../../../../../common/field_names'; import { SyntheticsMonitorStatusTranslations } from '../../../../../common/rules/synthetics/translations'; import type { StatusRuleParams } from '../../../../../common/rules/status_rule'; import { SYNTHETICS_ALERT_RULE_TYPES } from '../../../../../common/constants/synthetics_alerts'; -import type { AlertTypeInitializer } from '.'; +import type { AlertTypeInitializer } from './types'; + const { defaultActionMessage, defaultRecoveryMessage, description } = SyntheticsMonitorStatusTranslations; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx index 15c0fa90ec605..896a84cd1688c 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx @@ -14,12 +14,14 @@ import { TlsTranslations } from '../../../../../common/rules/synthetics/translat import { CERTIFICATES_ROUTE } from '../../../../../common/constants/ui'; import { SYNTHETICS_ALERT_RULE_TYPES } from '../../../../../common/constants/synthetics_alerts'; import type { TLSParams } from '../../../../../common/runtime_types/alerts/tls'; -import { AlertTypeInitializer } from '.'; + +import type { AlertTypeInitializer } from './types'; let validateFunc: (ruleParams: any) => ValidationResult; const { defaultActionMessage, defaultRecoveryMessage, description } = TlsTranslations; const TLSAlert = React.lazy(() => import('./lazy_wrapper/tls_alert')); + export const initTlsAlertType: AlertTypeInitializer = ({ core, plugins, diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/types.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/types.ts new file mode 100644 index 0000000000000..baf1f6c75801c --- /dev/null +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/lib/alert_types/types.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ObservabilityRuleTypeModel } from '@kbn/observability-plugin/public'; +import { CoreStart } from '@kbn/core-lifecycle-browser'; +import type { ClientPluginsStart } from '../../../../plugin'; + +export type AlertTypeInitializer = (dependencies: { + core: CoreStart; + plugins: ClientPluginsStart; +}) => TAlertTypeModel; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/api.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/api.ts index 7244efc4dc655..cc496074332b0 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/api.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/api.ts @@ -36,6 +36,7 @@ export function toStatusOverviewQueryArgs( projects: pageState.projects, schedules: pageState.schedules, monitorTypes: pageState.monitorTypes, + monitorQueryIds: pageState.monitorQueryIds, searchFields: [], }; } diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/index.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/index.ts index 3f8038ffc84d3..665a92aeaf773 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/index.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/overview/index.ts @@ -11,6 +11,7 @@ import { MonitorOverviewState } from './models'; import { fetchMonitorOverviewAction, + quietFetchOverviewAction, setFlyoutConfig, setOverviewGroupByAction, setOverviewPageStateAction, @@ -44,6 +45,9 @@ export const monitorOverviewReducer = createReducer(initialState, (builder) => { state.loading = true; state.loaded = false; }) + .addCase(quietFetchOverviewAction.get, (state, action) => { + state.loading = true; + }) .addCase(fetchMonitorOverviewAction.success, (state, action) => { state.data = action.payload; state.loading = false; diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/store.ts b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/store.ts index 19320f0102a99..c88f126edeb52 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/store.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/state/store.ts @@ -20,7 +20,6 @@ export const store = configureStore({ preloadedState: {}, enhancers: [], }); - sagaMW.run(rootEffect); export const storage = new Storage(window.localStorage); diff --git a/x-pack/plugins/observability_solution/synthetics/public/kibana_services.ts b/x-pack/plugins/observability_solution/synthetics/public/kibana_services.ts deleted file mode 100644 index 9c3f641c29a80..0000000000000 --- a/x-pack/plugins/observability_solution/synthetics/public/kibana_services.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { CoreStart } from '@kbn/core/public'; - -type StartServices = Pick; - -let coreStart: CoreStart; -export function setStartServices(core: CoreStart) { - coreStart = core; -} - -export const getStartServices = (): StartServices => coreStart; - -export const getDocLinks = () => coreStart?.docLinks; diff --git a/x-pack/plugins/observability_solution/synthetics/public/plugin.ts b/x-pack/plugins/observability_solution/synthetics/public/plugin.ts index 4489d418830e5..15de2de6d5eee 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/plugin.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/plugin.ts @@ -66,7 +66,6 @@ import { kibanaService } from './utils/kibana_service'; import { PLUGIN } from '../common/constants/plugin'; import { OVERVIEW_ROUTE } from '../common/constants/ui'; import { locators } from './apps/locators'; -import { setStartServices } from './kibana_services'; import { syntheticsAlertTypeInitializers } from './apps/synthetics/lib/alert_types'; export interface ClientPluginsSetup { @@ -216,9 +215,6 @@ export class SyntheticsPlugin public start(coreStart: CoreStart, pluginsStart: ClientPluginsStart): void { const { triggersActionsUi } = pluginsStart; - setStartServices(coreStart); - - setStartServices(coreStart); syntheticsAlertTypeInitializers.forEach((init) => { const { observabilityRuleTypeRegistry } = pluginsStart.observability; diff --git a/x-pack/plugins/observability_solution/synthetics/public/utils/api_service/api_service.ts b/x-pack/plugins/observability_solution/synthetics/public/utils/api_service/api_service.ts index 682b3be6a700a..9a0b887a7d6eb 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/utils/api_service/api_service.ts +++ b/x-pack/plugins/observability_solution/synthetics/public/utils/api_service/api_service.ts @@ -9,8 +9,10 @@ import { isRight } from 'fp-ts/lib/Either'; import { formatErrors } from '@kbn/securitysolution-io-ts-utils'; import { HttpFetchQuery, HttpHeadersInit, HttpSetup } from '@kbn/core/public'; import { FETCH_STATUS, AddInspectorRequest } from '@kbn/observability-shared-plugin/public'; -import { InspectorRequestProps } from '@kbn/observability-shared-plugin/public/contexts/inspector/inspector_context'; +import type { InspectorRequestProps } from '@kbn/observability-shared-plugin/public/contexts/inspector/inspector_context'; + type Params = HttpFetchQuery & { version?: string }; + class ApiService { private static instance: ApiService; private _http!: HttpSetup; diff --git a/x-pack/plugins/observability_solution/synthetics/server/routes/common.ts b/x-pack/plugins/observability_solution/synthetics/server/routes/common.ts index b29e3578aba87..491b67160677e 100644 --- a/x-pack/plugins/observability_solution/synthetics/server/routes/common.ts +++ b/x-pack/plugins/observability_solution/synthetics/server/routes/common.ts @@ -44,6 +44,7 @@ export const OverviewStatusSchema = schema.object({ monitorTypes: StringOrArraySchema, locations: StringOrArraySchema, projects: StringOrArraySchema, + monitorQueryIds: StringOrArraySchema, schedules: StringOrArraySchema, status: StringOrArraySchema, scopeStatusByLocation: schema.maybe(schema.boolean()), diff --git a/x-pack/plugins/observability_solution/synthetics/server/routes/suggestions/route.ts b/x-pack/plugins/observability_solution/synthetics/server/routes/suggestions/route.ts index ae729e7361a4d..3a9c3b064bc0f 100644 --- a/x-pack/plugins/observability_solution/synthetics/server/routes/suggestions/route.ts +++ b/x-pack/plugins/observability_solution/synthetics/server/routes/suggestions/route.ts @@ -30,6 +30,9 @@ interface AggsResponse { projectsAggs: { buckets: Buckets; }; + monitorTypeAggs: { + buckets: Buckets; + }; monitorIdsAggs: { buckets: Array<{ key: string; @@ -82,7 +85,7 @@ export const getSyntheticsSuggestionsRoute: SyntheticsRestApiRouteFactory< searchFields: SEARCH_FIELDS, }); - const { tagsAggs, locationsAggs, projectsAggs, monitorIdsAggs } = + const { monitorTypeAggs, tagsAggs, locationsAggs, projectsAggs, monitorIdsAggs } = (data?.aggregations as AggsResponse) ?? {}; const allLocationsMap = new Map(allLocations.map((obj) => [obj.id, obj.label])); @@ -110,6 +113,12 @@ export const getSyntheticsSuggestionsRoute: SyntheticsRestApiRouteFactory< value: key, count, })) ?? [], + monitorTypes: + monitorTypeAggs?.buckets?.map(({ key, doc_count: count }) => ({ + label: key, + value: key, + count, + })) ?? [], }; } catch (error) { logger.error(`Failed to fetch synthetics suggestions: ${error}`); @@ -125,6 +134,13 @@ const aggs = { exclude: [''], }, }, + monitorTypeAggs: { + terms: { + field: `${syntheticsMonitorType}.attributes.${ConfigKey.MONITOR_TYPE}.keyword`, + size: 10000, + exclude: [''], + }, + }, locationsAggs: { terms: { field: `${syntheticsMonitorType}.attributes.${ConfigKey.LOCATIONS}.id`, diff --git a/x-pack/test/api_integration/apis/synthetics/suggestions.ts b/x-pack/test/api_integration/apis/synthetics/suggestions.ts index bbdac399714de..dab822f832c08 100644 --- a/x-pack/test/api_integration/apis/synthetics/suggestions.ts +++ b/x-pack/test/api_integration/apis/synthetics/suggestions.ts @@ -161,6 +161,18 @@ export default function ({ getService }: FtrProviderContext) { value: project, }, ], + monitorTypes: [ + { + count: 20, + label: 'http', + value: 'http', + }, + { + count: 2, + label: 'icmp', + value: 'icmp', + }, + ], tags: expect.arrayContaining([ { count: 21, @@ -237,6 +249,18 @@ export default function ({ getService }: FtrProviderContext) { value: project, }, ], + monitorTypes: [ + // { + // count: 20, + // label: 'http', + // value: 'http', + // }, + { + count: 2, + label: 'icmp', + value: 'icmp', + }, + ], tags: expect.arrayContaining([ { count: 1,