Examples
Boiler Room comes with Templates for things worth checking on, and a new install puts them in your templates folder
(~/.config/boiler-room/templates/) the first time it starts, with some example Jobs, paused, to switch on. List
the Templates, or put them back if you've removed some:
boiler-room examples # what there is
boiler-room examples install # all of them; or name the ones you want
Installing never replaces a Template of the same name you already have. They're plain files in
~/.config/boiler-room/templates/ afterwards: read them, change them, copy them to make your own.
Waiting for something to finish #
These are made to be Errands: each runs until there's an answer, then tells you how it went and stops.
| Template | Waits for |
|---|---|
github-pr-checks |
A pull request's checks: "All 16 checks passed", or which failed |
github-run |
One GitHub Actions run, by its ID |
github-branch-ci |
Every Actions run on a branch's newest commit: after a push, "tell me when CI on main is done" |
github-pr-merged |
A pull request to be merged or closed |
forgejo-ci |
A Forgejo commit's CI status (needs boiler-room secret set forgejo-token) |
boiler-room submit --template github-pr-checks repo=cli/cli pr=15041 --loud
boiler-room submit --template github-branch-ci repo=owner/name --wait
They use gh, signed in (gh auth login), and jq.
Keeping an eye on something #
These are made to be Jobs, which run on their schedule and tell you when something changes:
| Template | Every | Tells you |
|---|---|---|
aws-support-case |
3h | Someone replied to the case, or its status changed |
agent-skills-outdated |
1d | Which skills installed with npx skills have updates |
service-status |
2m | A public status page's word changes: "All Systems Operational", "Partial System Outage" |
datadog-monitors |
2m | How many monitors with a tag are alerting, or have a warning or no data |
grafana-alerts |
2m | How many of a Grafana's alert rules are firing or pending |
newrelic-nrql |
2m | A NRQL query's number, red or amber past limits you give |
boiler-room new aws-support-case case=case-123456789012-abc profile=work
boiler-room new agent-skills-outdated
Other people's services #
These four give each Job one Gauge: its tone is the colour and its icon what it's about, so a page of them reads as a
grid of lights. Put them on a Dashboard page as a status grid, and a Job's open_in says where clicking one opens.
service-status needs no key and works for any site on Atlassian Statuspage; the others need keys kept in the
Keychain, which the Script receives as environment variables.
boiler-room new service-status site=www.githubstatus.com service=GitHub icon=github
boiler-room new service-status site=www.cloudflarestatus.com service=Cloudflare icon=cloud
boiler-room secret set datadog-api-key
boiler-room secret set datadog-app-key
boiler-room new datadog-monitors tag=service:checkout
boiler-room secret set grafana-token
boiler-room new grafana-alerts url=https://grafana.example.com
boiler-room secret set newrelic-key
boiler-room new newrelic-nrql account=1234567 nrql="SELECT percentage(count(*), WHERE error IS true) FROM Transaction SINCE 5 minutes ago" bad=5 unit=%
A site that can't be reached is a failed Run, which isn't the same as the service being down, so a broken check doesn't turn a light red; its last answer just goes stale, and the status grid says so.
Many Gauges from one query #
The Templates above give a Job one Gauge. When one query answers for many things, report them all from a single Job, so an observability platform is asked once, not once per tile. This Job asks New Relic for error rate by service and gives each its own Gauge:
name = "Error rate by service"
every = "2m"
shell = "/bin/sh"
secrets = ["newrelic-key"]
run = '''
query='query($a: Int!, $q: Nrql!) { actor { account(id: $a) { nrql(query: $q) { results } } } }'
q='SELECT percentage(count(*), WHERE error IS true) AS rate FROM Transaction FACET appName SINCE 5 minutes ago'
body=$(jq -n --arg query "$query" --arg q "$q" --argjson a 1234567 '{query: $query, variables: {a: $a, q: $q}}') || exit 2
curl -fsS https://api.newrelic.com/graphql -H "API-Key: $NEWRELIC_KEY" -H "Content-Type: application/json" -d "$body" |
jq -r '.data.actor.account.nrql.results[] | "\(.appName) \(.rate)"' |
while read -r app rate; do
boiler-room value "$app" "$rate%" --max 100 --warn-above 2 --bad-above 5 --icon activity --group "Error rate"
done
'''
A few more, each one call and many tiles:
Every check of a pull request, a light per check, from gh:
gh pr checks "$BOILER_ROOM_PARAM_PR" --json name,bucket |
jq -r '.[] | "\(.name)\t\(.bucket)"' |
while IFS="$(printf '\t')" read -r check bucket; do
case $bucket in pass) tone=good ;; fail) tone=bad ;; *) tone=warn ;; esac
boiler-room value "$check" "$bucket" --tone "$tone" --icon git-pull-request --group "PR checks"
done
Disk use of every volume, a dial each:
df -P -k | awk 'NR>1 && $1 ~ /^\/dev\// {gsub("%","",$5); print $6, $5}' |
while read -r mount used; do
name=$(basename "$mount"); [ "$name" = / ] && name=root
boiler-room value "disk-$name" "$used%" --max 100 --show ring \
--warn-above 75 --bad-above 90 --icon hard-drive --group Disks
done
This month's AWS spend by service, which is one Cost Explorer call (they're billed) that you'd not want ten of:
aws ce get-cost-and-usage --time-period Start=$(date +%Y-%m-01),End=$(date -v+1d +%Y-%m-%d) \
--granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE \
--query 'ResultsByTime[0].Groups[].[Keys[0],Metrics.UnblendedCost.Amount]' --output text |
while IFS="$(printf '\t')" read -r service amount; do
boiler-room value "$service" "$(printf '$%.2f' "$amount")" --icon dollar-sign --group "AWS spend"
done
Pods that aren't running, per namespace, from kubectl, with a Python script that does the sums:
name = "Pods by namespace"
every = "1m"
runner = "python3"
script = '''
import json, subprocess
import boiler_room as br
pods = json.loads(subprocess.check_output(["kubectl", "get", "pods", "-A", "-o", "json"]))["items"]
bad = {}
for pod in pods:
ns = pod["metadata"]["namespace"]
bad.setdefault(ns, 0)
if pod["status"]["phase"] not in ("Running", "Succeeded"):
bad[ns] += 1
for ns, n in bad.items():
br.value(ns, n, tone="bad" if n else "good", icon="box", group="Not running")
'''
Put the Gauges on a Dashboard page as a status grid. How a Job reports them is in Many Gauges from one Run.
Just watching numbers #
These Jobs only feed Gauges. A Gauge with thresholds is a Change only when its tone changes, so the Jobs with
--warn-above and --bad-above tell you only when a number crosses one; the others, whose numbers have no thresholds,
say notify = "never", since a number that moved isn't news. Use "on-failure" instead to be told when the query
itself stops working. Each one asks its platform once and gives
every series its own Gauge.
Prometheus, a Gauge per job from one instant query:
name = "Prometheus up"
every = "1m"
shell = "/bin/sh"
notify = "never"
run = '''
curl -fsS "http://prometheus.example.com:9090/api/v1/query" \
--data-urlencode 'query=sum by (job) (up)' |
jq -r '.data.result[] | "\(.metric.job) \(.value[1])"' |
while read -r job up; do
boiler-room value "up-$job" "$up" --max 10 --icon server --group Prometheus
done
'''
CloudWatch, Lambda errors over the last fifteen minutes for a few functions. get-metric-statistics has no data
for a quiet function, which is zero errors, not a broken check:
name = "Lambda errors"
every = "5m"
shell = "/bin/sh"
notify = "on-failure"
run = '''
from=$(date -u -v-15M +%Y-%m-%dT%H:%M:%SZ); to=$(date -u +%Y-%m-%dT%H:%M:%SZ)
for fn in checkout-api orders-worker emailer; do
n=$(aws cloudwatch get-metric-statistics --namespace AWS/Lambda --metric-name Errors \
--dimensions Name=FunctionName,Value=$fn --start-time "$from" --end-time "$to" \
--period 900 --statistics Sum --query 'Datapoints[0].Sum' --output text) || exit 2
case $n in None|"") n=0 ;; esac
boiler-room value "$fn-errors" "$n" --warn-above 1 --bad-above 10 --icon zap --group "Lambda errors"
done
'''
Datadog, one metrics query with a Gauge for each host it groups by. Keep the keys in the Keychain
(boiler-room secret set datadog-api-key, and datadog-app-key):
name = "CPU by host"
every = "2m"
shell = "/bin/sh"
notify = "never"
secrets = ["datadog-api-key", "datadog-app-key"]
run = '''
now=$(date +%s)
curl -fsSG "https://api.datadoghq.com/api/v1/query" \
-H "DD-API-KEY: $DATADOG_API_KEY" -H "DD-APPLICATION-KEY: $DATADOG_APP_KEY" \
--data-urlencode "from=$((now - 300))" --data-urlencode "to=$now" \
--data-urlencode "query=avg:system.cpu.user{*} by {host}" |
jq -r '.series[] | "\(.scope | sub("host:"; "")) \(.pointlist[-1][1])"' |
while read -r host cpu; do
boiler-room value "cpu-$host" "$(printf '%.0f' "$cpu")%" --max 100 --show ring \
--warn-above 70 --bad-above 90 --icon cpu --group "CPU"
done
'''
A checklist of SLOs, one Gauge that lists them, from a Python script that does the sums. --item gives each line
its own tone, and a link too, --item "checkout=bad=https://slo.example.com/checkout", which opens when the line is
clicked (in Python, items=[("checkout", "bad", "https://…")]):
name = "SLOs"
every = "10m"
runner = "python3"
notify = "never"
script = '''
import json, subprocess
import boiler_room as br
slos = json.loads(subprocess.check_output(["./slo-report.sh"], text=True)) # {"checkout": 99.95, "search": 99.2}
items = {name: ("good" if pct >= 99.9 else "warn" if pct >= 99.0 else "bad") for name, pct in slos.items()}
worst = min(slos.values())
br.value("slos", f"{worst:.2f}% worst", show="list", items=items, icon="target", group="SLOs")
'''
One Job per service, when each needs its own schedule and history, is a Template: make it once and
boiler-room new a Job for each, then put their Gauges on one page. See Jobs.
The example Jobs #
A new install's Jobs folder starts with these, paused. Switch one on in the list to try it:
| Job | Every | Tells you |
|---|---|---|
| Example: GitHub's status | 30m | GitHub's status changes |
| Example: Is the internet up? | 5m | Your connection drops, and when it's back |
| Example: Disk space | 6h | Your startup disk is over 90% full |
| Example: macOS updates | 1d | Software Update has something new |
| Example: Homebrew updates | 1d | brew outdated has something new |
They're files in ~/.config/boiler-room/jobs/, worth reading for how a Job reports: each prints what it found, a
line of JSON to tell you something, and keeps what it saw last in its own folder, $BOILER_ROOM_STATE.
Writing your own #
Each is a few lines of /bin/sh that checks once and prints what it found as a line of JSON:
{"values": {"status": "…"}} for something to compare with the last Run, {"notify": "…", "link": "…"} for something
to tell you. An Errand's Template exits 0 once it's done and 1 while it isn't, with until = "exit 0". See
Jobs for everything a Template can say.
Phin Tech docs
Boiler Room in the store →