Automating Connectors via Saved Object API

Hi folks!

I'm attempting to automate Dashboards and Alerts for a team within my company. This involves creating a MS Teams Connector. I have written a bash script that posts the Connector NDJSON to the Saved Objects endpoint via curl.

I had some problems initially, as Saved Objects exported from Kibana do not contain secrets or sensitive information. Here's an example of the exported Connector (formatted for readability):

{
  "attributes": {
    "actionTypeId": ".teams",
    "config": {},
    "isMissingSecrets": true,
    "name": "MS Teams Connector"
  },
  "coreMigrationVersion": "8.4.3",
  "id": "redacted",
  "migrationVersion": {
    "action": "8.3.0"
  },
  "references": [],
  "type": "action",
  "updated_at": "2022-12-07T12:09:25.255Z",
  "version": "redacted"
}
{
  "excludedObjects": [],
  "excludedObjectsCount": 0,
  "exportedCount": 1,
  "missingRefCount": 0,
  "missingReferences": []
}

Uploading this exported NDJSON resulted in the following error in the Kibana GUI:

1 connector has sensitive information that require updates.

After some digging around, I found the following PR on elastic/kibana which hinted at a secrets field which was missing from my exported NDJSON.

I modified my existing NDJSON body and added the following:

{
  "attributes": {
    [...]
    "secrets": {
      "webhookUrl": "redacted"
    },
    "isMissingSecrets": false,
    [...]
  },
  [...]
}
{
  [...]
}

And this succeeds. The Connector has the webhook.

My question is, is this the intended approach? As I can find little documentation in the REST API documentation focusing on this. If someone has a link to some documentation on this, I'd be ever so happy!

Hi @Hayden_WB

Below Doc could help you.

1 Like

Ersin, yes! Perfect, thanks for this - am on an older version, but can see the docs are there for < 8.5 for the various connectors.

Thanks so much!

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