Skip to main content

Examples

Common recipes using curl and jq. Set this once so the examples run as-is:

export JWT="<YOUR-JWT>" # see Authentication

Tokens expire after 6 hours. For long-running scripts, refresh instead of re-logging-in:

JWT=$(curl -s -X POST https://api.backend.stealthium.io/api/v1/auth/refresh \
-H "Content-Type: application/json" -H "Accept: application/json" \
-d "{\"refresh_token\": \"$REFRESH_TOKEN\"}" | jq -r '.access_token')

Recent high-priority alerts

Active critical and high alerts from the last 24 hours:

curl -sG "https://api.stealthium.io/api/v1/alerts/" \
--data-urlencode "filter[severity][in]=critical,high" \
--data-urlencode "filter[state][equals]=active" \
--data-urlencode "from=$(date -u -v-24H +%Y-%m-%dT%H:%M:%SZ)" \
-H "Authorization: Bearer $JWT" |
jq -r '.alerts[] | [.created_at, .severity, .hostname, .title] | @tsv'

On Linux, replace the date call with date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ.

Alerts from one host

Everything whose hostname starts with gpu-node-1:

curl -sG "https://api.stealthium.io/api/v1/alerts/" \
--data-urlencode "filter[hostname][startsWith]=gpu-node-1" \
-H "Authorization: Bearer $JWT" | jq '.total_size'

Page through all alerts

Follow next_page_token until it's gone:

token=""
while :; do
page=$(curl -sG "https://api.stealthium.io/api/v1/alerts/" \
--data-urlencode "page_size=1000" \
${token:+--data-urlencode "page_token=$token"} \
-H "Authorization: Bearer $JWT")
echo "$page" | jq -r '.alerts[].id'
token=$(echo "$page" | jq -r '.next_page_token // empty')
[ -z "$token" ] && break
done

Severity breakdown for a dashboard

Counts per severity, type, and state in one call:

curl -s "https://api.stealthium.io/api/v1/alerts:summary" \
-H "Authorization: Bearer $JWT" |
jq -r '.summary.severity[] | "\(.value)\t\(.count)"'

Severity trend over a week

Per-severity counts in time buckets, ready for a chart:

curl -sG "https://api.stealthium.io/api/v1/alerts:severityTrend" \
--data-urlencode "from=$(date -u -v-7d +%Y-%m-%dT%H:%M:%SZ)" \
-H "Authorization: Bearer $JWT" |
jq -r '.points[] | [.bucket, .severity, .count] | @tsv'

Find unhealthy GPUs

GPUs that aren't healthy, with host and temperature (missing means the GPU stopped reporting):

curl -s "https://api.stealthium.io/api/v1/gpus" \
-H "Authorization: Bearer $JWT" |
jq -r '.gpus[] | select(.health != "healthy")
| [.health, .hostname, .model, .temperature_c] | @tsv'

Fleet health at a glance

Key numbers from the metrics summary:

curl -s "https://api.stealthium.io/api/v1/metrics" \
-H "Authorization: Bearer $JWT" |
jq '.metrics.metrics_summary
| {gpu_count, avg_gpu_utilization, avg_gpu_temperature, total_xid_errors}'