← 返回
未分类 中文

VictoriaMetrics

Query and manage VictoriaMetrics time-series database instances. Supports both single-node and cluster deployments with multi-tenancy. Use when the user asks...
查询和管理VictoriaMetrics时序数据库实例,支持单节点与集群部署及多租户模式。
yangjinzhao yangjinzhao 来源
未分类 clawhub v1.1.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 570
下载
💾 1
安装
1
版本
#latest

概述

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:

cd ~/.openclaw/workspace/skills/victoriametrics
node scripts/cli.js init

This will create a victoriametrics.json config file in your OpenClaw workspace (~/.openclaw/workspace/victoriametrics.json).

2. Start Querying

# Query default instance
node scripts/cli.js query 'up'

# Query all instances at once
node scripts/cli.js query 'up' --all

# List configured instances
node scripts/cli.js instances

Configuration

Config File Location

By default, the skill looks for config in your OpenClaw workspace:

~/.openclaw/workspace/victoriametrics.json

Priority order:

  1. Path from VICTORIAMETRICS_CONFIG environment variable
  2. ~/.openclaw/workspace/victoriametrics.json
  3. ~/.openclaw/workspace/config/victoriametrics.json
  4. ./victoriametrics.json (current directory)
  5. ~/.config/victoriametrics/config.json

Config Format

Create victoriametrics.json in your workspace (or use node cli.js init):

Single-Node Deployment

{
  "instances": [
    {
      "name": "production",
      "type": "single",
      "url": "http://victoriametrics:8428",
      "user": "admin",
      "password": "secret"
    }
  ],
  "default": "production"
}

Cluster Deployment (Multi-Tenant)

{
  "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"
}

Fields:

  • name — unique identifier for the instance
  • type"single" or "cluster" (default: "single")
  • url — VictoriaMetrics server URL
  • Single-node: http://victoriametrics:8428
  • Cluster: http://vmselect:8481
  • accountID — tenant account ID (cluster only, default: 0)
  • projectID — tenant project ID (cluster only, optional)
  • user / password — optional HTTP Basic Auth credentials
  • default — which instance to use when none specified

Environment Variables (Legacy)

For single-instance setups, you can use environment variables:

export VICTORIAMETRICS_URL=http://victoriametrics:8428
export VICTORIAMETRICS_USER=admin
export VICTORIAMETRICS_PASSWORD=secret

Usage

Global Flags

FlagDescription
-------------------
-c, --config Path to config file
-i, --instance Target specific instance
-a, --allQuery all configured instances

Commands

Setup

# Interactive configuration wizard
node scripts/cli.js init

Query Metrics

cd ~/.openclaw/workspace/skills/victoriametrics

# Query default instance
node scripts/cli.js query 'up'

# Query specific instance
node scripts/cli.js query 'up' -i cluster-prod

# Query ALL instances at once
node scripts/cli.js query 'up' --all

# Custom config file
node scripts/cli.js query 'up' -c /path/to/config.json

Common Queries

Disk space usage:

node scripts/cli.js query '100 - (node_filesystem_avail_bytes / node_filesystem_size_bytes * 100)' --all

CPU usage:

node scripts/cli.js query '100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)' --all

Memory usage:

node scripts/cli.js query '(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100' --all

Load average:

node scripts/cli.js query 'node_load1' --all

GPU memory usage (NVIDIA):

node scripts/cli.js query 'nvidia_gpu_memory_used_bytes / nvidia_gpu_memory_total_bytes * 100' --all

GPU temperature:

node scripts/cli.js query 'nvidia_gpu_temperature_celsius' --all

List Configured Instances

node scripts/cli.js instances

Output:

{
  "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
    }
  ]
}

Other Commands

# List all metrics matching pattern
node scripts/cli.js metrics 'node_memory_*'

# Get label names
node scripts/cli.js labels --all

# Get values for a label
node scripts/cli.js label-values instance --all

# Find time series
node scripts/cli.js series '{__name__=~"node_cpu_.*", instance=~".*:9100"}' --all

# Get active alerts
node scripts/cli.js alerts --all

# Check instance health
node scripts/cli.js health -i cluster-prod

Multi-Instance Output Format

When using --all, results include data from all instances:

{
  "resultType": "vector",
  "results": [
    {
      "instance": "cluster-prod",
      "status": "success",
      "resultType": "vector",
      "result": [...]
    },
    {
      "instance": "single-dev",
      "status": "success",
      "resultType": "vector",
      "result": [...]
    }
  ]
}

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: http://:8428/api/v1/query
  • Suitable for ingestion rates < 1M data points per second
  • Can be set up in High Availability mode

Cluster

  • Horizontal scalability
  • URL format: http://:8481/select//prometheus/api/v1/query
  • 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 Typenode_exportercategraf
--------------------------------------
CPU Usage100 - avg(irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100cpu_usage_active{cpu="cpu-total"}
Memory Usage(1 - node_memory_MemAvailable_bytes/node_memory_MemTotal_bytes) * 100mem_used_percent
Disk Usage100 - (node_filesystem_avail_bytes/node_filesystem_size_bytes * 100)disk_used_percent
System Loadnode_load1system_load1

Universal Queries (Auto-detect)

# CPU usage (works with both node_exporter and categraf)
node scripts/cli.js query 'cpu_usage_active{cpu="cpu-total"} or (100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100))'

# Memory usage (works with both)
node scripts/cli.js query 'mem_used_percent or ((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100)'

# Disk usage (works with both)
node scripts/cli.js query 'disk_used_percent or (100 - (node_filesystem_avail_bytes / node_filesystem_size_bytes * 100))'

For complete query examples for all metric types, see references/common_queries.md.

Common Queries Reference

node_exporter Metrics

MetricPromQL Query
----------------------
Disk free %node_filesystem_avail_bytes / node_filesystem_size_bytes * 100
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 RXrate(node_network_receive_bytes_total[5m])
Network TXrate(node_network_transmit_bytes_total[5m])
Uptimenode_time_seconds - node_boot_time_seconds
Service upup

categraf Metrics

MetricPromQL Query
----------------------
CPU usage %cpu_usage_active{cpu="cpu-total"}
Memory used %mem_used_percent
Disk used %disk_used_percent
Network RXrate(net_bytes_recv[5m])
Network TXrate(net_bytes_sent[5m])
System load 1msystem_load1
System uptimesystem_uptime

GPU Metrics (DCGM)

MetricPromQL Query
----------------------
GPU memory used %DCGM_FI_DEV_FB_USED / (DCGM_FI_DEV_FB_FREE + DCGM_FI_DEV_FB_USED) * 100
GPU temperatureDCGM_FI_DEV_GPU_TEMP
GPU utilizationDCGM_FI_DEV_GPU_UTIL
GPU power usageDCGM_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.

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-03-30 23:37 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,710
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装后可防止您和您的用户受到提示注入、数据泄露及恶意行为的侵害。
★ 116 📥 31,012
it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 31,062