metrics-chart

โดย axiomhq

แสดงผลลัพธ์การค้นหาเมตริกของ Axiom (application/vnd.metrics.v3+json) เป็นกราฟเส้น ใช้ Unicode/ASCII แบบไม่พึ่งพาไลบรารีเป็นค่าเริ่มต้น อัปเกรดเป็น PNG/SVG/sixel แบบอินไลน์ได้…

npx skills add https://github.com/axiomhq/skills --skill metrics-chart

metrics-chart

Turns a metrics query response into a multi-series line chart.

Input is exactly the body the Axiom metrics query service returns for application/vnd.metrics.v3+json — defined in the metrics query service (service/query, JsonV3QueryResponse in src/server.rs). It is a regularly-sampled, multi-series time series; this skill draws it.

TL;DR

# From a file, stdout picks the best renderer for your terminal:
python3 scripts/metrics_chart.py response.json

# From a pipe (e.g. straight off the query API):
curl ... -H 'Accept: application/vnd.metrics.v3+json' | python3 scripts/metrics_chart.py

# Force a zero-dependency ASCII chart (always works, anywhere):
python3 scripts/metrics_chart.py --format ascii response.json

Aggregate first. Charts are only readable with a handful of series. The cleanest result comes from a query that already groups/aggregates to a few lines (e.g. group by status rather than per-pod). This skill's series reduction (below) is a safety net for high-cardinality results, not a substitute for aggregating in the query.

Input format (vnd.metrics.v3+json)

{
  "metadata": {
    "group_keys": ["code", "method"],
    "warnings": [],
    "unit": "ms",
    "custom_unit": "millisec"
  },
  "series": [
    {
      "metric": "http_requests",
      "tags": { "code": 200, "method": "GET", "path": "/" },
      "start": 1750753164,
      "resolution": 60,
      "data": [420.0, 42.0, 30.0, 9.0, 15.0, 18.0]
    }
  ]
}
FieldMeaning
metadata.group_keysTags the query grouped on → used to build legend labels.
metadata.warningsShown as captions under the chart.
metadata.unitCanonical y-axis unit (ms, bytes, …).
metadata.custom_unitHuman y-axis label; preferred over unit when present.
series[].startUnix seconds (UTC) of data[0].
series[].resolutionSeconds per point; x[i] = start + resolution*i (uniform spacing).
series[].dataY values; null = gap (the line breaks, it is not drawn as 0).

The parser also accepts v2/v2a (same shape with an extra per-series summary, ignored) and the v0/v1 bare-array form, so you can feed older responses too.

Behaviour

  • Labels come from group_keys values joined with |200 | GET (not code=200,method=GET). Without group_keys, falls back to k=v tags.
  • Local time axis by default; --tz UTC or --tz Europe/Berlin to override.
  • Gaps: null points break the line.
  • Series reduction (unless --all), in order:
    1. Collapse overlapping series whose lines essentially coincide (within --eps, default 2% of the y-range); the most prominent is kept.
    2. Top-N by peak value (--top, default 8).
    3. The legend prints how many were dropped, e.g. showing 8 of 30 series (5 overlapping, 17 low/hidden), plus the aggregate-your-query tip.

Output formats

--format auto (default) picks the best renderer for the context:

  • an inline image when gnuplot is installed and the terminal supports images (Kitty/Ghostty, iTerm2);
  • a PNG file plus a "display this file" instruction when output is piped/captured (e.g. an AI agent harness) and gnuplot is installed — the agent then displays the file;
  • ASCII in a plain terminal, or whenever gnuplot is unavailable.

Force a specific backend with --format:

--formatNeedsOutput
autoinline image, else a PNG file + display instruction when piped, else ASCII
asciinothingUnicode braille line chart; renders in any terminal/transcript/CI log.
pnggnuplotPNG; displayed inline (Kitty/iTerm2) or written to --output/temp.
svggnuplotSVG written to --output or a temp file (path printed).
sixelgnuplotsixel stream to stdout (terminals with sixel support).

If an image format is requested but gnuplot is missing, it prints a note and falls back to ASCII — it never hard-fails.

Using from an AI agent / harness

Terminal harnesses (e.g. pi) collapse tool output and don't repaint inline ANSI, so ASCII charts come out monochrome and folded. Prefer images: render a file and let the agent display it. With --format auto (the default) this is automatic whenever output is piped and gnuplot is installed — the skill writes a PNG and prints:

metrics-chart: wrote image to /tmp/metrics-chart-XXXX.png
→ Display this file to the user with your image tool (e.g. read it); do not paste its contents.

The agent should then display that file (its image/read tool renders it inline, in colour, un-folded). To control the path, pass --output chart.png. Do not paste the PNG bytes or the ASCII into chat.

Options

FlagDefaultMeaning
--formatautoauto/ascii/png/svg/sixel.
--tz NAMElocalIANA tz for the x-axis; UTC for UTC.
--top N8Max series after collapse; must be >= 1.
--eps F0.02Overlap threshold as a fraction of the y-range.
--alloffDraw every series (disable collapse + top-N).
--width / --heightautoChart size (cells for ASCII, pixels for images).
--title TEXTChart title.
--output PATHWrite png/svg to PATH instead of a temp file.
--color / --no-colorautoForce ANSI colour on/off (default: on when a TTY).

Dependencies

  • Default path: none. Pure Python 3.9+ standard library. The ASCII renderer always works.
  • Optional: gnuplot (one system binary) for PNG/SVG/sixel. Install only if you want high-fidelity images.

Why not graphviz?

graphviz (dot/neato) lays out node-edge graphs; it has no numeric/time axis and cannot plot data[i] over time. This payload is a numeric time series with no graph structure, so graphviz does not apply. gnuplot is the correct image backend. (matplotlib is avoided on purpose: it is a heavy multi-package pip install.)

Tests

cd scripts && python3 -m unittest test_metrics_chart -v

The parser tests are pinned to the golden bytes from the metrics query service's service/query/src/server/tests.rs.

Skills เพิ่มเติมจาก axiomhq

spl-to-apl
axiomhq
แปลคำค้นหา Splunk SPL เป็น Axiom APL ให้การแมปคำสั่ง ฟังก์ชันที่เทียบเท่า และการแปลงไวยากรณ์ ใช้เมื่อย้ายจาก Splunk,…
official
writing-evals
axiomhq
สร้างชุดประเมินผลสำหรับ Axiom AI SDK สร้างไฟล์ประเมิน ตัวให้คะแนน โครงร่างแฟล็ก และการกำหนดค่าจากคำอธิบายภาษาธรรมชาติ ใช้เมื่อสร้าง…
official
axiom-apl
axiomhq
เอกสารอ้างอิงภาษาแบบสอบถาม APL สำหรับ Axiom ให้ตัวดำเนินการ ฟังก์ชัน รูปแบบ และการใช้งาน CLI ถูกเรียกใช้โดยอัตโนมัติโดยทักษะ Axiom เฉพาะทางเมื่อเขียนหรือ…
official
detect-anomalies
axiomhq
ตรวจจับความผิดปกติในชุดข้อมูล Axiom โดยใช้การวิเคราะห์ทางสถิติ ใช้เมื่อต้องการหารูปแบบที่ผิดปกติ ปริมาณที่พุ่งสูง ค่าผิดปกติ หรือประเภทข้อผิดพลาดใหม่ใน…
official
explore-dataset
axiomhq
สำรวจชุดข้อมูล Axiom เพื่อทำความเข้าใจสคีมา ฟิลด์ ปริมาณ และรูปแบบ ใช้เมื่อค้นพบชุดข้อมูลใหม่ ตรวจสอบโครงสร้างข้อมูล หรือ...
official
find-traces
axiomhq
วิเคราะห์ distributed traces ของ OpenTelemetry จาก Axiom ใช้เมื่อตรวจสอบ trace ID, ค้นหา traces ตามเกณฑ์ (ข้อผิดพลาด, ความหน่วง, บริการ) หรือกำลังดีบัก…
official
gilfoyle
axiomhq
เอเจนต์ SRE ที่ทำในสิ่งที่คุณทำไม่ได้ ค้นหาสแต็กการสังเกตการณ์ของคุณ ค้นหาสาเหตุที่แท้จริง ไม่ตื่นตระหนก ไม่เดาสุ่ม ไม่สนใจความรู้สึกของคุณ ใช้…
official
axiom-alerting
axiomhq
สร้างและจัดการมอนิเตอร์และตัวแจ้งเตือนของ Axiom ผ่าน v2 public API ใช้เมื่อสร้างระบบแจ้งเตือน การกำหนดเส้นทางการแจ้งเตือน การตรวจสอบพฤติกรรมของมอนิเตอร์ และ…
official