alerting-dashboards-plugin
alerting-dashboards-plugin copied to clipboard
[BUG] Alerting Dashboard doesn't find sub-fields when building the list of fields by type
What is the bug?
The alerting plugin needs to find fields (by type) to offer the visual editor for monitors. The code for recursing over the index mappings to find these fields currently only recurses into "object" types - but any type can have sub-fields within them. The default OS dynamic mapper maps strings to text fields with a keyword sub-field. The current alerting plugin can't find these keyword sub-fields and thus it is impossible to create a per-bucket monitor using the visual editor for such fields (the group-by drop down list is empty in my case).
Relevant code: https://github.com/opensearch-project/alerting-dashboards-plugin/blob/main/public/pages/CreateMonitor/containers/DefineMonitor/utils/mappings.js#L24-L33
How can one reproduce the bug? Steps to reproduce the behavior:
- Attempt to create a bucket monitor against an index with mappings like:
{
"random_index": {
"mappings": {
"description": {
"type": "text",
"fields": {
"kwsubfield": {
"type": "keyword"
}
}
}
}
}
}
}
- Observe that the
description.kwsubfieldis absent from the group-by drop down menu.
What is the expected behavior? The sub-field should be found and listed as a keyword field so that the visual editor works as expected
What is your host/environment?
- OS: n/a
- Version n/a
- Plugins n/a
Do you have any screenshots? If applicable, add screenshots to help explain your problem.
Do you have any additional context? We are encountering this while running OpenSearch Service in AWS, but is definitely not specific to any particular environment.
Just added the simple 1-line fix for this issue - https://github.com/opensearch-project/alerting-dashboards-plugin/pull/518
cc: @AWSHurneyt to help identify the gaps and see if we can plan this for our next release.
Any update on this @getsaurabh02 ?
Thanks
Hi @mjsell1234, Thank you for implementing this change! I've commented in the PR you have opened.
As an update, I believe I've found the issue; manual testing suggests the bug is resolved. I'm running through some use cases locally, and working on adding unit tests; and I should have a PR out shortly.