Skip to content

[Dataset quality] degradedDocs rule#216026

Merged
yngrdyn merged 81 commits intoelastic:mainfrom
yngrdyn:179173-dataset-quality-create-rules-for-degraded-documents
Jun 23, 2025
Merged

[Dataset quality] degradedDocs rule#216026
yngrdyn merged 81 commits intoelastic:mainfrom
yngrdyn:179173-dataset-quality-create-rules-for-degraded-documents

Conversation

@yngrdyn
Copy link
Copy Markdown
Contributor

@yngrdyn yngrdyn commented Mar 26, 2025

Closes #179173.

Rule type

A dedicated stack rule type was created datasetQuality.degradedDocs.
image
image

This new rule is aggregated by default using _index and could be further configured by the user (e.g. user can also aggregate by cloud.provider).

A new rule type was needed to be created since there is no actual way to aggregate all documents in a dataStream if we use a DataView like logs-*-*. Inside datasStream documents there is no indication about the dataStream where they belong to, instead we just have _index which contains backingIndexName instead of actual index.

It's important to note, that this rule type is also visible from Observability > Alerts, which is useful specially for serverless.

Screen.Recording.2025-04-09.at.16.44.56.mov

Role Based Access-Control (RBAC)

RBAC for dataset quality alerts is defined within dataQuality kibana feature.
We have three privileges defined:

  1. all: This privilege now contains a subFeature manage_rules that will allow for more granularity on alerting level. It's by default assigned to all but can be disabled.
  2. read: This privilege is only related to serverless (when we don't have yet custom roles).
    https://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71
  3. none: This privilege is only relevant for stateful (in serverless we don't have custom roles).

🎥 Demo

Serverless

all privileges

Screen.Recording.2025-04-09.at.14.30.38.mov

read privileges

Screen.Recording.2025-04-09.at.14.28.31.mov

Stateful

all privileges

Screen.Recording.2025-04-09.at.15.01.24.mov

all privileges with subFeature disabled

Screen.Recording.2025-04-09.at.13.03.31.mov

none privileges (Stateful)

Screen.Recording.2025-04-09.at.14.45.26.mov

How to test?

  1. run synthrace scenario degraded_logs in live mode
node scripts/synthtrace degraded_logs --live
  1. Open dataset quality page (/app/management/data/data_quality)
  2. Select synth.3 dataset (/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)
  3. Click on Actions and then select Create rule
  4. Fill out the alert form
  5. Go to Observability > Alerts or Stack management > Alerts (/app/observability/alerts)

Release note

Adds the Create alert rule action to dataset quality page and dataset quality details. This allows you to generate an alert when the percentage of degraded docs on the chart crosses a certain threshold.

@yngrdyn yngrdyn force-pushed the 179173-dataset-quality-create-rules-for-degraded-documents branch from 2e04aa7 to bcc8933 Compare March 28, 2025 11:37
@yngrdyn yngrdyn force-pushed the 179173-dataset-quality-create-rules-for-degraded-documents branch from eb8cdbe to f4ee7fb Compare April 7, 2025 12:24
@yngrdyn yngrdyn force-pushed the 179173-dataset-quality-create-rules-for-degraded-documents branch from f4ee7fb to cc07f07 Compare April 7, 2025 12:24
@yngrdyn yngrdyn force-pushed the 179173-dataset-quality-create-rules-for-degraded-documents branch 2 times, most recently from 45750ac to d74ec14 Compare April 9, 2025 09:37
@yngrdyn yngrdyn force-pushed the 179173-dataset-quality-create-rules-for-degraded-documents branch from d74ec14 to 4fd4612 Compare April 9, 2025 12:10
@yngrdyn
Copy link
Copy Markdown
Contributor Author

yngrdyn commented Jun 19, 2025

I didn't test that locally, but do we expect this to work for remote clusters as well? I would guess yes, but just to make sure.

@flash1293 yes, it works for remote clusters

Screen.Recording.2025-06-19.at.09.57.57.mov

Copy link
Copy Markdown
Contributor

@denar50 denar50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes related to @elastic/security-detection-engine LGTM. Code review only.

yngrdyn added 3 commits June 19, 2025 12:29
…nts' of github.com:yngrdyn/kibana into 179173-dataset-quality-create-rules-for-degraded-documents
@yngrdyn
Copy link
Copy Markdown
Contributor Author

yngrdyn commented Jun 19, 2025

The rule creation form should block the user from moving to the next step if the required fields are not filled out/configured.

Thanks for catching this @fkanout! I was missing to add the validation to errors object c8da5f0.

Screen.Recording.2025-06-19.at.12.27.25.mov

Copy link
Copy Markdown
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yngrdyn, thanks for handling the points I shared. LGTM

@yngrdyn yngrdyn enabled auto-merge (squash) June 23, 2025 04:51
Copy link
Copy Markdown
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, approving because I think it's good for merge but there are some improvements we coud/should make.

Somehow the red highlighted area does not include the very last bucket:
Screenshot 2025-06-23 at 10 47 57

Not sure whether we can control that, but in the "Document summary" of the alert, it doesn't show the grouping fields which are obviously very important:
Screenshot 2025-06-23 at 10 49 50

Screenshot 2025-06-23 at 10 49 38

Should we add that to the summary table? cc @LucaWintergerst

The "Reason" does list the grouping fields, but it doesn't give the field names

@yngrdyn yngrdyn merged commit 64df229 into elastic:main Jun 23, 2025
10 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15820549948

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #119 / event_log Event Log public API Legacy Ids "before all" hook for "should support search event by ids and legacyIds"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alerting 220 221 +1
apm 1925 1926 +1
cases 1022 1023 +1
datasetQuality 443 738 +295
discover 1322 1323 +1
embeddableAlertsTable 408 409 +1
infra 1443 1444 +1
ml 2406 2407 +1
monitoring 631 632 +1
observability 1311 1312 +1
observabilityAIAssistantApp 321 322 +1
observabilityShared 199 200 +1
securitySolution 7670 7671 +1
slo 1183 1184 +1
stackAlerts 292 293 +1
synthetics 1247 1248 +1
timelines 144 145 +1
transform 694 695 +1
triggersActionsUi 876 877 +1
uptime 773 774 +1
total +314

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/rule-data-utils 183 185 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
datasetQuality 254.3KB 418.0KB +163.6KB
observability 1.3MB 1.3MB +162.0B
total +163.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
datasetQuality 20.6KB 23.8KB +3.3KB
observability 93.6KB 93.6KB +43.0B
total +3.3KB
Unknown metric groups

API count

id before after diff
@kbn/rule-data-utils 196 198 +2

async chunk count

id before after diff
datasetQuality 13 16 +3

ESLint disabled line counts

id before after diff
datasetQuality 19 21 +2

miscellaneous assets size

id before after diff
datasetQuality 0.0B 178.3KB +178.3KB

References to deprecated APIs

id before after diff
datasetQuality 1 2 +1

Total ESLint disabled count

id before after diff
datasetQuality 21 23 +2

History

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [Response Ops][Reporting] Scheduled Reports (#221028)

Manual backport

To create the backport manually run:

node scripts/backport --pr 216026

Questions ?

Please refer to the Backport tool documentation

@yngrdyn yngrdyn added the backport This PR is a backport of another PR label Jun 23, 2025
@yngrdyn
Copy link
Copy Markdown
Contributor Author

yngrdyn commented Jun 23, 2025

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

yngrdyn added a commit to yngrdyn/kibana that referenced this pull request Jun 23, 2025
Closes elastic#179173.

## Rule type
A dedicated stack rule type was created `datasetQuality.degradedDocs`.
<img width="1759" alt="image"
src="https://github.com/user-attachments/assets/5004a08d-6f12-4f5e-b27f-5f4db242dcf0"
/>
<img width="2318" alt="image"
src="https://github.com/user-attachments/assets/f8b2664a-f1c6-48c5-a617-c6f1b79bf0f7"
/>

This new rule is aggregated by default using `_index` and could be
further configured by the user (e.g. user can also aggregate by
`cloud.provider`).

A new rule type was needed to be created since there is no actual way to
aggregate all documents in a dataStream if we use a DataView like
`logs-*-*`. Inside datasStream documents there is no indication about
the dataStream where they belong to, instead we just have `_index` which
contains backingIndexName instead of actual index.

It's important to note, that this rule type is also visible from
`Observability > Alerts`, which is useful specially for serverless.

https://github.com/user-attachments/assets/000aee51-4895-4f4c-9484-924ace4325c5

## Role Based Access-Control (RBAC)
RBAC for dataset quality alerts is defined within dataQuality kibana
feature.
We have three privileges defined:
1. `all`: This privilege now contains a subFeature `manage_rules` that
will allow for more granularity on alerting level. It's by default
assigned to `all` but can be disabled.
2. `read`: This privilege is only related to serverless (when we don't
have yet custom roles).

https://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71
3. `none`: This privilege is only relevant for stateful (in serverless
we don't have custom roles).

## 🎥 Demo
### Serverless
#### `all` privileges

https://github.com/user-attachments/assets/8dad6e30-a261-4a69-979f-6dfc2a41c888

#### `read` privileges

https://github.com/user-attachments/assets/e1cb108d-22a0-4e7f-b252-9cc12d1e9d65

### Stateful
#### `all` privileges

https://github.com/user-attachments/assets/d96f3b70-35b2-466b-aa59-a07190d24d93

#### `all` privileges with subFeature disabled

https://github.com/user-attachments/assets/808ab811-9320-43e4-b2a6-06d530a78b82

#### `none` privileges (Stateful)

https://github.com/user-attachments/assets/18f2a2d6-d825-4713-acea-0d72f451e9ab

## How to test?
1. run synthrace scenario `degraded_logs` in live mode
```
node scripts/synthtrace degraded_logs --live
```
2. Open dataset quality page (/app/management/data/data_quality)
3. Select `synth.3` dataset
(/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)
4. Click on `Actions` and then select `Create rule`
5. Fill out the alert form
6. Go to `Observability > Alerts` or `Stack management > Alerts`
(/app/observability/alerts)

## Release note
Adds the Create alert rule action to dataset quality page and dataset
quality details. This allows you to generate an alert when the
percentage of degraded docs on the chart crosses a certain threshold.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@elastic.co>
Co-authored-by: Faisal Kanout <faisal.kanout@elastic.co>
(cherry picked from commit 64df229)

# Conflicts:
#	x-pack/platform/plugins/shared/dataset_quality/kibana.jsonc
#	x-pack/platform/plugins/shared/dataset_quality/public/components/dataset_quality/header.tsx
#	x-pack/platform/plugins/shared/dataset_quality/public/components/dataset_quality_details/header.tsx
#	x-pack/platform/plugins/shared/dataset_quality/tsconfig.json
#	x-pack/test/functional/apps/dataset_quality/dataset_quality_details.ts
yngrdyn added a commit that referenced this pull request Jun 24, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [[Dataset quality] degradedDocs rule
(#216026)](#216026)

<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Yngrid
Coello","email":"yngrid.coello@elastic.co"},"sourceCommit":{"committedDate":"2025-06-23T09:30:14Z","message":"[Dataset
quality] degradedDocs rule (#216026)\n\nCloses
https://github.com/elastic/kibana/issues/179173.\n\n## Rule type\nA
dedicated stack rule type was created
`datasetQuality.degradedDocs`.\n<img width=\"1759\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5004a08d-6f12-4f5e-b27f-5f4db242dcf0\"\n/>\n<img
width=\"2318\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f8b2664a-f1c6-48c5-a617-c6f1b79bf0f7\"\n/>\n\n\nThis
new rule is aggregated by default using `_index` and could be\nfurther
configured by the user (e.g. user can also aggregate
by\n`cloud.provider`).\n\nA new rule type was needed to be created since
there is no actual way to\naggregate all documents in a dataStream if we
use a DataView like\n`logs-*-*`. Inside datasStream documents there is
no indication about\nthe dataStream where they belong to, instead we
just have `_index` which\ncontains backingIndexName instead of actual
index.\n\nIt's important to note, that this rule type is also visible
from\n`Observability > Alerts`, which is useful specially for
serverless.\n\n\nhttps://github.com/user-attachments/assets/000aee51-4895-4f4c-9484-924ace4325c5\n\n\n##
Role Based Access-Control (RBAC)\nRBAC for dataset quality alerts is
defined within dataQuality kibana\nfeature.\nWe have three privileges
defined:\n1. `all`: This privilege now contains a subFeature
`manage_rules` that\nwill allow for more granularity on alerting level.
It's by default\nassigned to `all` but can be disabled.\n2. `read`: This
privilege is only related to serverless (when we don't\nhave yet custom
roles).\n\nhttps://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71\n3.
`none`: This privilege is only relevant for stateful (in serverless\nwe
don't have custom roles).\n\n## 🎥 Demo\n### Serverless\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/8dad6e30-a261-4a69-979f-6dfc2a41c888\n\n####
`read`
privileges\n\nhttps://github.com/user-attachments/assets/e1cb108d-22a0-4e7f-b252-9cc12d1e9d65\n\n###
Stateful\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/d96f3b70-35b2-466b-aa59-a07190d24d93\n\n####
`all` privileges with subFeature
disabled\n\nhttps://github.com/user-attachments/assets/808ab811-9320-43e4-b2a6-06d530a78b82\n\n####
`none` privileges
(Stateful)\n\nhttps://github.com/user-attachments/assets/18f2a2d6-d825-4713-acea-0d72f451e9ab\n\n##
How to test?\n1. run synthrace scenario `degraded_logs` in live
mode\n```\nnode scripts/synthtrace degraded_logs --live\n```\n2. Open
dataset quality page (/app/management/data/data_quality)\n3. Select
`synth.3`
dataset\n(/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)\n4.
Click on `Actions` and then select `Create rule`\n5. Fill out the alert
form\n6. Go to `Observability > Alerts` or `Stack management >
Alerts`\n(/app/observability/alerts)\n\n## Release note\nAdds the Create
alert rule action to dataset quality page and dataset\nquality details.
This allows you to generate an alert when the\npercentage of degraded
docs on the chart crosses a certain
threshold.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Aleh
Zasypkin <aleh.zasypkin@elastic.co>\nCo-authored-by: Faisal Kanout
<faisal.kanout@elastic.co>","sha":"64df229998b0db7e5d381c847e60c0d39e6c3120","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:feature","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0"],"title":"[Dataset
quality] degradedDocs
rule","number":216026,"url":"https://github.com/elastic/kibana/pull/216026","mergeCommit":{"message":"[Dataset
quality] degradedDocs rule (#216026)\n\nCloses
https://github.com/elastic/kibana/issues/179173.\n\n## Rule type\nA
dedicated stack rule type was created
`datasetQuality.degradedDocs`.\n<img width=\"1759\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5004a08d-6f12-4f5e-b27f-5f4db242dcf0\"\n/>\n<img
width=\"2318\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f8b2664a-f1c6-48c5-a617-c6f1b79bf0f7\"\n/>\n\n\nThis
new rule is aggregated by default using `_index` and could be\nfurther
configured by the user (e.g. user can also aggregate
by\n`cloud.provider`).\n\nA new rule type was needed to be created since
there is no actual way to\naggregate all documents in a dataStream if we
use a DataView like\n`logs-*-*`. Inside datasStream documents there is
no indication about\nthe dataStream where they belong to, instead we
just have `_index` which\ncontains backingIndexName instead of actual
index.\n\nIt's important to note, that this rule type is also visible
from\n`Observability > Alerts`, which is useful specially for
serverless.\n\n\nhttps://github.com/user-attachments/assets/000aee51-4895-4f4c-9484-924ace4325c5\n\n\n##
Role Based Access-Control (RBAC)\nRBAC for dataset quality alerts is
defined within dataQuality kibana\nfeature.\nWe have three privileges
defined:\n1. `all`: This privilege now contains a subFeature
`manage_rules` that\nwill allow for more granularity on alerting level.
It's by default\nassigned to `all` but can be disabled.\n2. `read`: This
privilege is only related to serverless (when we don't\nhave yet custom
roles).\n\nhttps://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71\n3.
`none`: This privilege is only relevant for stateful (in serverless\nwe
don't have custom roles).\n\n## 🎥 Demo\n### Serverless\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/8dad6e30-a261-4a69-979f-6dfc2a41c888\n\n####
`read`
privileges\n\nhttps://github.com/user-attachments/assets/e1cb108d-22a0-4e7f-b252-9cc12d1e9d65\n\n###
Stateful\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/d96f3b70-35b2-466b-aa59-a07190d24d93\n\n####
`all` privileges with subFeature
disabled\n\nhttps://github.com/user-attachments/assets/808ab811-9320-43e4-b2a6-06d530a78b82\n\n####
`none` privileges
(Stateful)\n\nhttps://github.com/user-attachments/assets/18f2a2d6-d825-4713-acea-0d72f451e9ab\n\n##
How to test?\n1. run synthrace scenario `degraded_logs` in live
mode\n```\nnode scripts/synthtrace degraded_logs --live\n```\n2. Open
dataset quality page (/app/management/data/data_quality)\n3. Select
`synth.3`
dataset\n(/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)\n4.
Click on `Actions` and then select `Create rule`\n5. Fill out the alert
form\n6. Go to `Observability > Alerts` or `Stack management >
Alerts`\n(/app/observability/alerts)\n\n## Release note\nAdds the Create
alert rule action to dataset quality page and dataset\nquality details.
This allows you to generate an alert when the\npercentage of degraded
docs on the chart crosses a certain
threshold.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Aleh
Zasypkin <aleh.zasypkin@elastic.co>\nCo-authored-by: Faisal Kanout
<faisal.kanout@elastic.co>","sha":"64df229998b0db7e5d381c847e60c0d39e6c3120"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216026","number":216026,"mergeCommit":{"message":"[Dataset
quality] degradedDocs rule (#216026)\n\nCloses
https://github.com/elastic/kibana/issues/179173.\n\n## Rule type\nA
dedicated stack rule type was created
`datasetQuality.degradedDocs`.\n<img width=\"1759\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/5004a08d-6f12-4f5e-b27f-5f4db242dcf0\"\n/>\n<img
width=\"2318\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f8b2664a-f1c6-48c5-a617-c6f1b79bf0f7\"\n/>\n\n\nThis
new rule is aggregated by default using `_index` and could be\nfurther
configured by the user (e.g. user can also aggregate
by\n`cloud.provider`).\n\nA new rule type was needed to be created since
there is no actual way to\naggregate all documents in a dataStream if we
use a DataView like\n`logs-*-*`. Inside datasStream documents there is
no indication about\nthe dataStream where they belong to, instead we
just have `_index` which\ncontains backingIndexName instead of actual
index.\n\nIt's important to note, that this rule type is also visible
from\n`Observability > Alerts`, which is useful specially for
serverless.\n\n\nhttps://github.com/user-attachments/assets/000aee51-4895-4f4c-9484-924ace4325c5\n\n\n##
Role Based Access-Control (RBAC)\nRBAC for dataset quality alerts is
defined within dataQuality kibana\nfeature.\nWe have three privileges
defined:\n1. `all`: This privilege now contains a subFeature
`manage_rules` that\nwill allow for more granularity on alerting level.
It's by default\nassigned to `all` but can be disabled.\n2. `read`: This
privilege is only related to serverless (when we don't\nhave yet custom
roles).\n\nhttps://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71\n3.
`none`: This privilege is only relevant for stateful (in serverless\nwe
don't have custom roles).\n\n## 🎥 Demo\n### Serverless\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/8dad6e30-a261-4a69-979f-6dfc2a41c888\n\n####
`read`
privileges\n\nhttps://github.com/user-attachments/assets/e1cb108d-22a0-4e7f-b252-9cc12d1e9d65\n\n###
Stateful\n#### `all`
privileges\n\nhttps://github.com/user-attachments/assets/d96f3b70-35b2-466b-aa59-a07190d24d93\n\n####
`all` privileges with subFeature
disabled\n\nhttps://github.com/user-attachments/assets/808ab811-9320-43e4-b2a6-06d530a78b82\n\n####
`none` privileges
(Stateful)\n\nhttps://github.com/user-attachments/assets/18f2a2d6-d825-4713-acea-0d72f451e9ab\n\n##
How to test?\n1. run synthrace scenario `degraded_logs` in live
mode\n```\nnode scripts/synthtrace degraded_logs --live\n```\n2. Open
dataset quality page (/app/management/data/data_quality)\n3. Select
`synth.3`
dataset\n(/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)\n4.
Click on `Actions` and then select `Create rule`\n5. Fill out the alert
form\n6. Go to `Observability > Alerts` or `Stack management >
Alerts`\n(/app/observability/alerts)\n\n## Release note\nAdds the Create
alert rule action to dataset quality page and dataset\nquality details.
This allows you to generate an alert when the\npercentage of degraded
docs on the chart crosses a certain
threshold.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Aleh
Zasypkin <aleh.zasypkin@elastic.co>\nCo-authored-by: Faisal Kanout
<faisal.kanout@elastic.co>","sha":"64df229998b0db7e5d381c847e60c0d39e6c3120"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Jun 25, 2025
Closes elastic#179173.

## Rule type
A dedicated stack rule type was created `datasetQuality.degradedDocs`.
<img width="1759" alt="image"
src="https://github.com/user-attachments/assets/5004a08d-6f12-4f5e-b27f-5f4db242dcf0"
/>
<img width="2318" alt="image"
src="https://github.com/user-attachments/assets/f8b2664a-f1c6-48c5-a617-c6f1b79bf0f7"
/>


This new rule is aggregated by default using `_index` and could be
further configured by the user (e.g. user can also aggregate by
`cloud.provider`).

A new rule type was needed to be created since there is no actual way to
aggregate all documents in a dataStream if we use a DataView like
`logs-*-*`. Inside datasStream documents there is no indication about
the dataStream where they belong to, instead we just have `_index` which
contains backingIndexName instead of actual index.

It's important to note, that this rule type is also visible from
`Observability > Alerts`, which is useful specially for serverless.


https://github.com/user-attachments/assets/000aee51-4895-4f4c-9484-924ace4325c5


## Role Based Access-Control (RBAC)
RBAC for dataset quality alerts is defined within dataQuality kibana
feature.
We have three privileges defined:
1. `all`: This privilege now contains a subFeature `manage_rules` that
will allow for more granularity on alerting level. It's by default
assigned to `all` but can be disabled.
2. `read`: This privilege is only related to serverless (when we don't
have yet custom roles).

https://github.com/user-attachments/assets/70ed5bde-bf45-4024-b448-228799fcaf71
3. `none`: This privilege is only relevant for stateful (in serverless
we don't have custom roles).

## 🎥 Demo
### Serverless
#### `all` privileges

https://github.com/user-attachments/assets/8dad6e30-a261-4a69-979f-6dfc2a41c888

#### `read` privileges

https://github.com/user-attachments/assets/e1cb108d-22a0-4e7f-b252-9cc12d1e9d65

### Stateful
#### `all` privileges

https://github.com/user-attachments/assets/d96f3b70-35b2-466b-aa59-a07190d24d93

#### `all` privileges with subFeature disabled

https://github.com/user-attachments/assets/808ab811-9320-43e4-b2a6-06d530a78b82

#### `none` privileges (Stateful)

https://github.com/user-attachments/assets/18f2a2d6-d825-4713-acea-0d72f451e9ab

## How to test?
1. run synthrace scenario `degraded_logs` in live mode
```
node scripts/synthtrace degraded_logs --live
```
2. Open dataset quality page (/app/management/data/data_quality)
3. Select `synth.3` dataset
(/app/management/data/data_quality/details?pageState=(dataStream:logs-synth.3-default)
4. Click on `Actions` and then select `Create rule`
5. Fill out the alert form
6. Go to `Observability > Alerts` or `Stack management > Alerts`
(/app/observability/alerts)

## Release note
Adds the Create alert rule action to dataset quality page and dataset
quality details. This allows you to generate an alert when the
percentage of degraded docs on the chart crosses a certain threshold.

---------

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

Labels

backport:version Backport to applied version labels backport This PR is a backport of another PR release_note:feature Makes this part of the condensed release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dataset Quality] Create rules for degraded documents