VA

vastai-observability

Implement comprehensive observability for Vast.ai to track GPU health, utilization, and costs.

Install

mkdir -p .claude/skills/vastai-observability && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2394" && unzip -o skill.zip -d .claude/skills/vastai-observability && rm skill.zip

Installs to .claude/skills/vastai-observability

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Monitor Vast.ai GPU instance health, utilization, and costs.
60 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Collect Vast.ai instance metrics like GPU utilization and cost
  • Generate alerts for idle GPUs and high temperatures
  • Project daily cost based on running instances
  • Monitor remote GPU metrics via SSH and `nvidia-smi`
  • Export metrics to Prometheus for dashboarding

How it works

The skill collects Vast.ai instance data using the `vastai` CLI, processes it with Python to extract metrics, and generates alerts based on predefined thresholds. It can also export these metrics for visualization tools.

Inputs & outputs

You give it
Vast.ai instance data, GPU utilization, temperature, hourly cost
You get back
Metrics collector with JSONL output, alert conditions, remote GPU monitoring, optional Prometheus exporter

When to use vastai-observability

  • Set up custom monitoring dashboards
  • Configure alerts for GPU preemption
  • Track real-time hourly spend per instance
  • Monitor GPU utilization to identify wasted compute

About this skill

Vast.ai Observability

Overview

Monitor Vast.ai GPU instance health, utilization, and costs. Key metrics: GPU utilization (idle GPUs waste $0.20-$4.00/hr), instance uptime, training progress, cost accumulation, and spot preemption events.

Prerequisites

  • Vast.ai account with active instances
  • vastai CLI installed
  • Optional: Prometheus, Grafana, or Datadog for dashboarding

Instructions

Step 1: Instance Metrics Collector

import subprocess, json, time
from datetime import datetime

class VastMetricsCollector:
    def __init__(self, output_file="vast_metrics.jsonl"):
        self.output_file = output_file

    def collect(self):
        result = subprocess.run(
            ["vastai", "show", "instances", "--raw"],
            capture_output=True, text=True)
        instances = json.loads(result.stdout)

        metrics = {
            "timestamp": datetime.utcnow().isoformat(),
            "total_instances": len(instances),
            "running": 0, "total_hourly_cost": 0,
            "instances": [],
        }

        for inst in instances:
            status = inst.get("actual_status", "unknown")
            dph = inst.get("dph_total", 0)
            if status == "running":
                metrics["running"] += 1
                metrics["total_hourly_cost"] += dph

            metrics["instances"].append({
                "id": inst["id"],
                "gpu": inst.get("gpu_name"),
                "status": status,
                "dph": dph,
                "gpu_util": inst.get("gpu_util", 0),
                "gpu_temp": inst.get("gpu_temp", 0),
            })

        with open(self.output_file, "a") as f:
            f.write(json.dumps(metrics) + "\n")

        return metrics

    def run(self, interval=60):
        while True:
            m = self.collect()
            print(f"[{m['timestamp']}] Running: {m['running']} | "
                  f"Cost: ${m['total_hourly_cost']:.3f}/hr")
            time.sleep(interval)

Step 2: Alert Conditions

def check_alerts(metrics):
    alerts = []

    # Idle GPU alert (running but <10% utilization)
    for inst in metrics["instances"]:
        if inst["status"] == "running" and inst["gpu_util"] < 10:
            alerts.append(f"IDLE: Instance {inst['id']} GPU util={inst['gpu_util']}% "
                         f"(wasting ${inst['dph']:.3f}/hr)")

    # High temperature alert
    for inst in metrics["instances"]:
        if inst.get("gpu_temp", 0) > 85:
            alerts.append(f"HOT: Instance {inst['id']} GPU temp={inst['gpu_temp']}C")

    # Budget alert
    daily_projection = metrics["total_hourly_cost"] * 24
    if daily_projection > 100:
        alerts.append(f"BUDGET: Projected daily cost ${daily_projection:.2f}")

    return alerts

Step 3: Remote GPU Monitoring

# SSH into instance and collect nvidia-smi metrics
ssh -p $PORT root@$HOST "nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total,temperature.gpu,power.draw --format=csv,noheader,nounits"
# Output: 95, 20480, 24576, 72, 285

Step 4: Prometheus Exporter (Optional)

from prometheus_client import Gauge, start_http_server

gpu_util = Gauge("vastai_gpu_utilization", "GPU utilization %", ["instance_id", "gpu_name"])
hourly_cost = Gauge("vastai_hourly_cost", "Total hourly cost USD")
instance_count = Gauge("vastai_instance_count", "Running instances")

def export_metrics(metrics):
    instance_count.set(metrics["running"])
    hourly_cost.set(metrics["total_hourly_cost"])
    for inst in metrics["instances"]:
        if inst["status"] == "running":
            gpu_util.labels(inst["id"], inst["gpu"]).set(inst["gpu_util"])

start_http_server(9090)  # Prometheus scrape target

Output

  • Metrics collector with JSONL output
  • Alert conditions (idle GPU, high temp, budget)
  • Remote GPU monitoring via SSH + nvidia-smi
  • Optional Prometheus exporter for Grafana dashboards

Error Handling

AlertThresholdResponse
Idle GPUutil < 10% for > 10 minInvestigate or destroy instance
High temp> 85C sustainedReduce workload or report to host
Budget exceededProjected daily > $100Destroy non-critical instances
Instance offlineStatus changed from runningTrigger auto-recovery

Resources

Next Steps

For incident response procedures, see vastai-incident-runbook.

Examples

Quick dashboard: Run VastMetricsCollector().run(interval=30) in tmux on a monitoring server. Pipe alerts to Slack via webhook.

Cost tracking: Parse vast_metrics.jsonl to plot hourly cost over time and identify spending patterns.

When not to use it

  • When an instance is offline and status changed from running

Prerequisites

Vast.ai account with active instancesvastai CLI installed

Limitations

  • Idle GPU alert triggers if utilization is less than 10% for more than 10 minutes
  • High temperature alert triggers if GPU temperature exceeds 85C
  • Budget alert triggers if projected daily cost exceeds $100

How it compares

This skill provides automated monitoring and alerting for Vast.ai GPU instances, offering real-time insights into utilization and costs, unlike manual checks that can miss critical events.

Compared to similar skills

vastai-observability side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
vastai-observability (this skill)127dReviewIntermediate
distributed-tracing52moNo flagsIntermediate
service-mesh-observability52moNo flagsAdvanced
observability-engineer124moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

distributed-tracing

wshobson

Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.

577

service-mesh-observability

wshobson

Implement comprehensive observability for service meshes including distributed tracing, metrics, and visualization. Use when setting up mesh monitoring, debugging latency issues, or implementing SLOs for service communication.

574

observability-engineer

sickn33

Build production-ready monitoring, logging, and tracing systems. Implements comprehensive observability strategies, SLI/SLO management, and incident response workflows. Use PROACTIVELY for monitoring infrastructure, performance optimization, or production reliability.

1242

prometheus-configuration

wshobson

Set up Prometheus for comprehensive metric collection, storage, and monitoring of infrastructure and applications. Use when implementing metrics collection, setting up monitoring infrastructure, or configuring alerting systems.

645

langfuse

davila7

Expert in Langfuse - the open-source LLM observability platform. Covers tracing, prompt management, evaluation, datasets, and integration with LangChain, LlamaIndex, and OpenAI. Essential for debugging, monitoring, and improving LLM applications in production. Use when: langfuse, llm observability, llm tracing, prompt management, llm evaluation.

743

slo-implementation

wshobson

Define and implement Service Level Indicators (SLIs) and Service Level Objectives (SLOs) with error budgets and alerting. Use when establishing reliability targets, implementing SRE practices, or measuring service performance.

338

Search skills

Search the agent skills registry