fix: populate index-pattern field lists - #384
Merged
Merged
Conversation
Signed-off-by: Adam Tackett <tackadam@amazon.com>
TackAdam
requested review from
anirudha,
goyamegh,
joshuali925,
kylehounslow,
ps48 and
vamsimanohar
as code owners
August 3, 2026 21:46
Signed-off-by: Adam Tackett <tackadam@amazon.com>
TackAdam
marked this pull request as draft
August 4, 2026 17:10
TackAdam
marked this pull request as ready for review
August 4, 2026 19:00
ps48
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pre-generated index patterns (
logs-otel-v1*,otel-v1-apm-span*,otel-v2-apm-service-map*) were being created by the Dashboards initialization script with an emptyfieldsattribute. In the UI this appeared as "Fields (0)", and visualizations failed with errors such as:Recreating the dataset through the UI repaired the issue because the dataset creation flow populates the field list, but the pre-generated index patterns created during stack initialization remained permanently broken.
This PR populates index pattern fields during initialization and refactors the delayed refresh into a separate background process so it never blocks stack startup or Helm install/upgrade operations.
Root cause
Two issues combined to produce the bug.
1. The initialization script never populated fields at creation time
The script creates index patterns directly through the Saved Objects API:
Unlike the dataset creation wizard, this code path never performs a
_fields_for_wildcardrequest, so the saved object is persisted with an emptyfieldsattribute.OpenSearch Dashboards previously compensated by lazily fetching fields on first use, but that behavior was removed upstream in OpenSearch-Dashboards#11653. PR #12236 restored field prefetching for datasets created through the UI wizard, but pre-generated index patterns created out-of-band still bypass that logic.
2. The
_fields_for_wildcardrefresh call itself was brokenThe existing
refresh_index_pattern_fields()implementation passed repeatedmeta_fieldsquery parameters:This version of OpenSearch Dashboards rejects those parameters with a
400response (definition for this key is missing), so even when the refresh function executed, it silently failed and never populated any fields.The fix removes the unnecessary
meta_fieldsparameters entirely and sends only thepatternparameter usingrequests'paramsdictionary for proper URL encoding.Changes
1. Fix the
_fields_for_wildcardAPI callUpdated
refresh_index_pattern_fields()to:meta_fieldsquery parameters.patternparameter.requests'paramsdictionary for proper URL encoding.This restores compatibility with current OpenSearch Dashboards versions.
2. Populate fields immediately after creation
After each index pattern is created,
main()now immediately invokesrefresh_index_pattern_fields(), mirroring the behavior of the dataset creation wizard:_fields_for_wildcardThis fixes environments where matching indices already exist.
3. Replace the delayed refresh with a bounded retry loop
On a fresh deployment, matching indices often exist before any documents have been indexed, so the initial refresh legitimately returns no fields.
Previously the script:
This has been replaced with a bounded retry loop that:
The first refresh occurs immediately, so environments that already contain data complete within seconds.
4. Run the retry loop outside the initialization hook
The initialization script runs as a Helm
post-install/post-upgradehook, and Helm waits for hook Jobs to complete before finishing an install or upgrade.Running an hour-long retry loop inside that hook would unnecessarily block every deployment.
The script now supports two execution modes:
Default (
main)refresh-loopDocker Compose
Added a new service:
opensearch-dashboards-field-refreshUnlike the previous implementation, it intentionally does not depend on the initialization container completing successfully. A
service_completed_successfullydependency on a one-shot container causesdocker compose up --wait(used bytest/e2e.sh) to exit non-zero when the init container finishes.Instead, the refresh loop:
Helm
Added:
field-refresh-job.yamlfield-refresh-configmap.yamlThe refresh Job is intentionally not a Helm hook so it does not delay installs or upgrades.
Additional implementation details:
.Release.Revisionto avoid Jobspec.templateimmutability during upgrades.activeDeadlineSecondsandttlSecondsAfterFinishedfor automatic cleanup.5. Enable unbuffered logging
All Python invocations now use:
This applies to:
Previously Python buffered stdout until process exit, making the initialization flow difficult to monitor and debug.
Testing
Verified with a clean Docker Compose deployment:
Results:
opensearch-dashboards-initexecutesmain()and exits successfully.opensearch-dashboards-field-refreshstarts independently.logs-otel-v1*→ 135 fieldsotel-v1-apm-span*→ 280 fieldsotel-v2-apm-service-map*→ 13 fieldstest/e2e.shend-to-end locally; all checks passed (EXIT 0).helm templaterenders both Jobs, both ConfigMaps, correct hook/non-hook annotations, correct command arguments, deadlines, and unbuffered Python execution.docker compose configvalidates.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.