Skip to content

Fix/doc level monitor sample documents source fields#2150

Open
carmeroa wants to merge 2 commits into
opensearch-project:mainfrom
carmeroa:fix/doc-level-monitor-sample-documents-source-fields
Open

Fix/doc level monitor sample documents source fields#2150
carmeroa wants to merge 2 commits into
opensearch-project:mainfrom
carmeroa:fix/doc-level-monitor-sample-documents-source-fields

Conversation

@carmeroa

Copy link
Copy Markdown

Description

This change fixes doc-level monitor sample_documents so action templates can access the original matched document source instead of percolation-transformed fields.

The implementation captures a deep copy of each matched document before field-name transformation for percolation and uses that data to populate sample_documents with a stable structure containing _id, _index, and _source.

This preserves original field names for Mustache templates, keeps nested objects intact, and avoids exposing percolation-mutated field names in action templates. It also reduces reliance on fallback mget for documents already captured during shard search, which is especially important for routed indices.

This PR also adds regression coverage for original source rendering, metadata exposure, nested object preservation, and the absence of percolation suffixes in sample_documents.

Related Issues

Resolves #2149

Check List

  • New functionality includes testing.
    • See added regression tests in ./alerting/src/test/kotlin/org/opensearch/alerting/transport/DocLevelMonitorSampleDocumentsTests.kt.
  • New functionality has been documented.
  • API changes companion pull request created.
    • Not applicable: no API changes.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.
    • Documentation issue created: #12452.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

carmeroa added 2 commits May 20, 2026 22:53
Add regression coverage for original source rendering and nested object preservation.

Signed-off-by: Carlos Armero <278705015+carmeroa@users.noreply.github.com>
Signed-off-by: Carlos Armero <278705015+carmeroa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Doc-level monitor action templates cannot reliably access the original matched document for notifications on routed indices

1 participant