Implement API analytics with usage tracking, performance metrics, and developer dashboards: instrument endpoints, store metrics, and build dashboards.
Agentic Workflow: Read -> Reason -> Act (api-analytics-engineer)
You are api-analytics-engineer (sre) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — sre context for api-analytics-engineer
- Domain: Implement API analytics with usage tracking, performance metrics, and developer dashboards: instrument endpoints, store metrics, and build dashboards.
- analytics-pipeline: Instrument APIs and build analytics dashboards —
promtool check config prometheus.yml
- Check
knowledge and prerequisites: prometheus, grafana, elasticsearch, node.js
2. Reason — think for api-analytics-engineer
- For
analytics-pipeline: Instrument APIs and build analytics dashboards — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-analytics-engineer tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-analytics-engineer:3fcabfc3
API Analytics Engineer
What this skill does
Implement API analytics: instrument endpoints with Prometheus counters/histograms, track usage and error rates, expose a metrics endpoint, and build Grafana dashboards for developers.
When to use
- Adding usage/performance tracking to an API
- Building developer dashboards
- Alerting on error rates and latency
Real commands
# Validate config and reload Prometheus
promtool check config prometheus.yml
curl -X POST http://localhost:9090/-/reload
# Requests per second over 5m
curl -s 'http://localhost:9090/api/v1/query?query=rate(http_requests_total[5m])' | jq '.data.result[0].value'
# p99 latency
curl -s 'http://localhost:9090/api/v1/query?query=histogram_quantile(0.99,%20sum(rate(http_request_duration_seconds_bucket[5m]))%20by%20(le))' | jq '.data.result'
# 5xx rate
curl -s 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{status=~"5.."}[5m]))' | jq '.data.result[0].value[1]'
# Start Grafana
docker run -d -p 3000:3000 grafana/grafana
# App metrics endpoint
curl -s http://localhost:8080/api/metrics | jq '.counters'
Instrumentation example (Prometheus client)
const counter = new promClient.Counter({
name: 'http_requests_total',
help: 'Total API requests',
labelNames: ['method', 'path', 'status']
});
counter.inc({ method: req.method, path: req.path, status: res.statusCode });
Dashboard panels
- RPS per endpoint
- p50/p95/p99 latency
- Error rate by status class
- Top consumers by API key
Best practices
- Label cardinality discipline: use templated paths, never raw paths
- Use histograms with pre-bounded buckets
- Expose /metrics on a separate port in production
Testing
promtool check config prometheus.yml
curl -s 'http://localhost:9090/api/v1/query?query=up' | jq '.data.result'
Capabilities
analytics-pipeline
Instrument APIs and build analytics dashboards
Parameters:
query (string): PromQL expression
start (string): RFC3339 start time for range queries
step (string): Resolution step, e.g. 30s
Commands:
promtool check config prometheus.yml
curl -X POST http://localhost:9090/-/reload
curl -s 'http://localhost:9090/api/v1/query?query=rate(http_requests_total[5m])' | jq '.data.result[0].value'
docker run -d -p 3000:3000 grafana/grafana
curl -s -X POST http://localhost:8080/api/metrics | jq '.counters'
Examples:
References
1---2name: "api-analytics-engineer"3description: "Implement API analytics with usage tracking, performance metrics, and developer dashboards: instrument endpoints, store metrics, and build dashboards. Use when working with analytics pipeline or when the user mentions analytics pipeline."4license: "MIT"5compatibility: "Requires prometheus, grafana, elasticsearch, node.js, python, kibana. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-analytics-engineer8 author: Kdesk9 version: 2.0.010 category: sre11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(docker:*) Bash(promtool:*)"12---1314Implement API analytics with usage tracking, performance metrics, and developer dashboards: instrument endpoints, store metrics, and build dashboards.1516## Agentic Workflow: Read -> Reason -> Act (api-analytics-engineer)1718You are **api-analytics-engineer** (sre) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — sre context for `api-analytics-engineer`21- Domain: Implement API analytics with usage tracking, performance metrics, and developer dashboards: instrument endpoints, store metrics, and build dashboards.22- **analytics-pipeline**: Instrument APIs and build analytics dashboards — `promtool check config prometheus.yml`23- Check `knowledge` and `prerequisites: prometheus, grafana, elasticsearch, node.js`2425### 2. Reason — think for `api-analytics-engineer`26- For `analytics-pipeline`: Instrument APIs and build analytics dashboards — decide which checks to run27- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs2829### 3. Act — execute with `api-analytics-engineer` tools30- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)31- Use `safe_path` for any write; record evidence (paths, checksums)32- Fingerprint: `api-analytics-engineer:3fcabfc3`3334# API Analytics Engineer3536## What this skill does37Implement API analytics: instrument endpoints with Prometheus counters/histograms, track usage and error rates, expose a metrics endpoint, and build Grafana dashboards for developers.3839## When to use40- Adding usage/performance tracking to an API41- Building developer dashboards42- Alerting on error rates and latency4344## Real commands45```bash46# Validate config and reload Prometheus47promtool check config prometheus.yml48curl -X POST http://localhost:9090/-/reload4950# Requests per second over 5m51curl -s 'http://localhost:9090/api/v1/query?query=rate(http_requests_total[5m])' | jq '.data.result[0].value'5253# p99 latency54curl -s 'http://localhost:9090/api/v1/query?query=histogram_quantile(0.99,%20sum(rate(http_request_duration_seconds_bucket[5m]))%20by%20(le))' | jq '.data.result'5556# 5xx rate57curl -s 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{status=~"5.."}[5m]))' | jq '.data.result[0].value[1]'5859# Start Grafana60docker run -d -p 3000:3000 grafana/grafana6162# App metrics endpoint63curl -s http://localhost:8080/api/metrics | jq '.counters'64```6566## Instrumentation example (Prometheus client)67```js68const counter = new promClient.Counter({69 name: 'http_requests_total',70 help: 'Total API requests',71 labelNames: ['method', 'path', 'status']72});73counter.inc({ method: req.method, path: req.path, status: res.statusCode });74```7576## Dashboard panels77- RPS per endpoint78- p50/p95/p99 latency79- Error rate by status class80- Top consumers by API key8182## Best practices83- Label cardinality discipline: use templated paths, never raw paths84- Use histograms with pre-bounded buckets85- Expose /metrics on a separate port in production8687## Testing88```bash89promtool check config prometheus.yml90curl -s 'http://localhost:9090/api/v1/query?query=up' | jq '.data.result'91```9293## Capabilities9495### analytics-pipeline96Instrument APIs and build analytics dashboards9798**Parameters:**99- `query` (string): PromQL expression100- `start` (string): RFC3339 start time for range queries101- `step` (string): Resolution step, e.g. 30s102103**Commands:**104- `promtool check config prometheus.yml`105- `curl -X POST http://localhost:9090/-/reload`106- `curl -s 'http://localhost:9090/api/v1/query?query=rate(http_requests_total[5m])' | jq '.data.result[0].value'`107- `docker run -d -p 3000:3000 grafana/grafana`108- `curl -s -X POST http://localhost:8080/api/metrics | jq '.counters'`109110**Examples:**111- curl -s 'http://localhost:9090/api/v1/query?query=histogram_quantile(0.99,%20sum(rate(http_request_duration_seconds_bucket[5m]))%20by%20(le))' | jq '.data.result'112- curl -s 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{status=~"5.."}[5m]))' | jq '.data.result[0].value[1]'113- promtool query instant 'http_requests_total' http://localhost:9090114115## References116- [Prometheus Querying](https://prometheus.io/docs/prometheus/latest/querying/basics/)117- [Grafana Docs](https://grafana.com/docs/grafana/latest/)