Slack alert functions for Google BigQuery query performance and billing with Cloud Functions.
Sample Slack alert.
BigQuery Log(Cloud Logging) --> Cloud PubSub --> Cloud Functions(filter and notify) --> Slack
- Terraform 0.13 or later
- Python 3.9
- google-cloud-sdk
- Slack Webhook URL
Set your config and customize message in ./src/config.py
SLACK_ICON_EMOJI = ':male-police-officer:'
SLACK_USERNAME = 'bq-police'
SLACK_CHANNEL = 'random'
SLOT_ALERT_THRESHOLD = 7200000 # 120min slots
BILLED_BYTE_ALERT_THRESHOLD = 1*1000*1000*1000*1000 # 1TB
PROCESSED_BYTE_ALERT_THRESHOLD = 1*1000*1000*1000*1000 # 1TB
SLACK_ALERT_MESSAGE_TEXT = "Query Alert!!"
- Google Login.
gcloud auth application-default login
- terraform plan and apply with your GCP Project ID.
cd infrastructure/terraform
terraform init
export TF_VAR_project_id=<your GCP Project ID>
export TF_VAR_slack_webhook_url=<your Slack Webhook URL>
terraform plan
terraform apply
TBD