| name | algolia-observability |
| description | Set up observability for Algolia: Prometheus metrics for search latency/errors,
OpenTelemetry tracing, structured logging, and Grafana dashboards.
Trigger: "algolia monitoring", "algolia metrics", "algolia observability",
"monitor algolia", "algolia alerts", "algolia tracing", "algolia dashboard".
|
| allowed-tools | Read, Write, Edit |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","search","algolia"] |
| compatibility | Designed for Claude Code |
Algolia Observability
Overview
Algolia provides built-in analytics in the dashboard, but production systems need application-level observability: latency histograms, error rate counters, distributed traces, and alerts. This skill instruments the algoliasearch v5 client with Prometheus, OpenTelemetry, and structured logging.
Key Metrics to Track
| Metric | Type | Why It Matters |
|---|
| Search latency (P50/P95/P99) | Histogram | User experience, SLA compliance |
| Search requests/sec | Counter | Capacity planning, cost tracking |
| Error rate by type | Counter | Detect API issues before users report |
| Index freshness (last updated) | Gauge | Data pipeline health |
| Record count | Gauge | Cost monitoring, data integrity |
Instructions
Step 1: Instrumented Algolia Client Wrapper
import { algoliasearch, ApiError } from 'algoliasearch';
import { Counter, Histogram, Gauge, Registry } from 'prom-client';
const registry = new Registry();
const searchLatency = new Histogram({
name: 'algolia_search_duration_seconds',
help: 'Algolia search request duration in seconds',
labelNames: ['index', 'status'],
buckets: [0.01, 0.025, , , , , , ],
: [registry],
});
searchTotal = ({
: ,
: ,
: [, ],
: [registry],
});
searchErrors = ({
: ,
: ,
: [, , ],
: [registry],
});
indexRecords = ({
: ,
: ,
: [],
: [registry],
});
client = (process..!, process..!);
instrumentedSearch<T = >(
: ,
: <, >
) {
timer = searchLatency.({ : indexName });
{
result = client.<T>({ indexName, searchParams });
({ : });
searchTotal.({ : indexName, : });
result;
} (error) {
({ : });
searchTotal.({ : indexName, : });
(error ) {
searchErrors.({
: indexName,
: error. === ? : ,
: (error.),
});
} {
searchErrors.({
: indexName,
: ,
: ,
});
}
error;
}
}
() {
{ items } = client.();
( idx items) {
indexRecords.({ : idx. }, idx. || );
}
}
{ registry };