[Synthetics] Guard default monitor fields in agent stream templates#20342
[Synthetics] Guard default monitor fields in agent stream templates#20342shahzad31 wants to merge 4 commits into
Conversation
Wrap monitor fields that already equal the Heartbeat default in `{{#if}}`
guards for the http, tcp and icmp data streams so they are only emitted in
the compiled agent stream when a non-default value is configured. This
reduces the size of the generated package policy / agent payload.
Heartbeat applies the exact same defaults when a field is absent (proven by
unit tests in elastic/beats), so monitor behavior is unchanged.
Paired with the Kibana change that stops emitting these defaults
(elastic/kibana#241818).
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
Add elastic-package policy tests for http, tcp, and icmp, each with a defaults case and a custom case. The defaults .expected snapshots assert that Heartbeat-default fields (e.g. check.request.method, max_redirects, timeout, response.include_body, mode) are dropped from the compiled agent stream, while the custom cases assert the values are preserved. Note: these tests exercise the Fleet agent-policy YAML download endpoint, which requires the Kibana Fleet fix disabling YAML anchor/alias generation (aliasDuplicateObjects: false) to serialize policies that share object references. Co-authored-by: Cursor <cursoragent@cursor.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The icmp `wait` field was declared `required: true` with `default: 1s`, so
Fleet always backfilled `1s` and the `{{#if wait}}` template guard never
dropped it. Make it `required: false` and remove the manifest default so a
default monitor omits `wait` entirely; Heartbeat applies the same `1s`
default when the field is absent (proven by elastic/beats icmp unit tests).
Regenerates the icmp default policy-test snapshot (wait no longer present).
Co-authored-by: Cursor <cursoragent@cursor.com>
|
✅ All changelog entries have the correct PR link. |
💔 Build Failed
Failed CI StepsHistory
|
TL;DRThe Remediation
Investigation detailsRoot CauseThe PR adds six policy fixtures under The changed templates ( Evidence
Verification
Follow-upIf a retry with the Kibana fix still fails, attach the policy-test XML or the first error emitted before teardown; that output is required to identify whether any fixture/template assertion remains incorrect. What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
Summary
Wrap monitor fields that already equal the Heartbeat default in
{{#if}}guards for the http, tcp and icmp data streams, so they are only emitted in the compiled agent stream when a non-default value is configured. This reduces the size of the generated package policy / agent payload.Guarded fields:
timeout,max_redirects,response.include_body,check.request.methodtimeout,proxy_use_local_resolverwait,timeoutPackage version bumped
1.8.0→1.9.0.Why this is safe
Heartbeat applies the exact same defaults when a field is absent. This is proven by unit tests added in elastic/beats (
defaults_omit_test.gofor http/tcp/icmp) which assert that omitting or nulling each field falls back to the identical default value.ipv4/ipv6/response.include_headersare intentionally not guarded: they default totrueand a{{#if}}guard could not distinguish an explicitfalsefrom an omitted value.Paired changes
Test plan
elastic-package lint/buildpass for the synthetics packageMade with Cursor