Initial metrics skill with aggregation

This commit is contained in:
Azat
2026-02-02 22:29:24 +01:00
commit 09fe677f36
3 changed files with 304 additions and 0 deletions

73
SKILL.md Normal file
View File

@@ -0,0 +1,73 @@
---
name: metrics
description: Metrics aggregator with system and skill metrics
metadata:
version: "1.0.0"
vibestack:
main: false
metrics-port: 9090
---
# Metrics Skill
Aggregates metrics from system (node_exporter) and other skills into a single `/metrics` endpoint.
## Features
- System metrics via node_exporter (CPU, memory, disk, network)
- Auto-discovers skills that expose metrics
- Single aggregated endpoint for Prometheus scraping
- Auto-registers with Caddy if present
## How Skills Expose Metrics
Skills can expose metrics by adding to their SKILL.md:
```yaml
metadata:
vibestack:
metrics-port: 8080
```
Or by setting environment variable:
```bash
METRICS_PORT_myskill=8080
```
The aggregator will scrape `localhost:{port}/metrics` for each discovered skill.
## Configuration
| Variable | Description | Default |
|----------|-------------|---------|
| `METRICS_PORT` | Aggregator port | `9090` |
| `NODE_EXPORTER_PORT` | node_exporter port | `9100` |
| `METRICS_DOMAIN` | Domain for Caddy auto-config | (none) |
| `METRICS_PATH` | URL path for metrics | `/metrics` |
## Collected Metrics
### System (node_exporter)
- `node_cpu_*` - CPU usage
- `node_memory_*` - Memory usage
- `node_disk_*` - Disk I/O
- `node_network_*` - Network I/O
- `node_filesystem_*` - Filesystem usage
### Per-Skill
Each skill's metrics are prefixed with the skill name:
```
# From ttyd skill
ttyd_connections_active 5
ttyd_sessions_total 123
```
## Usage
```bash
# Scrape aggregated metrics
curl http://localhost:9090/metrics
# With Caddy proxy
curl https://metrics.example.com/metrics
```