Skip to content

Instantly share code, notes, and snippets.

@ihard
Last active December 23, 2021 13:51
Show Gist options
  • Save ihard/493423806d3eae4d89d415a9a8ce462d to your computer and use it in GitHub Desktop.
Save ihard/493423806d3eae4d89d415a9a8ce462d to your computer and use it in GitHub Desktop.
backfill prom metric via vmalert
cat <<EOF > rules.yml
---
groups:
- name: main
rules:
EOF
curl -s -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]={job="grafana"}' \
--data-urlencode 'start=2021-07-19T00:00:00+03:00' --data-urlencode 'end=2021-07-19T23:00:00+03:00' | \
jq .data[].__name__ | sort | uniq | \
xargs -I {} echo -e " - record: {}\n expr: {}" >> rules.yml
vmalert-prod -rule=rules.yml -datasource.url=http://localhost:9090 -remoteWrite.url=http://localhost:8429 \
-replay.timeFrom=2021-04-22T00:00:00Z -replay.timeTo=2021-07-20T00:10:00Z \
-datasource.queryStep=30s -replay.rulesDelay=1s -remoteWrite.flushInterval=1s \
-remoteWrite.concurrency=20 &> rules.log &
tail -f rules.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment