Skip to content

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Aug 28, 2025

Summary

Resolve #233186

Allow to configure monitoring runtime in agent policy.

Implementation details:

  • I made some change to our settings framework to support empty value, and label for select. Those changes are covered with unit tests

UI Changes

Agent policy editor
Screenshot 2025-08-28 at 1 32 43 PM

How to test

I tested this locally and it seems to generate correct policy that are handled by Elastic Agent

Screenshot 2025-08-28 at 2 02 06 PM

And we switch to otel when configuring to otel

{"log.level":"info","@timestamp":"2025-08-28T18:09:46.706Z","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/application/monitoring/reload.(*ServerReloader).Start","file.name":"reload/reload.go","file.line":54},"message":"Starting monitoring server with cfg &config.MonitoringConfig{Enabled:true, MonitorLogs:true, MonitorMetrics:true, MetricsPeriod:\"\", FailureThreshold:(*uint)(nil), LogMetrics:true, HTTP:(*config.MonitoringHTTPConfig)(0x40024825d0), Namespace:\"default\", Pprof:(*config.PprofConfig)(nil), MonitorTraces:false, APM:config.APMConfig{Environment:\"\", APIKey:\"\", SecretToken:\"\", Hosts:[]string(nil), GlobalLabels:map[string]string(nil), TLS:config.APMTLS{SkipVerify:false, ServerCertificate:\"\", ServerCA:\"\"}, SamplingRate:(*float32)(nil)}, Diagnostics:config.Diagnostics{Uploader:config.Uploader{MaxRetries:10, InitDur:1000000000, MaxDur:600000000000}, Limit:config.Limit{Interval:60000000000, Burst:1}}, RuntimeManager:\"otel\"}","log":{"source":"elastic-agent"},"ecs.version":"1.6.0"}

@cmacknz
Copy link
Member

cmacknz commented Aug 28, 2025

This should be backported to 9.1 and 8.19 as well as we intend to eventually use beat receivers there as well.

@nchaulet nchaulet added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Fleet Team label for Observability Data Collection Fleet team labels Aug 28, 2025
@nchaulet nchaulet self-assigned this Aug 28, 2025
@nchaulet nchaulet marked this pull request as ready for review August 28, 2025 18:08
@nchaulet nchaulet requested a review from a team as a code owner August 28, 2025 18:08
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet nchaulet added backport:prev-minor backport:version Backport to applied version labels v9.1.3 v8.19.3 and removed backport:prev-minor backport:skip This PR does not require backporting labels Aug 28, 2025
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --update'
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner August 28, 2025 18:42
nchaulet and others added 5 commits August 28, 2025 15:19
…lastic/kibana into feature-fleet-agent-runtime-monitoring
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --update'
…lastic/kibana into feature-fleet-agent-runtime-monitoring
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --update'
Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you do some manual testing of clearing/un-setting this setting? Do brand new agent policies get '' as a value right away?

I remember encountering unexpected behavior before with these generated settings before, where the agent policies are always created with a non-undefined value for introduced settings (we don't want this since we prefer to use agent default unless user explicitly chooses otherwise). Just want to make sure we double check here :)

{
name: 'agent.monitoring._runtime_experimental',
title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.monitoringRuntimeTitle', {
defaultMessage: 'Monitoring Runtime (experimental)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultMessage: 'Monitoring Runtime (experimental)',
defaultMessage: 'Runtime monitoring (experimental)',

sentence casing + I think "runtime monitoring" makes more sense than "monitoring runtime"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also agree with Jen here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a native speaker here, but does Runtime monitoring has a special meaning, here what it's configuring it's that agent flag agent.monitoring._runtime_experimental that configure the internal runtime of the agent monitoring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say that just happens to be the order from how the setting is nested, but after reviewing the original issue I think I misunderstood the intent. it's the runtime used for the self-monitoring process, not monitoring the runtime :)

so we should just fix the sentence casing here

Suggested change
defaultMessage: 'Monitoring Runtime (experimental)',
defaultMessage: 'Monitoring runtime (experimental)',

},
{
value: 'otel',
text: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.monitoringRuntimeLabel', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.monitoringRuntimeLabel', {
text: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.monitoringRuntimeOtelLabel', {

extremely small nit with naming of this i18n key 😅

Comment on lines +488 to +489
timeout: schema.maybe(schema.string()),
target_directory: schema.maybe(schema.string()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious where these additions came from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That a good point, I should have pointed this in the PR description, I added a test that verify that all advenced settings generate a valid full policy response here and found a few settings that were missing from the schema, as we plan to backport this up to 8.17 I think it's okay to not have a dedicated PR for that wdyt?

Comment on lines +515 to +519
metrics: schema.maybe(
schema.object({
period: schema.maybe(schema.string()),
})
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one too

@nchaulet
Copy link
Member Author

Did you do some manual testing of clearing/un-setting this setting? Do brand new agent policies get '' as a value right away?
I remember encountering unexpected behavior before with these generated settings before, where the agent policies are always created with a non-undefined value for introduced settings (we don't want this since we prefer to use agent default unless user explicitly chooses otherwise). Just want to make sure we double check here :)

Yes I tested those, and I added a special case to handle '' to not render those settings

@vishaangelova
Copy link
Contributor

Looping in @lcawl as I don’t know enough about the API docs (yet) and whether it’s possible to use the x-state in this case.

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

@lcawl
Copy link
Contributor

lcawl commented Aug 29, 2025

@vishaangelova I was not able to find any example of x-state added to a property managed by kbn/config-schema, and looking at the type it does not seems supported yet https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-config-schema/src/types/type.ts#L40 no?

You're right it looks like support for x-state has been added at the operation level but not yet at the parameter or property-level, so I've added that to our list of outstanding to-dos.

Copy link
Contributor

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for experience docs.

@lcawl @vishaangelova Assuming that this PR gets merged before we allow x-state at the parameter or props level, will we create a separate task to update it later?

@vishaangelova
Copy link
Contributor

vishaangelova commented Sep 1, 2025

@florent-leborgne good point! I’ve created an issue to track PRs related to Fleet APIs so that we can add the availability information when we have support for x-state at this level: elastic/docs-content#2769

@nchaulet
Copy link
Member Author

nchaulet commented Sep 2, 2025

@elasticmachine merge upstream

@nchaulet nchaulet enabled auto-merge (squash) September 2, 2025 08:26
@nchaulet nchaulet merged commit 52c02e9 into main Sep 2, 2025
13 checks passed
@nchaulet nchaulet deleted the feature-fleet-agent-runtime-monitoring branch September 2, 2025 10:02
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/17400085628

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 2.1MB 2.1MB +1.1KB

History

cc @nchaulet

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.1:
- Add overlay for Fleet remote synced integrations API (#233493)
- [ska] remove kbn/test-suites-xpack imports (#233427)
- [Fleet] remove sync integrations APIs in serverless (#233482)

Manual backport

To create the backport manually run:

node scripts/backport --pr 233345

Questions ?

Please refer to the Backport tool documentation

@nchaulet
Copy link
Member Author

nchaulet commented Sep 2, 2025

💚 All backports created successfully

Status Branch Result
9.1
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

nchaulet added a commit to nchaulet/kibana that referenced this pull request Sep 2, 2025
…c#233345)

(cherry picked from commit 52c02e9)

# Conflicts:
#	x-pack/platform/plugins/private/translations/translations/de-DE.json
nchaulet added a commit that referenced this pull request Sep 2, 2025
…233345) (#233708)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Fleet] Allow to configure monitoring runtime in agent policy
(#233345)](#233345)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2025-09-02T10:02:19Z","message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.2.0","v9.1.3","v8.19.3"],"title":"[Fleet]
Allow to configure monitoring runtime in agent
policy","number":233345,"url":"https://github.com/elastic/kibana/pull/233345","mergeCommit":{"message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233345","number":233345,"mergeCommit":{"message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
nchaulet added a commit that referenced this pull request Sep 2, 2025
…233345) (#233710)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Fleet] Allow to configure monitoring runtime in agent policy
(#233345)](#233345)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2025-09-02T10:02:19Z","message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.2.0","v9.1.3","v8.19.3"],"title":"[Fleet]
Allow to configure monitoring runtime in agent
policy","number":233345,"url":"https://github.com/elastic/kibana/pull/233345","mergeCommit":{"message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233345","number":233345,"mergeCommit":{"message":"[Fleet]
Allow to configure monitoring runtime in agent policy
(#233345)","sha":"52c02e9d73625926f1f3592275db62ed1cbd71ec"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
MichelLosier pushed a commit to MichelLosier/kibana that referenced this pull request Sep 2, 2025
kowalczyk-krzysztof pushed a commit to kowalczyk-krzysztof/kibana that referenced this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.19.3 v8.19.4 v9.1.3 v9.1.4 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet] Add advanced agent policy setting setting for agent.monitoring._runtime_experimental

8 participants