elastic / kibana

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

Fleet API: ID gets ignored when creating a package policy #153205

Open ckauf opened 1 year ago

ckauf commented 1 year ago

Kibana version: 8.6.2

Elasticsearch version: 8.6.2

Original install method (e.g. download page, yum, from source, etc.): Cloud

Describe the bug: When creating a package policy and specifying the id in the body, that field seem to get ignored

Steps to reproduce:

  1. Create an Agent Policy

    POST kbn:/api/fleet/agent_policies
    {
    "id": "someId",
    "name": "someName",
    "description": "",
    "namespace": "default",
    "monitoring_enabled": [
    "logs",
    "metrics"
    ]
    }
  2. Add a Package Policy, including the id in the body:

    POST kbn:/api/fleet/package_policies
    {
    "id": "someOtherId",
    "policy_id": "someId",
    "package": {
    "name": "log",
    "version": "1.1.1"
    },
    "name": "thisisaname",
    "description": "",
    "namespace": "default",
    "inputs": {
    "logs-logfile": {
      "enabled": true,
      "streams": {
        "log.log": {
          "enabled": true,
          "vars": {
            "paths": [
              "test"
            ],
            "data_stream.dataset": "generic",
            "tags": [],
            "custom": ""
          }
        }
      }
    }
    }
    }
  3. Verify how the id in the output differs from the id in the create call

    {
    "item": {
    "id": "4db28dd9-7fd7-4442-b706-f62ec3c2bfdd",
    "version": "WzEwNzM5MTUzLDExXQ==",
    "name": "thisisaname",
    "namespace": "default",

Expected behavior: ID should be the same

Screenshots (if relevant): API Spec: image

elasticmachine commented 1 year ago

Pinging @elastic/fleet (Team:Fleet)

juliaElastic commented 1 year ago

It seems that the service supports passing an id parameter, but the request handler doesn't set it. So I think the fix would be to pass the missing id parameter from the request body to the service create call.

maximilianpohle commented 1 year ago

Dear all,

the error already exists in 8.5.3 as well.