Exporting all alerts from a space into a json file

Hello,

I am trying to test a tool and I am in need of a way to export all alerts from a space into a json or txt file. I have looked around online and cannot find forum posts involving this and when asking claude I only face errors.

If anyone has any tips, ideas or solutions please let me know.

from,

Ben Tyler

Hi, you can call Kibana directly using a curl command in terminal.

// curl export API
curl -k -X POST "https://[kibana_url]/s/[space]/api/saved_objects/_export" -H "kbn-xsrf: true" -H "Content-Type: application/json" -d '{"type":["alert"],"includeReferencesDeep":true}' -o alerts_rules.ndjson -u ID:PASSWORD

// result
cat alerts_rules.ndjson
{"excludedObjects":[{"id":"30d8ac54-4b33-410a-bcf9-4b361e27b4a8","reason":"excluded","type":"alert"}],"excludedObjectsCount":1,"exportedCount":0,"missingRefCount":0,"missingReferences":[]}