| name | mistral-observability |
| description | Set up comprehensive observability for Mistral AI with metrics, traces, and alerts.
Use when implementing monitoring for Mistral AI operations, setting up dashboards,
or configuring alerting for integration health.
Trigger with phrases like "mistral monitoring", "mistral metrics",
"mistral observability", "monitor mistral", "mistral alerts".
|
| allowed-tools | Read, Write, Edit |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","mistral","monitoring","observability","dashboard"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Mistral AI Observability
Overview
Monitor Mistral AI API usage, latency, token consumption, error rates, and costs. Covers instrumented client wrapper, Prometheus metrics, Grafana dashboard panels, alerting rules, and structured logging.
Prerequisites
- Mistral API integration in production
- Prometheus or OpenTelemetry-compatible metrics backend
- Alerting system (Alertmanager, PagerDuty, or similar)
Instructions
Step 1: Instrumented Client Wrapper
import { Mistral } from '@mistralai/mistralai';
const PRICING: Record<string, { input: number; output: number }> = {
'mistral-small-latest': { input: 0.10, output: 0.30 },
'mistral-large-latest': { input: 0.50, output: 1.50 },
'codestral-latest': { input: 0.30, output: 0.90 },
'mistral-embed': { input: 0.10, output: 0 },
};
interface MetricsEvent {
model: string;
endpoint: string;
durationMs: number;
status: 'success' | 'error';
?: ;
?: ;
?: ;
?: ;
}
(): {
.(.({ : , ...event }));
}
() {
start = performance.();
{
response = client..({ model, messages, ...options });
duration = .(performance.() - start);
pricing = [model] ?? [];
pt = response.?. ?? ;
ct = response.?. ?? ;
({
model,
: ,
: duration,
: ,
: pt,
: ct,
: (pt / ) * pricing. + (ct / ) * pricing.,
});
response;
} (: ) {
({
model,
: ,
: .(performance.() - start),
: ,
: error.,
});
error;
}
}