Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Nov 26, 2025

What does this PR do?

When we generate self-monitoring configuration, we do certain things differently depending on whether a component will run in a beat process or a beat receiver in an otel collector. This PR ensures this information is accurate. Up until now, this decision was based on which runtime the component was configured to use, rather than what it ultimately used. If the component cannot run in the otel runtime - for example because the output is not supported - it would fall back to the process runtime, but this would happen after the self-monitoring configuration was generated, leading to inconsistencies.

This is achieved by making the following changes:

  1. Falling back to the process runtime is done as a component modifier instead of a dedicated Coordinator method.
  2. Component modifiers are now applied immediately after the components are generated, and before the self-monitoring configuration is generated. As a result, the monitoring manager now sees what runtime components will actually run as.
  3. For the self-monitoring components, we check if the output is otel supported and make decisions based on that.

Why is it important?

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

How to test this PR locally

Build agent locally and run using the following configuration:

agent:
  logging:
    to_stderr: true
inputs:
- data_stream:
    namespace: default
  id: unique-system-metrics-input
  streams:
  - data_stream:
      dataset: system.cpu
    metricsets:
    - cpu
  type: system/metrics
  use_output: default
outputs:
  default:
    username: elastic
    password: elastic
    hosts:
    - 127.0.0.1:9200
    type: elasticsearch
    indices: []

Verify that all the components are running as beats processes via the status, and that the prometheus monitoring component is not present.

Related issues


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

…untime (#11300)

* Move ComponentsModifies to the component package

* Move Otel runtime determination to component modifier

* Check supported outputs in monitoring config generation

* Add changelog entry

* Log warning about switching to process runtime for monitoring

* Fix monitoring config types

* fix TestBeatsReceiverProcessRuntimeFallback

* Add logstash output to test cases

(cherry picked from commit 2c4c615)

# Conflicts:
#	internal/pkg/agent/application/monitoring/component/v1_monitor.go
#	internal/pkg/agent/install/componentvalidation/validation.go
#	internal/pkg/otel/translate/otelconfig.go
#	pkg/component/component.go
#	testing/integration/ess/beat_receivers_test.go
@mergify mergify bot requested a review from a team as a code owner November 26, 2025 11:38
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Nov 26, 2025
@mergify mergify bot requested review from swiatekm and ycombinator and removed request for a team November 26, 2025 11:38
@mergify
Copy link
Contributor Author

mergify bot commented Nov 26, 2025

Cherry-pick of 2c4c615 has failed:

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

You are currently cherry-picking commit 2c4c615f1.
  (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/1763650536-self-monitoring-runtime.yaml
	modified:   internal/pkg/agent/application/application.go
	modified:   internal/pkg/agent/application/coordinator/coordinator.go
	modified:   internal/pkg/agent/application/endpoint_component_modifier.go
	modified:   internal/pkg/agent/application/endpoint_component_modifier_test.go
	modified:   internal/pkg/agent/application/fleet_server_bootstrap.go
	modified:   internal/pkg/agent/application/inject_proxy_component_modifier.go
	modified:   internal/pkg/agent/application/monitoring/component/testdata/monitoring_config_full_otel.yaml
	modified:   internal/pkg/agent/application/monitoring/component/testdata/monitoring_config_full_process.yaml
	modified:   internal/pkg/agent/application/monitoring/component/v1_monitor_test.go
	new file:   internal/pkg/agent/application/monitoring/monitoringhelpers/endpoint.go
	modified:   internal/pkg/agent/install/uninstall.go
	modified:   internal/pkg/otel/translate/otelconfig_test.go
	modified:   pkg/component/component_test.go

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   internal/pkg/agent/application/monitoring/component/v1_monitor.go
	deleted by us:   internal/pkg/agent/install/componentvalidation/validation.go
	both modified:   internal/pkg/otel/translate/otelconfig.go
	both modified:   pkg/component/component.go
	both modified:   testing/integration/ess/beat_receivers_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 bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Nov 26, 2025
@elasticmachine
Copy link
Contributor

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

@swiatekm swiatekm enabled auto-merge (squash) December 1, 2025 11:35
@elasticmachine
Copy link
Contributor

elasticmachine commented Dec 1, 2025

@swiatekm swiatekm merged commit 36c5e18 into 8.19 Dec 1, 2025
17 checks passed
@swiatekm swiatekm deleted the mergify/bp/8.19/pr-11300 branch December 1, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working 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.

3 participants