Skip to content

[Synthetics] Guard default monitor fields in agent stream templates#20342

Draft
shahzad31 wants to merge 4 commits into
mainfrom
synthetics-omit-default-values
Draft

[Synthetics] Guard default monitor fields in agent stream templates#20342
shahzad31 wants to merge 4 commits into
mainfrom
synthetics-omit-default-values

Conversation

@shahzad31

Copy link
Copy Markdown
Contributor

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:

  • http: timeout, max_redirects, response.include_body, check.request.method
  • tcp: timeout, proxy_use_local_resolver
  • icmp: wait, timeout

Package version bumped 1.8.01.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.go for http/tcp/icmp) which assert that omitting or nulling each field falls back to the identical default value.

ipv4/ipv6/response.include_headers are intentionally not guarded: they default to true and a {{#if}} guard could not distinguish an explicit false from an omitted value.

Paired changes

Test plan

  • elastic-package lint / build pass for the synthetics package
  • Compiled stream for a default monitor no longer contains the guarded fields
  • Compiled stream still contains fields when a non-default value is set

Made with Cursor

shahzad31 and others added 2 commits July 23, 2026 20:59
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>
@github-actions

Copy link
Copy Markdown
Contributor

✅ 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>
@github-actions

This comment has been minimized.

@github-actions

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>
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

✅ All changelog entries have the correct PR link.

@infra-vault-gh-plugin-prod

infra-vault-gh-plugin-prod Bot commented Jul 24, 2026

Copy link
Copy Markdown

💔 Build Failed

Failed CI Steps

History

@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

The synthetics check is failing in the newly added policy-test path, not at the package/template lint stage. The PR’s policy tests depend on the Kibana Fleet YAML serialization fix described in commit 3e79bee; Buildkite build 46592 appears to be running without that paired Kibana change, so the policy download/compare step fails before the expected snapshots can be validated.

Remediation

  • Run the synthetics policy tests against a stack containing the paired Kibana Fleet fix (aliasDuplicateObjects: false), or remove the dependency by using a stack-independent test path.
  • Retry elastic-package test policy --report-format xUnit --report-output file for packages/synthetics after the stack is updated.
  • If the stack already contains that fix, expose the pre-teardown policy-test output or the uploaded synthetics-policy-*.xml; the captured log ends before the underlying error and cannot distinguish an endpoint serialization error from another policy-test failure.
Investigation details

Root Cause

The PR adds six policy fixtures under packages/synthetics/data_stream/{http,tcp,icmp}/_dev/test/policy/. The Buildkite package runner executes elastic-package test policy at .buildkite/scripts/common.sh:967 for the package test flow. The policy-test commit explicitly documents that these tests exercise the Fleet agent-policy YAML download endpoint and require Kibana’s aliasDuplicateObjects: false fix. The current PR description also identifies the Kibana change as a paired change. Without that stack-side serialization fix, the policy response can contain YAML anchors/aliases that prevent the fixture comparison from succeeding.

The changed templates (http.yml.hbs, tcp.yml.hbs, and icmp.yml.hbs) only add conditional emission around fields, while the failing build has no reported template parse or lint error. The failure follows the introduction of the policy suites in commit 3e79bee and persists in build 46592 after the ICMP fixture update.

Evidence

  • Build: https://buildkite.com/elastic/integrations/builds/46592
  • Job/step: Check integrations synthetics
  • Command: .buildkite/scripts/test_one_package.sh packages/synthetics origin/main faefd06d90f052526763f409d8b55fd00d643598
  • Captured log: lines 79-84 contain only --- [synthetics] failed and The command exited with status 1; lines 85-123 show artifact upload and teardown.
  • Relevant test runner: .buildkite/scripts/common.sh:967 invokes elastic-package test policy.
  • Relevant PR commit: 3e79bee

Verification

  • Inspected the PR diff, all recent PR comments, the package test runner, and the failed Buildkite log.
  • Not run locally: elastic-package is not installed in this environment, and the supplied log omits the failing policy-test diagnostic.

Follow-up

If 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integration:synthetics Elastic Synthetics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants