Skip to content

remove show_all_group_by_instances from schema and change UI to selec…#8

Open
mgiota wants to merge 1 commit intoslo_alerts_schema_registrationfrom
slo_alerts_schema_refactoring
Open

remove show_all_group_by_instances from schema and change UI to selec…#8
mgiota wants to merge 1 commit intoslo_alerts_schema_registrationfrom
slo_alerts_schema_refactoring

Conversation

@mgiota
Copy link
Copy Markdown
Owner

@mgiota mgiota commented Mar 16, 2026

Fixes elastic#257868 (comment)

Screen.Recording.2026-03-16.at.14.40.31.mov

@mgiota mgiota self-assigned this Mar 16, 2026
mgiota pushed a commit that referenced this pull request Apr 2, 2026
Closes elastic#258318
Closes elastic#258319

## Summary

Adds logic to the alert episodes table to display `.alert_actions`
information.

This includes:
- New action-specific API paths.
- Snooze
  - **Per group hash.**
- Button in the actions column opens a popover where an `until` can be
picked.
  - **When snoozed**
    - A bell shows up in the status column.
- Mouse over the bell icon to see until when the snooze is in effect.
- Unsnooze
  - **Per group hash.**
  - Clicking the button removes the snooze.
- Ack/Unack
  - **Per episode.**
  - Button in the actions column
  - When "acked", an icon shows in the status column.
- Tags
- This PR only handles displaying tags. They need to be created via API.
- Resolve/Unresolve
  - **Per group hash.**
  - Button inside the ellipsis always
- The status is turned to `inactive` **regardless of the "real"
status.**

<img width="1704" height="672" alt="Screenshot 2026-03-25 at 16 04 12"
src="https://github.com/user-attachments/assets/5ef4111a-6e0c-4114-a60e-ce5f81a86ac6"
/>


## Testing


<details> <summary>POST mock episodes</summary>

```
POST _bulk
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:00:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:01:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "pending" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:02:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:03:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "inactive" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:04:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:05:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:06:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-001", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:07:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:08:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "active" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:09:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "recovering" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:10:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "recovering" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:11:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:12:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "recovering" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:13:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-2", "episode": { "id": "ep-002", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:14:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-003", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:15:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-1", "episode": { "id": "ep-003", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:16:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-4", "episode": { "id": "ep-004", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:17:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-4", "episode": { "id": "ep-004", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:18:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-4", "episode": { "id": "ep-004", "status": "recovering" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:19:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-4", "episode": { "id": "ep-004", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:20:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-5", "episode": { "id": "ep-005", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:21:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-5", "episode": { "id": "ep-005", "status": "pending" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:22:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "gh-5", "episode": { "id": "ep-005", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:23:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-006", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:24:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-006", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:25:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-006", "status": "active" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:26:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-1" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-006", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:14:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-2" }, "group_hash": "gh-7", "episode": { "id": "ep-007", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:15:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-2" }, "group_hash": "gh-7", "episode": { "id": "ep-007", "status": "inactive" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:16:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-3" }, "group_hash": "gh-8", "episode": { "id": "ep-008", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:17:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-3" }, "group_hash": "gh-8", "episode": { "id": "ep-008", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:18:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-3" }, "group_hash": "gh-8", "episode": { "id": "ep-008", "status": "recovering" }, "status": "recovered" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:20:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-4" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-009", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:21:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-4" }, "group_hash": "elasticgh-9", "episode": { "id": "ep-009", "status": "pending" }, "status": "no_data" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:23:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-5" }, "group_hash": "elasticgh-10", "episode": { "id": "ep-010", "status": "pending" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:24:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-5" }, "group_hash": "elasticgh-10", "episode": { "id": "ep-010", "status": "active" }, "status": "breached" }
{ "create": { "_index": ".rule-events" }}
{ "@timestamp": "2026-01-27T16:25:00.000Z", "source": "internal", "type": "alert", "rule": { "id": "rule-5" }, "group_hash": "elasticgh-10", "episode": { "id": "ep-010", "status": "active" }, "status": "no_data" }
```

</details>

- In the POST above, episodes 1 and 3, and episodes 6 and 9 have the
same group hashes.
- Go to `https://localhost:5601/app/observability/alerts-v2` and try all
buttons.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
mgiota added a commit to elastic/kibana that referenced this pull request Apr 2, 2026
Fixes #252816
Fixes #257868

Legacy alerts embeddable saved state contained `showAllGroupByInstances`
and `slos` (`id`, `instanceId`, `name`, `groupBy`).

As part of this PR we do following changes (More context on [this
issue](#257868)):
- remove `showAllGroupByInstances` and keep slo_instance_id as the sole
source of truth
- remove `name` and groupBy` from schema. An SLO with updated name for
example can lead to stale UI representation in the dashboard app.


## Acceptance criteria
- schemas are registered server side
- transforms are registered, where legacy stored shape is converted to
REST API shape
- REST API should be snake_case
- public embeddable code should be updated to use new snake_case shape
- types should be derived from schemas, duplicative type declarations
should be removed
- ensure backwards compatibility: confirm previously stored SLO error
alert embeddables continue to work as expected
- drilldown support
- register SLO embeddable transform out in
embeddablePlugin.registerLegacyURLTransform: Dashboard allows users to
share unsaved dashboard changes. This feature stores embeddable state in
URLs.

## Testing OAS documentation
- add `server.oas.enabled: true` to config/kibana.dev.yml
- start kibana with `yarn start --no-base-path`
- Copy paste URL
http://localhost:5601/api/oas?pathStartsWith=/api/dashboard&access=internal&version=1
into your browser.
- View panels schema and verify slo alerts embeddable schema appears in
the list.

## Testing validation
Try to create a few dashboards with alerts embeddable through API calls
in Kibana dev tools and verify validation and creation work as expected.

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Testing empty alerts embeddable through API call",
  "panels": [
    {
      "config": {},
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Test a group by SLO with all instances",
  "panels": [
    {
      "config": {
        "slos": [
            {
                "slo_id": "6b523190-9da5-4bbc-8c37-fa3f3a3f5046",
                "slo_instance_id": "*"
            }
        ]
      },
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Test a group by SLO with a specific instance",
  "panels": [
    {
      "config": {
        "slos": [
            {
                "slo_id": "6b523190-9da5-4bbc-8c37-fa3f3a3f5046",
                "slo_instance_id": "something"
            }
        ]
      },
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```


## Reference

Regarding removal of `showAllGroupByInstances` we explored two
approaches, **1)** keep the flag and normalize on load and **2)** remove
the flag entirely.

<img width="400" height="676" alt="Screenshot 2026-03-18 at 11 18 47"
src="https://github.com/user-attachments/assets/ea6909f6-e98c-4bad-ac66-05c738e54126"
/>

I proceeded with `Option 2: remove the flag entirely` plus the simplest
required UI change, where SLO selector support picking all instances (*)
for group-by SLOs.

<img width="400" height="301" alt="Screenshot 2026-03-18 at 11 44 49"
src="https://github.com/user-attachments/assets/6c0a966b-6481-4381-8608-a8e1afdff97f"
/>

I decided not to proceed with a full UI refactoring implemented in this
[PR](mgiota#8). This change can be done
as a follow up after the schema registration PR is merged, if we decide
we want to change the way we select SLOs in the alerts embeddable.

<img width="400" height="474" alt="Screenshot 2026-03-18 at 11 41 33"
src="https://github.com/user-attachments/assets/710a816f-3c40-42ae-ac65-6f13aac846e7"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Faisal Kanout <faisal@kanout.com>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
Fixes elastic#252816
Fixes elastic#257868

Legacy alerts embeddable saved state contained `showAllGroupByInstances`
and `slos` (`id`, `instanceId`, `name`, `groupBy`).

As part of this PR we do following changes (More context on [this
issue](elastic#257868)):
- remove `showAllGroupByInstances` and keep slo_instance_id as the sole
source of truth
- remove `name` and groupBy` from schema. An SLO with updated name for
example can lead to stale UI representation in the dashboard app.


## Acceptance criteria
- schemas are registered server side
- transforms are registered, where legacy stored shape is converted to
REST API shape
- REST API should be snake_case
- public embeddable code should be updated to use new snake_case shape
- types should be derived from schemas, duplicative type declarations
should be removed
- ensure backwards compatibility: confirm previously stored SLO error
alert embeddables continue to work as expected
- drilldown support
- register SLO embeddable transform out in
embeddablePlugin.registerLegacyURLTransform: Dashboard allows users to
share unsaved dashboard changes. This feature stores embeddable state in
URLs.

## Testing OAS documentation
- add `server.oas.enabled: true` to config/kibana.dev.yml
- start kibana with `yarn start --no-base-path`
- Copy paste URL
http://localhost:5601/api/oas?pathStartsWith=/api/dashboard&access=internal&version=1
into your browser.
- View panels schema and verify slo alerts embeddable schema appears in
the list.

## Testing validation
Try to create a few dashboards with alerts embeddable through API calls
in Kibana dev tools and verify validation and creation work as expected.

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Testing empty alerts embeddable through API call",
  "panels": [
    {
      "config": {},
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Test a group by SLO with all instances",
  "panels": [
    {
      "config": {
        "slos": [
            {
                "slo_id": "6b523190-9da5-4bbc-8c37-fa3f3a3f5046",
                "slo_instance_id": "*"
            }
        ]
      },
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```

```
POST kbn:/api/dashboards?apiVersion=1
{
  "title": "Test a group by SLO with a specific instance",
  "panels": [
    {
      "config": {
        "slos": [
            {
                "slo_id": "6b523190-9da5-4bbc-8c37-fa3f3a3f5046",
                "slo_instance_id": "something"
            }
        ]
      },
      "grid": {
        "x": 1,
        "y": 0
      },
      "type": "slo_alerts"
    }
  ]
}
```


## Reference

Regarding removal of `showAllGroupByInstances` we explored two
approaches, **1)** keep the flag and normalize on load and **2)** remove
the flag entirely.

<img width="400" height="676" alt="Screenshot 2026-03-18 at 11 18 47"
src="https://github.com/user-attachments/assets/ea6909f6-e98c-4bad-ac66-05c738e54126"
/>

I proceeded with `Option 2: remove the flag entirely` plus the simplest
required UI change, where SLO selector support picking all instances (*)
for group-by SLOs.

<img width="400" height="301" alt="Screenshot 2026-03-18 at 11 44 49"
src="https://github.com/user-attachments/assets/6c0a966b-6481-4381-8608-a8e1afdff97f"
/>

I decided not to proceed with a full UI refactoring implemented in this
[PR](mgiota#8). This change can be done
as a follow up after the schema registration PR is merged, if we decide
we want to change the way we select SLOs in the alerts embeddable.

<img width="400" height="474" alt="Screenshot 2026-03-18 at 11 41 33"
src="https://github.com/user-attachments/assets/710a816f-3c40-42ae-ac65-6f13aac846e7"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Faisal Kanout <faisal@kanout.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant