Victoriametrics Query 标志

Victoriametrics Query

组织
VictoriaMetrics
victoriametrics-query

Query VictoriaMetrics metrics via curl. Use when running PromQL/MetricsQL queries, discovering metrics/labels, checking alerts and rules, inspecting TSDB status, exporting raw data, checking metric usage statistics, or debugging relabeling/downsampling/retention configs. Triggers on: metric queries, PromQL, MetricsQL, label discovery, series exploration, cardinality checks, alert status, recording rules, active/top queries, export data, metric statistics, relabel debug, downsampling debug, retention debug, flags.

Add to TypingMind

概览

发布者VictoriaMetrics
代码仓库skills
技能名称victoriametrics-query
星标数
62
复刻数
9
附带文件
1
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 VictoriaMetrics 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Victoriametrics Query AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/VictoriaMetrics/skills/tree/main/plugins/query/skills/victoriametrics-query
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/VictoriaMetrics/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/plugins/query/skills/victoriametrics-query .claude/skills/victoriametrics-query
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Victoriametrics Query,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Victoriametrics Query。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Victoriametrics Query 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

VictoriaMetrics Metrics Query

Query VictoriaMetrics HTTP API directly via curl. Covers instant/range queries, label/series discovery, alerts, rules, instance diagnostics, raw data export, metric usage statistics, and config debugging tools.

Environment

bash
# $VM_METRICS_URL - base URL
#   cluster: export VM_METRICS_URL="https://vmselect.example.com/select/0/prometheus"
#   single: export VM_METRICS_URL="http://localhost:8428"
# $VM_CURL_CONFIG - curl config file with auth header (set for remote, unset for local)
#   Remote: export VM_CURL_CONFIG="$HOME/.config/victoriametrics/curl.conf"
#   Local:  leave unset (defaults to /dev/null - no auth)

Auth Pattern

All curl commands load auth from a curl config file - works for both remote and local:

bash
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s "$VM_METRICS_URL/api/v1/query?query=up" | jq .

When VM_CURL_CONFIG is unset, curl reads /dev/null and sends no auth header. When set, it must point to a mode-0600 curl config file containing header = "Authorization: Bearer <token>". Never print its contents.

Core Endpoints

Instant Query

bash
# Query at current time
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/query?query=up" | jq .

# Query at specific time
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/query?query=up&time=2026-03-07T09:00:00Z" | jq .

Parameters: query (required), time (optional, RFC3339 or Unix seconds), step, timeout

Range Query

bash
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/query_range?query=rate(http_requests_total[5m])&start=2026-03-07T00:00:00Z&end=2026-03-07T12:00:00Z&step=5m" | jq .

Parameters: query (required), start (required), end (optional), step (required). Times in RFC3339 or Unix seconds.

Labels Discovery

bash
# All label names
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/labels" | jq '.data[]'

# Label values (label_name is a PATH parameter)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/label/namespace/values" | jq '.data[]'

# Label values filtered by series matcher
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'match[]={job="kubelet"}' \
  "$VM_METRICS_URL/api/v1/label/namespace/values" | jq '.data[]'

Series Discovery

bash
# Find series matching selector
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'match[]={namespace="myapp"}' \
  "$VM_METRICS_URL/api/v1/series?limit=20" | jq '.data[].__name__'

Parameters: match[] (required), start, end, limit

Metric Metadata

bash
# Search by metric name keyword
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/metadata?metric=http_request&limit=10" | jq .

Parameters: metric (search keyword), limit.

Alerts and Rules

bash
# All firing/pending alerts
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/alerts" | jq '.data.alerts[]'

# All alerting and recording rules
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/rules" | jq '.data.groups[]'

Instance Diagnostics

bash
# TSDB cardinality stats
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/tsdb" | jq .

# Currently executing queries
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/active_queries" | jq .

# Most frequent/slowest queries
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/top_queries?topN=10" | jq .

# Version info
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/buildinfo" | jq .

Export Raw Data

bash
# Export raw samples as JSON lines (one JSON object per line)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'match[]=http_requests_total' \
  -d 'start=2026-03-07T00:00:00Z' -d 'end=2026-03-07T12:00:00Z' \
  "$VM_METRICS_URL/api/v1/export" | head -5

# Export with reduced memory usage (for large exports)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'match[]={namespace="myapp"}' \
  -d 'start=2026-03-07T00:00:00Z' -d 'end=2026-03-07T01:00:00Z' \
  -d 'reduce_mem_usage=1' \
  "$VM_METRICS_URL/api/v1/export" > export.jsonl

Parameters: match[] (required), start, end, reduce_mem_usage. Output is JSON lines (not wrapped in a standard API response).

Each line: {"metric":{"__name__":"...","label":"value"},"values":[...],"timestamps":[...]}

Also available: /api/v1/export/csv (CSV format), /api/v1/export/native (binary, for import via /api/v1/import/native).

Series Count

bash
# Total number of active time series
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/series/count" | jq .

Note: can be slow on large databases and may return slightly inflated values.

Metric Usage Statistics

bash
# Which metrics are being queried, and how often
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/metric_names_stats?limit=20" | jq .

# Metrics queried <= N times (find unused/rarely-used metrics)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/metric_names_stats?limit=50&le=1" | jq .

# Filter by metric name pattern
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/status/metric_names_stats?match_pattern=vm_&limit=20" | jq .

Parameters: limit (max results), le (max query count threshold — find metrics queried at most N times), match_pattern (metric name prefix filter).

Flags (Non-Default)

bash
# View non-default runtime flags (returns plain text, one flag per line — NOT JSON)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "${VM_METRICS_URL%%/select/*}/flags"

Root-level endpoint. Returns plain text (not JSON), one flag per line. Shows only flags that differ from defaults — useful for debugging configuration.

Query Tools

These are ROOT-level endpoints, NOT under /api/v1/. On cluster mode, strip the /select/0/prometheus prefix to get the base host.

bash
# Expand WITH expressions (returns text, not JSON)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "${VM_METRICS_URL%%/select/*}/expand-with-exprs?query=WITH(x=up)x"

# Prettify MetricsQL query (returns JSON)
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "${VM_METRICS_URL%%/select/*}/prettify-query?query=rate(x[5m])" | jq .

Note: ${VM_METRICS_URL%%/select/*} strips everything from /select onward, yielding the base host. On single-node (local), VM_METRICS_URL has no /select prefix so it returns the URL unchanged.

Config Debug Tools

Root-level endpoints for debugging relabeling, downsampling, and retention configurations. These accept POST with form data. Primarily used via VMUI but accessible via curl.

bash
# Debug metric relabeling rules — test how a metric is transformed
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  -d 'metric=foo{bar="baz"}' \
  -d 'relabel_config=- target_label: cluster
  replacement: dev' \
  "${VM_METRICS_URL%%/select/*}/metric-relabel-debug"

# Debug downsampling filters — test which downsampling rules match a metric
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  -d 'metric=foo{bar="baz"}' \
  -d 'downsampling_period=30d:5m,180d:1h' \
  "${VM_METRICS_URL%%/select/*}/downsampling-filters-debug"

# Debug retention filters — test which retention policy applies to a metric
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  -d 'metric=foo{bar="baz"}' \
  -d 'retention_period=2y,{env="dev"}:30d' \
  "${VM_METRICS_URL%%/select/*}/retention-filters-debug"

These return HTML by default. For programmatic use, the VMUI at ${VM_METRICS_URL%%/select/*}/vmui/#/relabeling provides an interactive interface.

Timestamp Format

All times accept RFC3339 (2026-03-07T09:00:00Z) or Unix seconds (1709769600). Default time for instant queries is "now". Default end for range queries is "now".

Response Parsing (jq)

bash
# Extract metric values from instant query
... | jq '.data.result[] | {metric: .metric.__name__, value: .value[1]}'

# Extract time series from range query
... | jq '.data.result[] | {metric: .metric, values: [.values[] | {time: .[0], value: .[1]}]}'

# List metric names from series response
... | jq '[.data[] | .__name__] | unique'

# Count alerts by state
... | jq '.data.alerts | group_by(.state) | map({state: .[0].state, count: length})'

# Top series by cardinality from tsdb status
... | jq '.data.seriesCountByMetricName[:10]'

Common Patterns

bash
# Check if a metric exists
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  "$VM_METRICS_URL/api/v1/query?query=count({__name__=~\"http_request.*\"})" | jq '.data.result[].value[1]'

# Get all namespaces with active pods
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'match[]={__name__="kube_pod_info"}' \
  "$VM_METRICS_URL/api/v1/label/namespace/values" | jq '.data[]'

# Rate of errors over last hour
curl -q --config "${VM_CURL_CONFIG:-/dev/null}" -s \
  --data-urlencode 'query=sum(rate(http_requests_total{code=~"5.."}[5m])) by (namespace)' \
  "$VM_METRICS_URL/api/v1/query" | jq '.data.result[] | {ns: .metric.namespace, rate: .value[1]}'

Environment Switching

bash
# Check current environment
echo "VM_METRICS_URL: $VM_METRICS_URL"
echo "VM_CURL_CONFIG: ${VM_CURL_CONFIG:-(unset - no auth)}"

Important Notes

  • POST endpoints accept application/x-www-form-urlencoded (use --data-urlencode for query params with special chars)
  • match[] parameter requires the [] suffix — match alone won't work
  • For metric metadata, raw API uses metric param
  • label_values uses a path parameter: /api/v1/label/{label_name}/values
  • expand-with-exprs, prettify-query, flags, metric-relabel-debug, downsampling-filters-debug, and retention-filters-debug are root-level paths, not under /api/v1/
  • Export endpoint (/api/v1/export) returns JSON lines (one object per line), not standard API response JSON
  • Debug endpoints (metric-relabel-debug, etc.) return HTML by default — best used via VMUI for interactive debugging
  • For full endpoint details, parameters, and response formats, see references/api-reference.md

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Victoriametrics Query AI 技能有什么作用?

Query VictoriaMetrics metrics via curl. Use when running PromQL/MetricsQL queries, discovering metrics/labels, checking alerts and rules, inspecting TSDB status, exporting raw data, checking metric usage statistics, or debugging relabeling/downsampling/retention configs. Triggers on: metric queries, PromQL, MetricsQL, label discovery, series exploration, cardinality checks, alert status, recording rules, active/top queries, export data, metric statistics, relabel debug, downsampling debug, retention debug, flags.

为什么在 TypingMind 中使用 Victoriametrics Query?

因为您只需安装一次,就能搭配任何模型使用。Victoriametrics Query 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Victoriametrics Query?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/VictoriaMetrics/skills/tree/main/plugins/query/skills/victoriametrics-query。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Victoriametrics Query?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Victoriametrics Query 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Victoriametrics Query 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Victoriametrics Query AI 技能免费吗?

是的。VictoriaMetrics 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇