[Fleet] Enable agent.monitoring.http settings on agent policy UI (#180922)

## Summary

Related to https://github.com/elastic/ingest-dev/issues/2471

With https://github.com/elastic/elastic-agent/pull/4499 merged, it
became possible to reload monitoring settings changes in a running
agent, so enabling these settings on the UI.

To verify:
- Create an agent policy and enroll an agent with latest 8.15-SNAPSHOT
- edit agent policy, and change monitoring settings, e.g. change port
- verify that the metrics endpoint is running on the new port

<img width="958" alt="image"
src="91e3d2ec-8275-40c3-b5a6-7cdbb6b07cd3">
<img width="1109" alt="image"
src="83be9610-5095-485f-83fd-bf4dbe5cb44a">

@cmacknz Does it make sense to allow changing the host name? It seems to
me that monitoring can only work in localhost.
Another question, how can we verify that the `buffer.enabled` setting is
applied correctly?

```
15:07:40.054
elastic_agent
[elastic_agent][error] Failed creating a server: failed to create api server: listen tcp 192.168.178.217:6791: bind: cannot assign requested address
```

Also, I'm not sure if switching off the `enabled` flag did anything,
seeing this again in the logs:
```
15:13:15.167
elastic_agent
[elastic_agent][info] Starting server
15:13:15.168
elastic_agent
[elastic_agent][info] Starting stats endpoint
15:13:15.168
elastic_agent
[elastic_agent][debug] Server started
15:13:15.168
elastic_agent
[elastic_agent][info] Metrics endpoint listening on: 127.0.0.1:6791 (configured: http://localhost:6791)
```

---------

Co-authored-by: Jen Huang <its.jenetic@gmail.com>
This commit is contained in:
Julia Bardi 2024-05-14 14:04:18 +02:00 committed by GitHub
parent a19143c198
commit c4f08c0ce9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,27 +104,27 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [
},
{
name: 'agent.monitoring.http',
hidden: true,
api_field: {
name: 'agent_monitoring_http',
},
title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpTitle', {
defaultMessage: 'Agent HTTP monitoring',
defaultMessage: 'HTTP monitoring endpoint',
}),
description: i18n.translate(
'xpack.fleet.settings.agentPolicyAdvanced.agentMonitoringHttpDescription',
{
defaultMessage: 'Agent HTTP monitoring settings.',
defaultMessage:
'Enables a liveness HTTP endpoint that returns the overall health of Elastic Agent. This can be used by Kubernetes to restart the container, for example.',
}
),
learnMoreLink:
'https://www.elastic.co/guide/en/fleet/current/enable-custom-policy-settings.html#override-default-monitoring-port',
schema: z
.object({
enabled: z.boolean().describe('Enabled').default(false),
// enabled: z.boolean().describe('Enabled').default(false),
host: z.string().describe('Host').default('localhost'),
port: z.number().describe('Port').min(0).max(65353).default(6791),
'buffer.enabled': z.boolean().describe('Buffer Enabled').default(false),
// 'buffer.enabled': z.boolean().describe('Buffer Enabled').default(false),
})
.default({}),
},