elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.71k stars 8.12k forks source link

[Fleet UI] Policy override API should accept flattened configuration keys and un-flatten them #189329

Open ycombinator opened 1 month ago

ycombinator commented 1 month ago

Kibana version:

8.15.0

Elasticsearch version:

8.15.0

Describe the bug:

When using the PUT kbn:/api/fleet/agent_policies/:policy_id API to set overrides, it is not possible to specify flattened keys. For example, this request:

PUT kbn:/api/fleet/agent_policies/663eb8dd-25c9-46c3-b455-e058408915e6
{
   "name": "default",
    "namespace": "default",
    "overrides": {
         "agent.monitoring.enabled": false
    }
}

... does not result in the same policy YAML as this request:

PUT kbn:/api/fleet/agent_policies/663eb8dd-25c9-46c3-b455-e058408915e6
{
   "name": "default",
    "namespace": "default",
    "overrides": {
         "agent": {
            "monitoring": {
                "enabled": false
            }
         }
    }
}

Steps to reproduce:

  1. Create a new Agent policy with logs/metrics monitoring enabled.
  2. View the policy YAML and check the value of agent.monitoring.enabled. It should be set to `true.
  3. Use the policy override API (first example shown above) to set agent.monitoring.enabled to false.
  4. View the policy YAML and check the value of agent.monitoring.enabled.

Expected behavior:

The value of agent.monitoring.enabled (unflattened) in the policy YAML is set to false. There is no flattened agent.monitoring.enabled key in the policy YAML.

Observed behavior:

A new flattened key, agent.monitoring.enabled is added to the policy YAML and it's value is set to false. However, the original, unflattened agent.monitoring.enabled key in the policy YAML still has it's value set to true.

Screenshots (if relevant):

Screenshot 2024-07-26 at 16 19 26

Bug originally reported by @michel-laterman. Thanks!

elasticmachine commented 1 month ago

Pinging @elastic/fleet (Team:Fleet)