Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
creates alerts with the "built-in" .fizz-buzz Kibana alert type
#!/usr/bin/env bash
source ~/.kbn-fizz-buzz-secrets.sh
ACTION_ID_SELOG=`kbn-action create .server-log "fizz-buzz server-log" "{}" "{}" | jq -r ".id"`
ACTION_ID_SLACK=`kbn-action create .slack "fizz-buzz slack" "{}" "{webhookUrl: '$SLACK_WEBHOOKURL'}" | jq -r ".id"`
ACTION_ID_EMAIL=`kbn-action create .email "fizz-buzz email" "{service: '$EMAIL_SERVICE', from: '$EMAIL_FROM'}" "{user: '$EMAIL_USER' password: '$EMAIL_PASSWORD'}" | jq -r ".id"`
ACTION_ID_INDEX=`kbn-action create .index "fizz-buzz index" "{index: 'fizz-buzz'}" "{}" | jq -r ".id"`
ACTION_ID_PDUTY=`kbn-action create .pagerduty "fizz-buzz pagerduty" "{}" "{routingKey: '$PAGERDUTY_ROUTING_KEY'}" | jq -r ".id"`
ACTION_PARAMS_FIZZ_SELOG="{group:fizz id:'$ACTION_ID_SELOG' params:{message: '{{context.count}} fizz'}}"
ACTION_PARAMS_BUZZ_SELOG="{group:buzz id:'$ACTION_ID_SELOG' params:{message: '{{context.count}} buzz'}}"
ACTION_PARAMS_FUZZ_SELOG="{group:'fizz-buzz' id:'$ACTION_ID_SELOG' params:{message: '{{context.count}} fizz-buzz'}}"
ACTION_PARAMS_FIZZ_SLACK="{group:fizz id:'$ACTION_ID_SLACK' params:{message: '{{context.count}} fizz'}}"
ACTION_PARAMS_BUZZ_SLACK="{group:buzz id:'$ACTION_ID_SLACK' params:{message: '{{context.count}} buzz'}}"
ACTION_PARAMS_FUZZ_SLACK="{group:'fizz-buzz' id:'$ACTION_ID_SLACK' params:{message: '{{context.count}} fizz-buzz'}}"
ACTION_PARAMS_FIZZ_EMAIL="{group:fizz id:'$ACTION_ID_EMAIL' params:{subject: 'hallo' to: ['$EMAIL_TO'] message: '{{context.count}} fizz'}}"
ACTION_PARAMS_BUZZ_EMAIL="{group:buzz id:'$ACTION_ID_EMAIL' params:{subject: 'hallo' to: ['$EMAIL_TO'] message: '{{context.count}} buzz'}}"
ACTION_PARAMS_FUZZ_EMAIL="{group:'fizz-buzz' id:'$ACTION_ID_EMAIL' params:{subject: 'hallo' to: ['$EMAIL_TO'] message: '{{context.count}} fizz-buzz'}}"
ACTION_PARAMS_FIZZ_INDEX="{group:fizz id:'$ACTION_ID_INDEX' params:{documents: [{count: '{{context.count}}', date: '{{context.date}}', event: 'fizz'}]}}"
ACTION_PARAMS_BUZZ_INDEX="{group:buzz id:'$ACTION_ID_INDEX' params:{documents: [{count: '{{context.count}}', date: '{{context.date}}', event: 'buzz'}]}}"
ACTION_PARAMS_FUZZ_INDEX="{group:'fizz-buzz' id:'$ACTION_ID_INDEX' params:{documents: [{count: '{{context.count}}', date: '{{context.date}}', event: 'fizz-buzz'}]}}"
ACTION_PARAMS_FIZZ_PDUTY="{group:fizz id:'$ACTION_ID_PDUTY' params:{eventAction: 'trigger' summary: '{{context.count}} fizz'}}"
ACTION_PARAMS_BUZZ_PDUTY="{group:buzz id:'$ACTION_ID_PDUTY' params:{eventAction: 'acknowledge' summary: '{{context.count}} buzz'}}"
ACTION_PARAMS_FUZZ_PDUTY="{group:'fizz-buzz' id:'$ACTION_ID_PDUTY' params:{eventAction: 'resolve' summary: '{{context.count}} fizz-buzz'}}"
kbn-alert create .fizz-buzz 1s {} "[$ACTION_PARAMS_FIZZ_SELOG, $ACTION_PARAMS_BUZZ_SELOG, $ACTION_PARAMS_FUZZ_SELOG]"
kbn-alert create .fizz-buzz 1s {} "[$ACTION_PARAMS_FIZZ_SLACK, $ACTION_PARAMS_BUZZ_SLACK, $ACTION_PARAMS_FUZZ_SLACK]"
kbn-alert create .fizz-buzz 1s {} "[$ACTION_PARAMS_FIZZ_EMAIL, $ACTION_PARAMS_BUZZ_EMAIL, $ACTION_PARAMS_FUZZ_EMAIL]"
kbn-alert create .fizz-buzz 1s {} "[$ACTION_PARAMS_FIZZ_INDEX, $ACTION_PARAMS_BUZZ_INDEX, $ACTION_PARAMS_FUZZ_INDEX]"
kbn-alert create .fizz-buzz 1s {} "[$ACTION_PARAMS_FIZZ_PDUTY, $ACTION_PARAMS_BUZZ_PDUTY, $ACTION_PARAMS_FUZZ_PDUTY]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.