Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Add quickstart script for alert generator compliance test #5441

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions scripts/alert-compliance-quickstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# This is a script for running the Prometheus Alert Generator Compliance
# test suite. Read more at: https://github.com/prometheus/compliance/tree/main/alert_generator
#
# It is the most minimal setup you can use for testing on a local machine.
# The script will start all necessary components (receive, ruler, querier)
# with appropriate confguration.
#
# After all comopnents are running, you can start the alert generator compliance tester
matej-g marked this conversation as resolved.
Show resolved Hide resolved
# with `thanos-example.yaml`` configuration provided in here:
# https://github.com/prometheus/compliance/blob/main/alert_generator/test-prometheus.yaml
matej-g marked this conversation as resolved.
Show resolved Hide resolved
set -euo pipefail

trap 'kill 0' SIGTERM

THANOS_EXECUTABLE=${THANOS_EXECUTABLE:-"thanos"}

export TMP_DATA=$(mktemp -d /tmp/data-XXXX)
matej-g marked this conversation as resolved.
Show resolved Hide resolved
export ALERT_COMPLIANCE_RULES=$(mktemp /tmp/rules-XXXX.yaml)
matej-g marked this conversation as resolved.
Show resolved Hide resolved

curl -sNL -o ${ALERT_COMPLIANCE_RULES} "https://raw.githubusercontent.com/prometheus/compliance/main/alert_generator/rules.yaml"
matej-g marked this conversation as resolved.
Show resolved Hide resolved

${THANOS_EXECUTABLE} receive \
--label "receive_replica=\"0\"" \
--tsdb.path=${TMP_DATA} &
matej-g marked this conversation as resolved.
Show resolved Hide resolved

# We make sure to filter out the 'receive_replica' and 'tenant_id' labels,
# which are added by the receiver (they cannot be present during the test).
${THANOS_EXECUTABLE} query \
--http-address 0.0.0.0:19192 \
--store 0.0.0.0:10901 \
--rule 0.0.0.0:20901 \
--grpc-address 0.0.0.0:19099 \
--query.replica-label="tenant_id" \
--query.replica-label="receive_replica" &

# Script downloads the compliance test rules into a tmp file that `--rule-file` is pointing to.
${THANOS_EXECUTABLE} rule \
--rule-file=${ALERT_COMPLIANCE_RULES} \
matej-g marked this conversation as resolved.
Show resolved Hide resolved
--alertmanagers.url="http://0.0.0.0:8080" \
--query=0.0.0.0:19192 \
--http-address=0.0.0.0:20902 \
--grpc-address=0.0.0.0:20901 \
--data-dir=${TMP_DATA} &
matej-g marked this conversation as resolved.
Show resolved Hide resolved

sleep 0.5

printf "\nAll services started, you can start the alert compliance tester! Waiting on a signal to quit\n"

wait