Logo Hotpath Init Grafana

Hotpath Init Grafana

Cộng đồngPhổ biến
pawurb
hotpath_init_grafana

Build a Grafana dashboard JSON for a Rust project profiled with hotpath. Writes the dashboard file with context-aware panels (SQL and HTTP time per route, N+1 detection, memory and time per request, channel queues, lock contention, Tokio workers, per-thread CPU and allocations, profiling overhead) limited to what the project instruments. Only builds the dashboard, does not configure Prometheus, Grafana or the hotpath metrics endpoint. Use when the user wants a Grafana dashboard for hotpath metrics.

Tổng quan

Nhà phát hànhpawurb
Kho mãhotpath-rs
Tên kỹ nănghotpath_init_grafana
Sao
1.9K
Bản fork
61
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được pawurb công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hotpath Init Grafana trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/pawurb/hotpath-rs/tree/main/skills/hotpath_init_grafana
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/pawurb/hotpath-rs.git /tmp/hotpath-rs
mkdir -p .claude/skills
cp -r /tmp/hotpath-rs/skills/hotpath_init_grafana .claude/skills/hotpath_init_grafana
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Hotpath Init Grafana trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Hotpath Init Grafana ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Hotpath Init Grafana với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Initialize a hotpath Grafana dashboard

Build a Grafana dashboard on top of the metrics that hotpath exposes through its Prometheus endpoint. The dashboard is organized in performance layers: SQL queries and outbound HTTP calls attributed to the axum route that issued them, memory and time per request, then channels, locks, the Tokio runtime and threads. Each panel answers a concrete question instead of plotting raw series.

Scope

This skill only builds the dashboard JSON file. It does not configure Prometheus, Grafana or the app's metrics endpoint: no scrape jobs, data sources, auth tokens, Grafana API imports or Prometheus restarts. Those setups differ between projects (local, docker-compose, Kubernetes, Grafana Cloud, ...) and are owned by whoever runs the infrastructure, so the skill assumes they are already in place:

  • the app runs with the hotpath-prometheus feature and exposes /metrics;
  • Prometheus scrapes it with native histograms enabled;
  • Grafana has that Prometheus as a data source.

If any of these is missing, point the user to https://hotpath.rs/prometheus_grafana and continue with the dashboard; do not edit Prometheus or Grafana config, and do not change Cargo.toml features or deployment env vars.

Documentation

The hotpath docs are the reference for every metric, label and environment variable; this skill holds the procedure and the dashboard queries, which the docs do not have. Every page of https://hotpath.rs is served as markdown when requested with an Accept: text/markdown header:

bash
curl -sL -H 'Accept: text/markdown' https://hotpath.rs/prometheus_grafana

Fetch https://hotpath.rs/prometheus_grafana before building the dashboard, and check every metric and label name a panel uses against its "Available metrics" tables instead of relying on memory. Keep -L (some pages redirect) and the header (there are no .md URLs). A #fragment is not sent to the server: fetch the whole page and find the heading.

The site documents the latest hotpath release, which can be newer than the version the project uses. Never change the project's hotpath version because the docs show a newer one. If the docs describe something that version does not have, tell the user it needs a newer hotpath instead of working around it.

PageCovers
https://hotpath.rs/prometheus_grafanametrics endpoint, scrape config, native and classic histogram queries, time sampling, every metric family with its labels, exporter environment variables
https://hotpath.rs/axum_tracingroute scoping, behind every per-route panel
https://hotpath.rs/profiling_overheadtime sampling, behind the profiling overhead panel
https://hotpath.rs/tokio_runtimeTokio metrics and which need tokio_unstable

Steps

1. Inspect the project

  • Check whether hotpath is already set up: a hotpath dependency, #[hotpath::main] (or HotpathGuardBuilder) and instrumented code. If it is not, stop and tell the user to set up profiling first with hotpath init (https://hotpath.rs/); do not instrument the project as part of this skill.
  • Record which subsystems the project instruments. They decide which dashboard rows to build:
Instrumentation in the codeDashboard row
hotpath::axum!(router) or .layer(hotpath::AxumLayer::new())Routes, and every per-route panel
sqlx / diesel / toasty SQL layerSQL
hotpath::http!(client)Outbound HTTP
hotpath-alloc featureMemory
#[hotpath::measure] / #[hotpath::measure_all] / hotpath::measure_block!Functions, profiling overhead
hotpath::channel!Channels
hotpath::rw_lock! / hotpath::mutex!Locks
hotpath::tokio_runtime!()Tokio runtime
threads feature (on by default)Threads
  • Skip any row whose instrumentation is missing; an empty panel is noise. Mention the skipped rows to the user with the macro that would enable them, but do not add instrumentation unless they ask.

2. Check the emitted metrics (optional)

If the app's metrics endpoint is already reachable (default http://127.0.0.1:6772/metrics), list the metric families it emits to confirm step 1. Families with no data are omitted from the scrape:

bash
curl -s http://127.0.0.1:6772/metrics | grep -v '^#' | cut -d'{' -f1 | sort -u

Do not start the app or change its configuration for this; when the endpoint is not reachable, rely on the code inspection alone.

Every query below assumes native histograms: histogram_sum(), histogram_count() and histogram_quantile() on the bare metric name. If the user says their Prometheus stores classic histograms, rewrite every histogram query to the classic form, as "Classic histogram queries" in https://hotpath.rs/prometheus_grafana shows.

3. Build the dashboard

Write the dashboard as Grafana JSON to grafana/hotpath-dashboard.json (or next to the project's existing dashboards). Requirements:

  • A datasource template variable of type prometheus, used by every panel and every query variable, so the file imports into any Grafana.
  • A route query variable, label_values(hotpath_server_requests_total, route), multi-value with an "All" option (.*), only when the routes row exists.
  • Textbox variables overhead_ns (default 50), threshold (default 1) and min_share (default 1) for the profiling overhead panel.
  • One collapsible row per layer from step 1, in the order below.
  • Ranking panels ("top 10 ...") use instant queries over $__range, rendered as horizontal bar gauges, with the legend set to the grouping label (e.g. {{query}}, {{route}}). Set the unit per panel: percent, s, bytes, short.
  • Long label values (SQL text, function paths) need a wide panel and value truncation off, or a table panel.
SQL

Share of total SQL time per query:

promql
sort_desc(topk(10,
  100 * sum by (query) (histogram_sum(increase(hotpath_sql_duration_seconds[$__range])))
  / on() group_left()
  sum(histogram_sum(increase(hotpath_sql_duration_seconds[$__range])))
))

Slow queries, p95 above 500ms:

promql
sort_desc(histogram_quantile(0.95, sum by (query) (increase(hotpath_sql_duration_seconds[$__range]))) > 0.500)
Routes (axum)

Share of total response time per route:

promql
sort_desc(topk(10,
  100 * sum by (route) (histogram_sum(increase(hotpath_server_duration_seconds[$__range])))
  / on() group_left()
  sum(histogram_sum(increase(hotpath_server_duration_seconds[$__range])))
))

Slowest routes by p95:

promql
sort_desc(topk(10, histogram_quantile(0.95, sum by (route) (increase(hotpath_server_duration_seconds[$__range])))))

SQL time per request, by query, for the selected $route (only with the SQL row):

promql
sort_desc(topk(10,
  sum by (query) (histogram_sum(increase(hotpath_sql_duration_seconds{route=~"$route"}[$__range])))
  / scalar(sum(increase(hotpath_server_scoped_requests_total{route=~"$route"}[$__range])))
))

SQL queries per request, the N+1 detector (only with the SQL row):

promql
sort_desc(topk(10,
  sum by (route) (increase(hotpath_server_sql_calls_total[$__range]))
  / (sum by (route) (increase(hotpath_server_scoped_requests_total[$__range])) > 0)
))
Outbound HTTP

HTTP calls per request (needs the routes row):

promql
sort_desc(topk(10,
  (sum by (route) (increase(hotpath_server_http_calls_total[$__range])) > 0)
  / (sum by (route) (increase(hotpath_server_scoped_requests_total[$__range])) > 0)
))

HTTP time per request; route!="" drops calls made outside a request, e.g. background jobs:

promql
sort_desc(topk(10,
  sum by (route) (histogram_sum(increase(hotpath_http_duration_seconds{route!=""}[$__range])))
  / (sum by (route) (increase(hotpath_server_scoped_requests_total[$__range])) > 0)
))

Without axum, rank endpoints by total time instead: sort_desc(topk(10, sum by (endpoint) (histogram_sum(increase(hotpath_http_duration_seconds[$__range]))))).

Memory (hotpath-alloc)

Bytes allocated per request, by route:

promql
sort_desc(topk(10,
  sum by (route) (increase(hotpath_server_alloc_bytes_total[$__range]))
  / (sum by (route) (increase(hotpath_server_scoped_requests_total[$__range])) > 0)
))

Bytes allocated per request, by function, for the selected $route. Allocations are exclusive by default: each function reports only what it allocates itself.

promql
sort_desc(topk(10,
  sum by (function) (increase(hotpath_function_route_alloc_bytes_total{route=~"$route"}[$__range]))
  / scalar(sum(increase(hotpath_server_scoped_requests_total{route=~"$route"}[$__range])))
))

Without axum, use sort_desc(topk(10, sum by (function) (increase(hotpath_function_alloc_bytes_total[$__range])))).

Functions

Time per request, by function, for the selected $route. Dividing by timed calls and multiplying by calls keeps it correct under time sampling. The time is inclusive of nested instrumented calls.

promql
sort_desc(topk(10,
  sum by (function) (increase(hotpath_function_route_duration_seconds_total{route=~"$route"}[$__range]))
  / (sum by (function) (increase(hotpath_function_route_timed_calls_total{route=~"$route"}[$__range])) > 0)
  * sum by (function) (increase(hotpath_function_route_calls_total{route=~"$route"}[$__range]))
  / scalar(sum(increase(hotpath_server_scoped_requests_total{route=~"$route"}[$__range])))
))

Without axum, share of total instrumented time per function:

promql
sort_desc(topk(10,
  100 * sum by (function) (histogram_sum(increase(hotpath_function_duration_seconds[$__range])))
  / on() group_left()
  sum(histogram_sum(increase(hotpath_function_duration_seconds[$__range])))
))
Channels

Every channel query groups by source, label, iter and payload, the labels that identify one channel: label is empty for channels created without one, so grouping by it alone would merge unrelated call sites, and a generic helper can create channels of several payload types at one call site. Use {{label}} {{source}} {{payload}} as the legend.

Max queue size since start; the capacity is in the type label. A queue at capacity means consumers are not keeping up.

promql
sort_desc(topk(10, max by (source, label, iter, type, payload) (hotpath_channel_max_queue_size)))

Throughput, messages received per second:

promql
sort_desc(topk(10, sum by (source, label, iter, type, payload) (rate(hotpath_channel_received_total[$__range]))))

p95 send-to-receive latency:

promql
sort_desc(topk(10, histogram_quantile(0.95, sum by (source, label, iter, type, payload) (increase(hotpath_channel_delay_seconds[$__range])))))
Locks

p95 wait time (contention) and p95 hold time per RwLock and side, grouped by the call-site labels like the channels (legend {{label}} {{source}} {{op}}):

promql
sort_desc(topk(10, histogram_quantile(0.95, sum by (source, label, iter, op) (increase(hotpath_rwlock_wait_seconds[$__range])))))
sort_desc(topk(10, histogram_quantile(0.95, sum by (source, label, iter, op) (increase(hotpath_rwlock_acquire_seconds[$__range])))))

For mutexes use hotpath_mutex_wait_seconds and hotpath_mutex_acquire_seconds, grouped by (source, label, iter).

Tokio runtime

One table panel with one instant query per column, each in table format grouped by worker, merged with the "Merge" transformation:

promql
sum by (worker) (increase(hotpath_tokio_worker_parks_total[$__range]))
sum by (worker) (increase(hotpath_tokio_worker_polls_total[$__range]))
sum by (worker) (increase(hotpath_tokio_worker_steals_total[$__range]))
sum by (worker) (increase(hotpath_tokio_worker_busy_seconds_total[$__range]))
100 * sum by (worker) (rate(hotpath_tokio_worker_busy_seconds_total[$__range]))
sum by (worker) (hotpath_tokio_worker_local_queue_depth)
sum by (worker) (increase(hotpath_tokio_worker_busy_seconds_total[$__range]))
  / (sum by (worker) (increase(hotpath_tokio_worker_polls_total[$__range])) > 0)

Columns: Parks, Polls, Steals, Busy, Busy %, Local queue, Mean poll. Some of these need RUSTFLAGS="--cfg tokio_unstable"; tell the user if the family is missing from the scrape.

Threads

Peak CPU per thread, and total bytes allocated per thread (hotpath-alloc):

promql
sort_desc(topk(10, hotpath_thread_cpu_percent_max))
sort_desc(topk(10, hotpath_thread_alloc_bytes_total))

Retained bytes per thread (allocated minus deallocated since start), as a time series; a line that keeps rising under steady load points to a thread holding memory:

promql
hotpath_thread_alloc_bytes_total - hotpath_thread_dealloc_bytes_total

Memory freed on another thread than the one that allocated it (e.g. buffers handed through a channel) makes one thread drift up and the other down, so read a rising line together with the process-level hotpath_alloc_bytes_total - hotpath_dealloc_bytes_total.

Legend {{name}}. Unnamed threads show up as thread_N; suggest std::thread::Builder::name for the important ones.

Profiling overhead

Functions where the per-call profiling cost ($overhead_ns) exceeds $threshold percent of the average call, limited to functions above $min_share percent of total instrumented time. An empty panel is the good outcome.

promql
sort_desc(
  (
    100 * ($overhead_ns * 1e-9) / (
      sum by (function) (histogram_sum(increase(hotpath_function_duration_seconds[$__range])))
      / (sum by (function) (histogram_count(increase(hotpath_function_duration_seconds[$__range]))) > 0)
    )
    > $threshold
  )
  and on (function)
  (
    100 * sum by (function) (histogram_sum(increase(hotpath_function_duration_seconds[$__range])))
    / scalar(sum(histogram_sum(increase(hotpath_function_duration_seconds[$__range]))))
    > $min_share
  )
)

Functions listed here are candidates for removing #[hotpath::measure] or enabling time sampling (https://hotpath.rs/profiling_overhead).

4. Validate the dashboard

Check the file is valid JSON with jq . grafana/hotpath-dashboard.json. If the user gives a Prometheus URL that already scrapes the app, run each panel query through its HTTP API, read-only, with $__range replaced by a concrete window (e.g. 1h) and the variables by their defaults, and fix any query that returns an error:

bash
curl -sG http://127.0.0.1:9090/api/v1/query --data-urlencode 'query=<promql>'

An empty result is fine when the app has not served that kind of traffic yet; a "status":"error" is not.

5. Summarize

Tell the user:

  • where the dashboard file is, and that they import it themselves (Grafana UI: Dashboards, New, Import) or through their own provisioning;
  • which rows the dashboard contains, and which were skipped with the instrumentation that would enable them;
  • how to read the first panels to look at: SQL queries per request above ~5 is an N+1 candidate, a channel at max capacity is a bottleneck, a non-empty profiling overhead panel means some instrumentation costs more than it is worth.

Câu hỏi thường gặp

Kỹ năng AI Hotpath Init Grafana làm được gì?

Build a Grafana dashboard JSON for a Rust project profiled with hotpath. Writes the dashboard file with context-aware panels (SQL and HTTP time per route, N+1 detection, memory and time per request, channel queues, lock contention, Tokio workers, per-thread CPU and allocations, profiling overhead) limited to what the project instruments. Only builds the dashboard, does not configure Prometheus, Grafana or the hotpath metrics endpoint. Use when the user wants a Grafana dashboard for hotpath metrics.

Vì sao nên dùng Hotpath Init Grafana trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hotpath Init Grafana là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hotpath Init Grafana trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/pawurb/hotpath-rs/tree/main/skills/hotpath_init_grafana. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hotpath Init Grafana?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Hotpath Init Grafana với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hotpath Init Grafana với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hotpath Init Grafana có miễn phí không?

Có. Kỹ năng này được pawurb phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇