Created
June 29, 2022 00:57
-
-
Save spong/5c2bec554fae203f4cf956b1c09b295c to your computer and use it in GitHub Desktop.
Bulk Add Actions to Rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ACTIONS='[{"group":"default","id":"b1331930-f6f1-11ec-a712-05a690d63aa5","params":{"message":"Rule{{context.rule.name}}generated{{state.signals_count}}alerts"},"action_type_id":".slack"}]' | |
| RULES=$(curl -s -k -u elastic:changeme -X GET http://localhost:5601/kbn/api/detection_engine/rules/_find\?page\=1\&per_page\=10000 | jq --argjson ACTIONS "$ACTIONS" '[.data | .[] | {rule_id, actions: $ACTIONS, throttle: "rule"}]') | |
| echo $RULES | jq . | |
| curl -s -k \ | |
| -H 'Content-Type: application/json' \ | |
| -H "Accept: application/json" \ | |
| -H 'kbn-xsrf: 123' \ | |
| -u elastic:changeme \ | |
| -X PATCH http://localhost:5601/kbn/api/detection_engine/rules/_bulk_update \ | |
| -d "$RULES" \ | |
| -v \ | |
| | jq .; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment