Import Objects API for Rules/Connectors

Hello, Elastic!

I'm currently using a curl command to push an Alert Rule. Currently the rule gets created but is created in a 'disabled' state (see warnings.message):

{
  "successCount": 1,
  "success": true,
  "warnings": [
    {
      "type": "action_required",
      "message": "1 rule must be enabled after the import.",
      "actionPath": "/app/management/insightsAndAlerting/triggersActions/rules",
      "buttonLabel": "Go to rules"
    }
  ],
  "successResults": [
    {
      "type": "alert",
      "id": "4f1d10f0-62bd-11ee-b140-ffc91b5c916c",
      "meta": {
        "title": "Rule: [ADAM TEST RULE]"
      },
      "managed": false,
      "destinationId": "311fe229-f99d-43d5-b3c5-24f72b231fdb"
    }
  ]
}

Here is the curl command:

curl -u "$KIBANA_USERNAME:$KIBANA_PASSWORD" -X POST "$KIBANA_URL/api/saved_objects/_import?overwrite=true" -H "kbn-xsrf: true" --form "file=@$ENVIRONMENT/rules/$FILENAME"

The Import objects API documentation doesn't seem to mention any parameters that can be set to automatically enable objects when created.

If you could provide an example on how to do this, it would be greatly appreciated.

Thanks in advance!

Adam

UPDATE - It looks like setting the "enabled":false property to true in the corresponding .ndjson file sets it so that the alert rule becomes enabled after it is created via the curl request.

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