VictoriaMetrics
Query and manage VictoriaMetrics time-series database instances. Supports both single-node and cluster deployments with multi-tenancy.
Security Notice
This skill requires the following permissions for legitimate functionality:
- - HTTP/HTTPS requests: Query VictoriaMetrics API endpoints
- File system access: Read configuration files (
victoriametrics.json) - Base64 encoding: HTTP Basic Authentication for secure API access
All network operations are user-initiated and only connect to user-configured VictoriaMetrics instances. No data is sent to external services.
Quick Start
1. Initial Setup
Run the interactive configuration wizard:
CODEBLOCK0
This will create a victoriametrics.json config file in your OpenClaw workspace (~/.openclaw/workspace/victoriametrics.json).
2. Start Querying
CODEBLOCK1
Configuration
Config File Location
By default, the skill looks for config in your OpenClaw workspace:
CODEBLOCK2
Priority order:
- 1. Path from
VICTORIAMETRICS_CONFIG environment variable - INLINECODE4
- INLINECODE5
- INLINECODE6 (current directory)
- INLINECODE7
Config Format
Create victoriametrics.json in your workspace (or use node cli.js init):
Single-Node Deployment
CODEBLOCK3
Cluster Deployment (Multi-Tenant)
CODEBLOCK4
Fields:
- -
name — unique identifier for the instance - INLINECODE11 —
"single" or "cluster" (default: "single") - INLINECODE15 — VictoriaMetrics server URL
- Single-node:
http://victoriametrics:8428
- Cluster:
http://vmselect:8481
- -
accountID — tenant account ID (cluster only, default: 0) - INLINECODE19 — tenant project ID (cluster only, optional)
- INLINECODE20 /
password — optional HTTP Basic Auth credentials - INLINECODE22 — which instance to use when none specified
Environment Variables (Legacy)
For single-instance setups, you can use environment variables:
CODEBLOCK5
Usage
Global Flags
| Flag | Description |
|---|
| INLINECODE23 | Path to config file |
| INLINECODE24 |
Target specific instance |
|
-a, --all | Query all configured instances |
Commands
Setup
CODEBLOCK6
Query Metrics
CODEBLOCK7
Common Queries
Disk space usage:
CODEBLOCK8
CPU usage:
CODEBLOCK9
Memory usage:
CODEBLOCK10
Load average:
CODEBLOCK11
GPU memory usage (NVIDIA):
CODEBLOCK12
GPU temperature:
CODEBLOCK13
List Configured Instances
CODEBLOCK14
Output:
CODEBLOCK15
Other Commands
CODEBLOCK16
Multi-Instance Output Format
When using --all, results include data from all instances:
CODEBLOCK17
Errors on individual instances don't fail the entire query — they appear with "status": "error" in the results array.
Deployment Types
Single-Node
- - Simpler setup and operation
- URL format: INLINECODE28
- Suitable for ingestion rates < 1M data points per second
- Can be set up in High Availability mode
Cluster
- - Horizontal scalability
- URL format: INLINECODE29
- Multi-tenancy support via accountID and projectID
- Components: vmstorage, vminsert, vmselect
- Each component scales independently
Supported Metric Collectors
This skill supports multiple metric collection agents:
- - node_exporter - Standard Prometheus node exporter
- categraf - Flashcat's telemetry collector
- DCGM - NVIDIA GPU metrics
- Custom exporters - Any Prometheus-compatible exporter
Quick Comparison
| Metric Type | node_exporter | categraf |
|---|
| CPU Usage | INLINECODE30 | INLINECODE31 |
| Memory Usage |
(1 - node_memory_MemAvailable_bytes/node_memory_MemTotal_bytes) * 100 |
mem_used_percent |
| Disk Usage |
100 - (node_filesystem_avail_bytes/node_filesystem_size_bytes * 100) |
disk_used_percent |
| System Load |
node_load1 |
system_load1 |
Universal Queries (Auto-detect)
CODEBLOCK18
For complete query examples for all metric types, see references/common_queries.md.
Common Queries Reference
node_exporter Metrics
| Metric | PromQL Query |
|---|
| Disk free % | INLINECODE38 |
| Disk used % |
100 - (node_filesystem_avail_bytes / node_filesystem_size_bytes * 100) |
| CPU idle % |
avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100 |
| Memory used % |
(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100 |
| Network RX |
rate(node_network_receive_bytes_total[5m]) |
| Network TX |
rate(node_network_transmit_bytes_total[5m]) |
| Uptime |
node_time_seconds - node_boot_time_seconds |
| Service up |
up |
categraf Metrics
| Metric | PromQL Query |
|---|
| CPU usage % | INLINECODE46 |
| Memory used % |
mem_used_percent |
| Disk used % |
disk_used_percent |
| Network RX |
rate(net_bytes_recv[5m]) |
| Network TX |
rate(net_bytes_sent[5m]) |
| System load 1m |
system_load1 |
| System uptime |
system_uptime |
GPU Metrics (DCGM)
| Metric | PromQL Query |
|---|
| GPU memory used % | INLINECODE53 |
| GPU temperature |
DCGM_FI_DEV_GPU_TEMP |
| GPU utilization |
DCGM_FI_DEV_GPU_UTIL |
| GPU power usage |
DCGM_FI_DEV_POWER_USAGE |
Notes
- - Time range defaults to last 1 hour for instant queries
- Use range queries
[5m] for rate calculations - All queries return JSON with
data.result containing the results - Instance labels typically show
host:port format - When using
--all, queries run in parallel for faster results - Config is stored outside the skill directory so it persists across skill updates
- For cluster deployments, the accountID and projectID are automatically inserted into the URL path
VictoriaMetrics API Differences
VictoriaMetrics is compatible with Prometheus API but includes additional features:
- - MetricsQL: Extended PromQL with additional functions
- Multi-tenancy: Native support in cluster mode
- High cardinality: Better performance with many time series
- Storage efficiency: Better compression than Prometheus
For detailed API documentation, see references/api_reference.md.
VictoriaMetrics
查询和管理VictoriaMetrics时序数据库实例。支持单节点和集群部署,并具备多租户功能。
安全须知
本技能需要以下权限以实现合法功能:
- - HTTP/HTTPS请求:查询VictoriaMetrics API端点
- 文件系统访问:读取配置文件(victoriametrics.json)
- Base64编码:用于安全API访问的HTTP基本认证
所有网络操作均由用户发起,且仅连接用户配置的VictoriaMetrics实例。不会向外部服务发送任何数据。
快速开始
1. 初始设置
运行交互式配置向导:
bash
cd ~/.openclaw/workspace/skills/victoriametrics
node scripts/cli.js init
这将在你的OpenClaw工作区(~/.openclaw/workspace/victoriametrics.json)中创建一个victoriametrics.json配置文件。
2. 开始查询
bash
查询默认实例
node scripts/cli.js query up
同时查询所有实例
node scripts/cli.js query up --all
列出已配置的实例
node scripts/cli.js instances
配置
配置文件位置
默认情况下,技能会在你的OpenClaw工作区中查找配置:
~/.openclaw/workspace/victoriametrics.json
优先级顺序:
- 1. VICTORIAMETRICS_CONFIG环境变量指定的路径
- ~/.openclaw/workspace/victoriametrics.json
- ~/.openclaw/workspace/config/victoriametrics.json
- ./victoriametrics.json(当前目录)
- ~/.config/victoriametrics/config.json
配置格式
在工作区中创建victoriametrics.json(或使用node cli.js init):
单节点部署
json
{
instances: [
{
name: production,
type: single,
url: http://victoriametrics:8428,
user: admin,
password: secret
}
],
default: production
}
集群部署(多租户)
json
{
instances: [
{
name: cluster-prod,
type: cluster,
url: http://vmselect:8481,
accountID: 0,
user: admin,
password: secret
},
{
name: cluster-tenant42,
type: cluster,
url: http://vmselect:8481,
accountID: 42,
projectID: 9
}
],
default: cluster-prod
}
字段说明:
- - name — 实例的唯一标识符
- type — single或cluster(默认:single)
- url — VictoriaMetrics服务器URL
- 单节点:http://victoriametrics:8428
- 集群:http://vmselect:8481
- - accountID — 租户账户ID(仅集群,默认:0)
- projectID — 租户项目ID(仅集群,可选)
- user / password — 可选的HTTP基本认证凭据
- default — 未指定时使用的默认实例
环境变量(旧版)
对于单实例设置,可以使用环境变量:
bash
export VICTORIAMETRICS_URL=http://victoriametrics:8428
export VICTORIAMETRICS_USER=admin
export VICTORIAMETRICS_PASSWORD=secret
用法
全局标志
| 标志 | 描述 |
|---|
| -c, --config <路径> | 配置文件路径 |
| -i, --instance <名称> |
指定目标实例 |
| -a, --all | 查询所有已配置的实例 |
命令
设置
bash
交互式配置向导
node scripts/cli.js init
查询指标
bash
cd ~/.openclaw/workspace/skills/victoriametrics
查询默认实例
node scripts/cli.js query up
查询特定实例
node scripts/cli.js query up -i cluster-prod
同时查询所有实例
node scripts/cli.js query up --all
自定义配置文件
node scripts/cli.js query up -c /path/to/config.json
常用查询
磁盘空间使用率:
bash
node scripts/cli.js query 100 - (nodefilesystemavailbytes / nodefilesystemsizebytes * 100) --all
CPU使用率:
bash
node scripts/cli.js query 100 - (avg by (instance) (irate(nodecpuseconds_total{mode=idle}[5m])) * 100) --all
内存使用率:
bash
node scripts/cli.js query (nodememoryMemTotalbytes - nodememoryMemAvailablebytes) / nodememoryMemTotal_bytes * 100 --all
平均负载:
bash
node scripts/cli.js query node_load1 --all
GPU内存使用率(NVIDIA):
bash
node scripts/cli.js query nvidiagpumemoryusedbytes / nvidiagpumemorytotalbytes * 100 --all
GPU温度:
bash
node scripts/cli.js query nvidiagputemperature_celsius --all
列出已配置的实例
bash
node scripts/cli.js instances
输出:
json
{
default: cluster-prod,
instances: [
{
name: cluster-prod,
type: cluster,
url: http://vmselect:8481,
accountID: 0,
hasAuth: true
},
{
name: single-dev,
type: single,
url: http://localhost:8428,
hasAuth: false
}
]
}
其他命令
bash
列出匹配模式的所有指标
node scripts/cli.js metrics node
memory*
获取标签名称
node scripts/cli.js labels --all
获取标签的值
node scripts/cli.js label-values instance --all
查找时间序列
node scripts/cli.js series {
name=~node
cpu.
, instance=~.:9100} --all
获取活跃告警
node scripts/cli.js alerts --all
检查实例健康状态
node scripts/cli.js health -i cluster-prod
多实例输出格式
使用--all时,结果包含所有实例的数据:
json
{
resultType: vector,
results: [
{
instance: cluster-prod,
status: success,
resultType: vector,
result: [...]
},
{
instance: single-dev,
status: success,
resultType: vector,
result: [...]
}
]
}
单个实例的错误不会导致整个查询失败——它们会在结果数组中显示为status: error。
部署类型
单节点
- - 设置和操作更简单
- URL格式:http://:8428/api/v1/query
- 适用于每秒少于100万个数据点的采集速率
- 可设置为高可用模式
集群
- - 水平可扩展性
- URL格式:http://:8481/select//prometheus/api/v1/query
- 通过accountID和projectID支持多租户
- 组件:vmstorage、vminsert、vmselect
- 每个组件可独立扩展
支持的指标采集器
本技能支持多种指标采集代理:
- - node_exporter - 标准Prometheus节点导出器
- categraf - Flashcat的遥测采集器
- DCGM - NVIDIA GPU指标
- 自定义导出器 - 任何兼容Prometheus的导出器
快速对比
| 指标类型 | nodeexporter | categraf |
|---|
| CPU使用率 | 100 - avg(irate(nodecpusecondstotal{mode=idle}[5m])) 100 | cpuusageactive{cpu=cpu-total} |
| 内存使用率 |
(1 - node
memoryMemAvailable
bytes/nodememory
MemTotalbytes) 100 | mem
usedpercent |
| 磁盘使用率 | 100 - (node_filesystem