Queries a Graylog log aggregator via its REST API to search logs, debug production incidents, and verify deployments. Publishes findings as a shareable HTML report artifact.
Ships in graylog-search. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Query a Graylog log aggregator through its REST API instead of clicking through the UI. Works with any Graylog 4/5/6 cluster that has API tokens enabled.
This skill has two halves and both are expected: (1) query the logs, (2) publish the findings as an HTML report artifact — see Deliverable: HTML report artifact. A search whose results never leave the terminal is an unfinished job.
The skill is instance-agnostic; everything specific to your cluster comes from environment variables:
| Variable | Required | Meaning |
|---|---|---|
GRAYLOG_URL | yes | Base URL, e.g. https://graylog.example.com (no trailing slash, no /api) |
GRAYLOG_API_TOKEN | yes | Personal API token (Graylog UI: System → Users → your user → Edit tokens) |
GRAYLOG_STREAM_ID | often | Stream to scope searches to — see Stream scope |
If a required variable is not set, ask the user to provide it once per session — do not invent or guess values. Never commit a token to git.
curl -sS -u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
"$GRAYLOG_URL/api/system" | head -c 400
Expect HTTP 200 and JSON with lifecycle: "running". A 401 means the token is
invalid or expired — ask the user to regenerate one in the Graylog UI.
All API calls use HTTP Basic with <token>:token — the literal word token
as the password. Required headers on every call:
Accept: application/jsonX-Requested-By: cli (Graylog CSRF guard; any non-empty value works)On many clusters, token permissions are granted per stream, and a search
without a stream filter returns Not authorized (even with a valid token)
or misleading empty results. If that happens, scope every
/search/universal/… call to a stream:
--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"
Find stream ids with GET /api/streams, or in the Graylog UI: Streams →
open the stream → the id is in the URL (…/streams/<STREAM_ID>/…).
| Endpoint | When |
|---|---|
GET /api/search/universal/relative?query=…&range=… | "Last N seconds" — range in seconds (3600 = 1h, 86400 = 24h) |
GET /api/search/universal/absolute?query=…&from=…&to=… | Specific window; from/to ISO-8601 UTC |
GET /api/search/universal/relative/histogram?…&interval=hour | Count over time |
GET /api/search/universal/relative/terms?…&field=…&size=… | Terms aggregation — top values for a field |
GET /api/streams | List streams and their ids |
GET /api/system | Health/auth check |
Add filter=streams:… to every search call if your cluster needs it (above).
Always pass &limit=200 (or smaller) and a &fields=… list (e.g.
timestamp,source,level,message) so you don't pull full message payloads —
Graylog can return huge GELF blobs otherwise and blow up your context window.
Field names vary by log shipper (Monolog GelfHandler, logstash, fluentd, nxlog, …), and guessing them is the #1 source of silent empty results. Before building real queries, pull one raw message and look at its keys:
curl -sS -G "$GRAYLOG_URL/api/search/universal/relative" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode "query=*" \
--data-urlencode "range=3600" \
--data-urlencode "limit=1" \
| jq '.messages[0].message | keys'
Things to establish from that sample:
application, project, service,
facility, container_name… there is no universal convention.level means. GELF proper uses syslog severity 0–7, lower =
more severe (0=EMERG … 3=ERROR … 7=DEBUG), so "errors and worse" is
level:<=3. But some pipelines ship raw framework levels (Monolog
100–500, higher = worse). Look at actual values before filtering — the
wrong assumption matches nothing and looks like "no errors".message vs short_message — some clusters index both, some only one.To enumerate services/values live, use a terms aggregation on the candidate
field (recipe 4 with field=<your service field>).
Graylog uses a Lucene-like syntax:
service:checkout AND level:<=3
service:checkout AND ("connection refused" OR "timeout")
service:api AND env:prod AND NOT level:7
source:worker-* AND message:/Connection.*refused/
* and ?. Leading * is allowed but slow./.../ (slow, last resort).level:[0 TO 3] or level:<=3.AND, OR, NOT (uppercase).from/to must be ISO-8601 UTC, and the timestamp field you get
back is UTC.GET /api/system (timezone field).All recipes assume GRAYLOG_URL, GRAYLOG_API_TOKEN and (if needed)
GRAYLOG_STREAM_ID are exported, and use service as the service-identifying
field — substitute your own (see field discovery above).
curl -sS -G "$GRAYLOG_URL/api/search/universal/relative" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode "query=service:checkout AND level:<=3" \
--data-urlencode "range=3600" \
--data-urlencode "limit=50" \
--data-urlencode "fields=timestamp,level,source,message" \
| jq '.messages[].message | {timestamp, level, source, msg: .message}'
curl -sS -G "$GRAYLOG_URL/api/search/universal/absolute" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode 'query=service:checkout AND "Failed to fetch mailing list"' \
--data-urlencode "from=2026-05-11T08:00:00.000Z" \
--data-urlencode "to=2026-05-11T12:00:00.000Z" \
--data-urlencode "limit=200" \
--data-urlencode "fields=timestamp,source,message"
curl -sS -G "$GRAYLOG_URL/api/search/universal/relative/histogram" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode "query=service:checkout AND level:<=3" \
--data-urlencode "range=86400" \
--data-urlencode "interval=hour" \
| jq '.results | to_entries | map({h: (.key|tonumber|strftime("%m-%d %HZ")), count: .value}) | sort_by(.h)'
curl -sS -G "$GRAYLOG_URL/api/search/universal/relative/terms" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode "query=level:<=3" \
--data-urlencode "range=3600" \
--data-urlencode "field=source" \
--data-urlencode "size=20"
curl -sS -G "$GRAYLOG_URL/api/search/universal/relative" \
-u "$GRAYLOG_API_TOKEN:token" \
-H "Accept: application/json" -H "X-Requested-By: cli" \
${GRAYLOG_STREAM_ID:+--data-urlencode "filter=streams:$GRAYLOG_STREAM_ID"} \
--data-urlencode "query=service:checkout" \
--data-urlencode "range=900" \
--data-urlencode "limit=50" \
--data-urlencode "sort=timestamp:desc" \
--data-urlencode "fields=timestamp,level,source,message"
scripts/gl-search.sh wraps the most common case (relative window, fixed
fields, jq one-line formatting):
./scripts/gl-search.sh 'service:checkout AND level:<=3' 3600
./scripts/gl-search.sh '"OutOfMemory"' 900 200
The deliverable of an investigation is a link to a readable HTML report,
not a wall of JSON in the terminal. After a search that returns data, publish
the findings with the Artifact tool — proactively, without being asked. Skip
only when the user explicitly declines, or when the search returned zero rows
(then just say so in chat).
Workflow:
Artifact tool: stable emoji favicon (use 🪵), a
one-sentence description, a <title> inside the HTML.Page structure, top to bottom: header (service + time window + as-of date), 2–4 stat tiles, key-insight callout (the sentence you'd post in the incident channel), histogram, log table (timestamp UTC, level, source, message truncated to ~200 chars, status chips for errors), footer with the exact query, stream id, window and limit so anyone can reproduce the search 1:1.
Content rules:
:root, overridden in
@media (prefers-color-scheme: dark) and :root[data-theme="dark"] /
:root[data-theme="light"].div with overflow-x: auto.<!DOCTYPE>, <html>, <head>, <body> — the publisher wraps
the file; start with <title> + <style> + content.If the Artifact tool is not available in the current harness (older
Claude Code, artifacts disabled by org policy), do not silently drop the
report: write the same HTML file, give the user its absolute path ("open this
in a browser"), and mention that updating Claude Code brings the Artifact
tool. A missing tool is never a reason to fall back to a terminal-only answer.
The companion skill publish-report-artifact (same marketplace) has a full
house-style template if you want a more polished report.
level scale — the single most common mistake. On GELF-normalised
clusters level:>=400 matches nothing (levels are 0–7, lower = worse); on
raw-Monolog clusters level:<=3 matches nothing. Check a sample message.application:foo vs service:foo vs
project:foo; a wrong field name returns zero rows, not an error. Field
names are case-sensitive.Not authorized on search but /api/system works — almost always a
missing filter=streams:<id>; the token can't search outside its streams.
Add the filter and retry; if it still fails, check the stream's reader
permissions in the Graylog UI.kubectl logs, journald) before
concluding the bug didn't fire.--data-urlencode over inline ?query=…,
otherwise &, :, and spaces get mangled.range=60) for near-real-time, or use the Graylog UI.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/graylog-search:graylog-searchfrom graylog-search
npx claudepluginhub freema/ai-skills --plugin graylog-search