404 When Using Copy Saved Objects to Space API

Hello, Elastic!

I'm currently trying to use the Copy Saved Objects api (copying an Uptime status Rule from our 'sandbox' space to our 'default' space) and am having issues with 404s.

The object exists in the Sandbox space and I know the 'id' is correct as well as the 'type' from the .ndjson export.

If you could tell me what I'm missing, I would greatly appreciate it. Thanks in advance!

Well, from the Kibana UI I see two things.

  1. There is no action to share or copy a rule between spaces as opposed to other saved objects
  2. The tooltip on rules says the object is isolated (which is different from "Global" as stated for the settings). This tells me a rule is assigned to a Space only.

Also, I'm not seeing the rule (or alert) in the list of supported types for the get, or _bulk_get API endpoints. And when calling the _export method this object is excluded as you saw in your screenshot

I tested it on a rule as well:

curl -s -u "${ELASTIC_USER}:${ELASTIC_PASSWORD}" \
  -X POST -H 'kbn-xsrf: true' -H 'Content-Type: application/json' \
  "${KIBANA_HOST}/s/test-observability/api/saved_objects/_export" \
  -d '{"objects":[{"id":"909dd640-73fc-11ee-ad19-59828ae0e5c4","type":"alert"}],"includeReferencesDeep":true}' \
  | jq 
{
  "excludedObjects": [
    {
      "id": "909dd640-73fc-11ee-ad19-59828ae0e5c4",
      "reason": "excluded",
      "type": "alert"
    }
  ],
  "excludedObjectsCount": 1,
  "exportedCount": 0,
  "missingRefCount": 0,
  "missingReferences": []
}

I've also tested to run a copy of that rule to another space to confirm that a 404 is thrown.

curl -s -u "${ELASTIC_USER}:${ELASTIC_PASSWORD}" \
  -X POST -H 'kbn-xsrf: true' -H 'Content-Type: application/json' \
  "${KIBANA_HOST}/s/test-observability/api/spaces/_copy_saved_objects" \
  -d '{"objects":[{"type":"alert","id":"909dd640-73fc-11ee-ad19-59828ae0e5c4"}],"spaces":["public"]}' \
  | jq
{
  "statusCode": 404,
  "error": "Not Found",
  "message": "Saved objects not found",
  "attributes": {
    "objects": [
      {
        "id": "909dd640-73fc-11ee-ad19-59828ae0e5c4",
        "type": "alert"
      }
    ]
  }
}

So it seems pretty clear to me that rules are not supported as saved objects that can be managed through the Saved Objects API.

1 Like

Thank you for the response, @jsanz. I appreciate it. Hopefully this can eventually be supported in the near future.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.