Skip to content

[9.6] (backport #16902) Restore Heartbeat monitor state in OTel mode - #17568

Merged
belimawr merged 2 commits into
9.6from
mergify/bp/9.6/pr-16902
Oct 27, 2026
Merged

belimawr merged 2 commits into
9.6from
mergify/bp/9.6/pr-16902

Conversation

@mergify

@mergify mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Restore Heartbeat monitor state in OTel mode
Configure output-scoped Elasticsearch authentication for Heartbeat receivers and delegate
transport settings to beatsauth.

Assisted-by: Cursor, Model: GPT-5.6 Sol (High)
Assisted-by: Cursor, Model: Gemini 3.8 Flash (High)

Why is it important?

Fixes #16284

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

## Disruptive User Impact

How to test this PR locally

Run the tests

go test -count=1 -run="TestGetBeatsAuthExtensionConfig|TestHeartbeatElasticsearchAuth" ./internal/pkg/otel/translate/
go test -count=1 ./internal/pkg/otel/translate/

Manual test

Runtime precondition

This Heartbeat defaults to the process runtime. Force OTel runtime via
Fleet policy override:
In Fleet UI go to: -> Settings -> Advanced internal YAML settings
and add the following snippet:

agent.internal.runtime:
  heartbeat:
    default: otel

Kibana and Elastic Agent setup

Example URLs assume you're using Elastic-Package

  1. Start a webserver to use as target for the monitor, for example python -m http.server.
  2. Create a dedicated Fleet agent policy with the default Elasticsearch output.
  3. Apply the runtime override above and wait for the Agent to receive the new policy revision.
  4. Enroll a local Elastic Agent build in that policy.
  5. Create a Synthetics private location bound to that policy:
  1. Create an HTTP Synthetics monitor on the private location.
  • Go to: https://localhost:5601/app/synthetics/add-monitor
  • Select "HTTP" as monitor type
  • In URL enter the URL of your webserver
  • Select the private location you created in the previous step
  • Change the frequency to 10s
  • Click "Run test" to make sure the monitor is working
  • Save/Create the monitor
  • You'll land in the monitors page, click on your monitor and copy its ID from the URL (the last element of the URL path)

Reproduction

Run the following query in Dev Tools, replacing <monitor-id> by the monitor ID you copied.

POST synthetics-http*/_search?filter_path=hits.hits._source
{
  "size": 1,
  "_source": [
    "agent.id",
    "monitor.id",
    "observer.name",
    "state.id",
    "state.started_at",
    "state.checks"
  ],
  "sort": [{"@timestamp": {"order": "desc"}}],
  "query": {
    "bool": {
      "filter": [
        {"term": {"monitor.id": "<monitor-id>"}},
        {"exists": {"field": "state.id"}}
      ]
    }
  }
}

Record the result:

  • state.checks: ever-increasing number of checks.
  • state.id: the persisted Heartbeat state ID.
  • state.started_at: the time of the first check.

Restart Elastic Agent, for example on Linux: sudo systemctl restart elastic-agent.

Run the query again. state.checks must have increased; state.id and
state.started_at must be unchanged.

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

This is an automatic backport of pull request #16902 done by [Mergify](https://mergify.com).

Restore Heartbeat monitor state in OTel mode
Configure output-scoped Elasticsearch authentication for Heartbeat receivers and delegate
transport settings to beatsauth.

Assisted-by: Cursor, Model: GPT-5.6 Terra & Sol (High)
Assisted-by: Cursor, Model: Gemini 3.8 Flash (High)
(cherry picked from commit fe0cdc3)

# Conflicts:
#	internal/pkg/otel/translate/otelconfig_test.go
@mergify mergify Bot added the backport label Oct 26, 2026
@mergify
mergify Bot requested a review from a team as a code owner October 26, 2026 21:48
@mergify mergify Bot added the conflicts There is a conflict in the backported pull request label Oct 26, 2026
@mergify
mergify Bot requested review from swiatekm and removed request for a team October 26, 2026 21:48
@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of fe0cdc3 has failed:

On branch mergify/bp/9.6/pr-16902
Your branch is up to date with 'origin/9.6'.

You are currently cherry-picking commit fe0cdc3.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1790701465-restore-heartbeat-monitor-state-in-otel-mode.yaml
	modified:   internal/pkg/otel/translate/otelconfig.go
	modified:   internal/pkg/otel/translate/output_elasticsearch.go
	modified:   internal/pkg/otel/translate/output_elasticsearch_test.go
	new file:   internal/pkg/otel/translate/testdata/certs/client-unencrypted.key
	modified:   testing/integration/ess/heartbeat_monitoring_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/otel/translate/otelconfig_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@github-actions github-actions Bot added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Oct 26, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Dependency review finished without posting an analysis comment.

If you expected a review, push a new commit to this pull request (or close and reopen it) to try again.

Workflow run: https://github.com/elastic/elastic-agent/actions/runs/40430235127

@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

Buildkite failed in check-ci during goimports because internal/pkg/otel/translate/otelconfig_test.go in commit f950893 contains unresolved merge-conflict markers. Resolve the conflict and rerun CI.

Remediation

  • Remove conflict markers in internal/pkg/otel/translate/otelconfig_test.go and keep a single valid merged version of both test additions (NoEnabledStreams and HeartbeatElasticsearchAuth).
  • Re-run make check-ci (or at minimum mage fmt) to confirm goimports passes before retriggering Buildkite.
Investigation details

Root Cause

This is a code bug introduced in the backport commit. The commit patch for f9508938ac04260d9226b0b270abdb1e1df41fa6 includes unresolved conflict markers in internal/pkg/otel/translate/otelconfig_test.go around the new receiver tests (contains <<<<<<< HEAD / >>>>>>> fe0cdc3).

Evidence

  • Build: https://buildkite.com/elastic/elastic-agent/builds/48765
  • Job/step: check-ci → .buildkite/scripts/steps/check-ci.sh
  • Key log excerpts:
    • internal/pkg/otel/translate/otelconfig_test.go:3554:1: expected declaration, found '<<'
    • internal/pkg/otel/translate/otelconfig_test.go:3715:64: illegal character U+0023 '#'
    • internal/pkg/otel/translate/otelconfig_test.go:3998:2: expected declaration, found 'for'
    • Error: running "goimports ..." failed with exit code 2

Verification

  • Not run locally against this exact failing commit (the commit SHA is not present in this runner checkout); diagnosis is based on Buildkite log evidence plus the commit patch content from GitHub.

Follow-up

  • I checked accessible prior PR comments and did not find an existing detective comment with this same root cause/remediation.

What is this? | From workflow: Observability Agentic Workflow — Status

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Assisted-by: gpt-5.6-terra-high
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @belimawr

@belimawr
belimawr merged commit f074635 into 9.6 Oct 27, 2026
42 checks passed
@belimawr
belimawr deleted the mergify/bp/9.6/pr-16902 branch October 27, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport conflicts There is a conflict in the backported pull request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant