Metrics logo

Metrics

CommunityPopular
alsk1992
metrics

System metrics, telemetry, and performance monitoring

Overview

Publisheralsk1992
RepositoryCloddsBot
Skill namemetrics
Stars
2.8K
Forks
336
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by alsk1992 on GitHub. Read the source before you install it.

Installation

Install the Metrics AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alsk1992/CloddsBot.git /tmp/CloddsBot
mkdir -p .claude/skills
cp -r /tmp/CloddsBot/src/skills/bundled/metrics .claude/skills/metrics
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Metrics in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Metrics on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Metrics is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Metrics - Complete API Reference

Monitor system health, track performance metrics, and analyze telemetry data.


Chat Commands

System Metrics

/metrics                               Show current metrics
/metrics system                        CPU, memory, latency
/metrics api                           API performance stats
/metrics ws                            WebSocket health

Trading Metrics

/metrics trades                        Trade execution stats
/metrics fills                         Fill rate metrics
/metrics latency                       Order latency stats
/metrics errors                        Error rates

Custom Metrics

/metrics track <name> <value>          Track custom metric
/metrics query <name>                  Query metric history
/metrics alert <name> > 100            Set metric alert

Export & Reports

/metrics export csv                    Export to CSV
/metrics report daily                  Generate daily report
/metrics dashboard                     Open metrics dashboard

TypeScript API Reference

Create Metrics Service

typescript
import { createMetricsService } from 'clodds/metrics';

const metrics = createMetricsService({
  // Collection
  collectInterval: 5000,  // ms
  retention: '30d',

  // Storage
  storage: 'sqlite',
  dbPath: './metrics.db',

  // Export
  enablePrometheus: true,
  prometheusPort: 9090,
});

// Start collection
await metrics.start();

System Metrics

typescript
const system = await metrics.getSystemMetrics();

console.log('=== System Health ===');
console.log(`CPU Usage: ${system.cpuUsage}%`);
console.log(`Memory: ${system.memoryUsed}MB / ${system.memoryTotal}MB`);
console.log(`Uptime: ${system.uptimeHours}h`);
console.log(`Active connections: ${system.activeConnections}`);
console.log(`Event loop lag: ${system.eventLoopLag}ms`);

API Metrics

typescript
const api = await metrics.getApiMetrics();

console.log('=== API Performance ===');
console.log(`Total requests: ${api.totalRequests}`);
console.log(`Requests/sec: ${api.requestsPerSecond}`);
console.log(`Avg latency: ${api.avgLatency}ms`);
console.log(`P50 latency: ${api.p50Latency}ms`);
console.log(`P95 latency: ${api.p95Latency}ms`);
console.log(`P99 latency: ${api.p99Latency}ms`);
console.log(`Error rate: ${api.errorRate}%`);

console.log('\nBy Endpoint:');
for (const endpoint of api.byEndpoint) {
  console.log(`  ${endpoint.path}: ${endpoint.avgLatency}ms (${endpoint.calls} calls)`);
}

WebSocket Metrics

typescript
const ws = await metrics.getWebSocketMetrics();

console.log('=== WebSocket Health ===');
console.log(`Active connections: ${ws.activeConnections}`);
console.log(`Messages/sec: ${ws.messagesPerSecond}`);
console.log(`Avg message size: ${ws.avgMessageSize} bytes`);
console.log(`Reconnections: ${ws.reconnections}`);
console.log(`Dropped messages: ${ws.droppedMessages}`);

console.log('\nBy Feed:');
for (const feed of ws.byFeed) {
  console.log(`  ${feed.name}: ${feed.messagesPerSecond}/s, ${feed.latency}ms lag`);
}

Trade Execution Metrics

typescript
const trades = await metrics.getTradeMetrics();

console.log('=== Trade Execution ===');
console.log(`Total orders: ${trades.totalOrders}`);
console.log(`Fill rate: ${trades.fillRate}%`);
console.log(`Partial fills: ${trades.partialFillRate}%`);
console.log(`Rejections: ${trades.rejectionRate}%`);
console.log(`Avg fill time: ${trades.avgFillTime}ms`);
console.log(`Avg slippage: ${trades.avgSlippage}%`);

console.log('\nBy Platform:');
for (const platform of trades.byPlatform) {
  console.log(`  ${platform.name}:`);
  console.log(`    Fill rate: ${platform.fillRate}%`);
  console.log(`    Avg latency: ${platform.avgLatency}ms`);
}

Latency Breakdown

typescript
const latency = await metrics.getLatencyBreakdown();

console.log('=== Latency Breakdown ===');
console.log(`Total order latency: ${latency.total}ms`);
console.log(`  Signal processing: ${latency.signalProcessing}ms`);
console.log(`  Order construction: ${latency.orderConstruction}ms`);
console.log(`  Network round-trip: ${latency.networkRoundTrip}ms`);
console.log(`  Exchange processing: ${latency.exchangeProcessing}ms`);
console.log(`  Confirmation: ${latency.confirmation}ms`);

Error Metrics

typescript
const errors = await metrics.getErrorMetrics();

console.log('=== Error Rates ===');
console.log(`Total errors: ${errors.totalErrors}`);
console.log(`Error rate: ${errors.errorRate}%`);
console.log(`Errors/hour: ${errors.errorsPerHour}`);

console.log('\nBy Type:');
for (const type of errors.byType) {
  console.log(`  ${type.name}: ${type.count} (${type.percentage}%)`);
}

console.log('\nBy Platform:');
for (const platform of errors.byPlatform) {
  console.log(`  ${platform.name}: ${platform.errorRate}%`);
}

Custom Metrics

typescript
// Track custom metric
metrics.track('edge_detected', 1, {
  market: 'trump-2028',
  edgeSize: 0.05,
});

// Increment counter
metrics.increment('trades_executed');

// Set gauge
metrics.gauge('active_positions', 5);

// Record timing
const timer = metrics.startTimer('order_execution');
// ... execute order ...
timer.end();

// Histogram
metrics.histogram('slippage', 0.003, {
  platform: 'polymarket',
});

Query Metrics

typescript
const query = await metrics.query({
  metric: 'edge_detected',
  period: '7d',
  aggregation: 'sum',
  groupBy: 'market',
});

console.log('Edge Detection by Market:');
for (const row of query.results) {
  console.log(`  ${row.market}: ${row.value} detections`);
}

Metric Alerts

typescript
// Set alert threshold
metrics.setAlert({
  metric: 'error_rate',
  condition: '>',
  threshold: 5,  // > 5% error rate
  window: '5m',
  action: 'notify',
});

metrics.setAlert({
  metric: 'latency_p99',
  condition: '>',
  threshold: 1000,  // > 1000ms
  window: '1m',
  action: 'escalate',
});

// Alert handlers
metrics.on('alert', (alert) => {
  console.log(`🚨 Alert: ${alert.metric} ${alert.condition} ${alert.threshold}`);
  console.log(`  Current value: ${alert.currentValue}`);
});

Export Metrics

typescript
// Export to CSV
await metrics.export({
  format: 'csv',
  metrics: ['api_latency', 'trade_fill_rate', 'error_rate'],
  period: '30d',
  outputPath: './metrics-export.csv',
});

// Export to Prometheus
const prometheusFormat = metrics.toPrometheus();

// Export to JSON
const jsonMetrics = await metrics.toJSON({
  period: '24h',
});

Generate Reports

typescript
const report = await metrics.generateReport({
  type: 'daily',
  include: ['summary', 'api', 'trades', 'errors'],
});

console.log('=== Daily Metrics Report ===');
console.log(`Date: ${report.date}`);
console.log(`\nSummary:`);
console.log(`  Uptime: ${report.summary.uptime}%`);
console.log(`  Total requests: ${report.summary.totalRequests}`);
console.log(`  Total trades: ${report.summary.totalTrades}`);
console.log(`  Error rate: ${report.summary.errorRate}%`);
console.log(`\nHighlights:`);
for (const highlight of report.highlights) {
  console.log(`  - ${highlight}`);
}

Real-time Streaming

typescript
// Stream metrics in real-time
const stream = metrics.stream(['cpu', 'memory', 'latency']);

stream.on('data', (data) => {
  console.log(`CPU: ${data.cpu}%, Memory: ${data.memory}MB, Latency: ${data.latency}ms`);
});

// Stop streaming
stream.stop();

Metric Types

TypeDescriptionExample
CounterMonotonic increasingtrades_total
GaugePoint-in-time valueactive_positions
HistogramDistributionlatency_ms
TimerDuration measurementorder_execution_time

Built-in Metrics

CategoryMetrics
Systemcpu_usage, memory_used, uptime, connections
APIrequest_count, latency_p50/p95/p99, error_rate
WebSocketmessages_per_sec, lag, reconnections
Tradesorders_total, fill_rate, slippage, execution_time
Errorserror_count, error_rate_by_type

Best Practices

  1. Monitor latency percentiles — P99 matters more than average
  2. Set alerts proactively — Catch issues before users notice
  3. Track custom metrics — Business-specific KPIs
  4. Review daily reports — Spot trends early
  5. Export for analysis — Use external tools for deep dives

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Metrics AI skill do?

System metrics, telemetry, and performance monitoring

Why use Metrics on TypingMind?

Because you install it once and use it with any model. Metrics is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Metrics in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/alsk1992/CloddsBot/tree/main/src/skills/bundled/metrics. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Metrics?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Metrics?

As many as you like. As long as a model supports skills, you can use Metrics with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Metrics AI skill free?

Yes. It is published on GitHub by alsk1992 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇