mistral-observability
БесплатноБез исполняемых скриптовНе проверенSet up comprehensive observability for Mistral AI integrations with metrics, traces, and alerts. Use when implementing monitoring for Mistral AI operations…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Mistral AI Observability
Overview
Set up comprehensive observability for Mistral AI integrations.
Prerequisites
- Prometheus or compatible metrics backend
- OpenTelemetry SDK installed (optional)
- Grafana or similar dashboarding tool
- AlertManager or similar alerting system
Instructions
Step 1: Define Key Metrics
| Metric | Type | Description |
|---|---|---|
mistral_requests_total |
Counter | Total API requests |
mistral_request_duration_seconds |
Histogram | Request latency |
mistral_tokens_total |
Counter | Tokens used (input/output) |
mistral_errors_total |
Counter | Error count by type |
mistral_cost_usd |
Counter | Estimated cost |
mistral_cache_hits_total |
Counter | Cache hit count |
Step 2: Implement Prometheus Metrics
import { Registry, Counter, Histogram, Gauge } from 'prom-client';
const registry = new Registry();
// Request counter
const requestCounter = new Counter({
name: 'mistral_requests_total',
help: 'Total Mistral AI API requests',
labelNames: ['model', 'status', 'endpoint'],
registers: [registry],
});
// Latency histogram
const requestDuration = new Histogram({
name: 'mistral_request_duration_seconds',
help: 'Mistral AI request duration in seconds',
labelNames: ['model', 'endpoint'],
buckets: [0.1, 0.25, 0.5, 1, 2.5, 5, 10],
registers: [registry],
});
// Token counter
const tokenCounter = new Counter({
name: 'mistral_tokens_total',
help: 'Total tokens used',
labelNames: ['model', 'type'], // type: input, output
registers: [registry],
});
// Error counter
const errorCounter = new Counter({
name: 'mistral_errors_total',
help: 'Mistral AI errors by type',
labelNames: ['model', 'error_type', 'status_code'],
registers: [registry],
});
// Cost gauge (estimated)
const costCounter = new Counter({
name: 'mistral_cost_usd_total',
help: 'Estimated cost in USD',
labelNames: ['model'],
registers: [registry],
});
export { registry, requestCounter, requestDuration, tokenCounter, errorCounter, costCounter };
Step 3: Create Instrumented Client Wrapper
import Mistral from '@mistralai/mistralai';
import {
requestCounter,
requestDuration,
tokenCounter,
errorCounter,
costCounter,
} from './metrics';
// Pricing per 1M tokens (update as needed)
const PRICING: Record<string, { input: number; output: number }> = {
'mistral-small-latest': { input: 0.20, output: 0.60 },
'mistral-large-latest': { input: 2.00, output: 6.00 },
'mistral-embed': { input: 0.10, output: 0 },
};
export async function instrumentedChat(
client: Mistral,
model: string,
messages: any[],
options?: { temperature?: number; maxTokens?: number }
): Promise<any> {
const timer = requestDuration.startTimer({ model, endpoint: 'chat.complete' });
try {
const response = await client.chat.complete({
model,
messages,
...options,
});
// Record success
requestCounter.inc({ model, status: 'success', endpoint: 'chat.complete' });
// Record tokens
if (response.usage) {
tokenCounter.inc({ model, type: 'input' }, response.usage.promptTokens || 0);
tokenCounter.inc({ model, type: 'output' }, response.usage.completionTokens || 0);
// Estimate cost
const pricing = PRICING[model] || PRICING['mistral-small-latest'];
const cost =
((response.usage.promptTokens || 0) / 1_000_000) * pricing.input +
((response.usage.completionTokens || 0) / 1_000_000) * pricing.output;
costCounter.inc({ model }, cost);
}
return response;
} catch (error: any) {
// Record error
requestCounter.inc({ model, status: 'error', endpoint: 'chat.complete' });
errorCounter.inc({
model,
error_type: error.code || 'unknown',
status_code: error.status?.toString() || 'unknown',
});
throw error;
} finally {
timer();
}
}
Step 4: OpenTelemetry Distributed Tracing
import { trace, SpanStatusCode, Span } from '@opentelemetry/api';
const tracer = trace.getTracer('mistral-client');
export async function tracedChat<T>(
operationName: string,
operation: () => Promise<T>,
attributes?: Record<string, string>
): Promise<T> {
return tracer.startActiveSpan(`mistral.${operationName}`, async (span: Span) => {
if (attributes) {
Object.entries(attributes).forEach(([key, value]) => {
span.setAttribute(key, value);
});
}
try {
const result = await operation();
// Add result attributes
if ((result as any).usage) {
span.setAttribute('mistral.input_tokens', (result as any).usage.promptTokens);
span.setAttribute('mistral.output_tokens', (result as any).usage.completionTokens);
}
span.setStatus({ code: SpanStatusCode.OK });
return result;
} catch (error: any) {
span.setStatus({
code: SpanStatusCode.ERROR,
message: error.message,
});
span.r
Установить mistral-observability в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditВложенные файлы
FAQ
Что делает скилл mistral-observability?
Set up comprehensive observability for Mistral AI integrations with metrics, traces, and alerts. Use when implementing monitoring for Mistral AI operations, setting up dashboards, or configuring alerting for Mistral AI integration health. Trigger with phrases like "mistral monitoring", "mistral metrics", "mistral observability", "monitor mistral", "mistral alerts", "mistral tracing".
Как установить скилл mistral-observability?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mistral-observability запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub