Deep API analytics: PromQL expertise, query range analysis, log-based analytics with Elasticsearch, and correlating metrics with deployments.
Agentic Workflow: Read -> Reason -> Act (api-analytics-specialist)
You are api-analytics-specialist (sre) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — sre context for api-analytics-specialist
- Domain: Deep API analytics: PromQL expertise, query range analysis, log-based analytics with Elasticsearch, and correlating metrics with deployments.
- analytics-deep: Advanced analytics queries and log correlation —
curl -G 'http://localhost:9090/api/v1/query_range' --data-urlencode 'query=rate(
- Check
knowledge and prerequisites: prometheus, grafana, elasticsearch
2. Reason — think for api-analytics-specialist
- For
analytics-deep: Advanced analytics queries and log correlation — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-analytics-specialist tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-analytics-specialist:c6c39cd9
API Analytics Specialist
What this skill does
Expert-level API analytics: range queries, alert rules, log-based analysis with Elasticsearch, and correlating metric anomalies with deployments and releases.
When to use
- Investigating performance regressions
- Building alert rules that don't false-positive
- Correlating logs and metrics
Real commands
# Range query over one hour
curl -G 'http://localhost:9090/api/v1/query_range' \
--data-urlencode 'query=rate(http_requests_total[5m])' \
--data-urlencode 'start=2024-06-01T00:00:00Z' \
--data-urlencode 'end=2024-06-01T01:00:00Z' \
--data-urlencode 'step=60' | jq '.data.result[0].values | length'
# Same via promtool
promtool query range 'rate(http_requests_total[1m])' \
--start=2024-06-01T00:00:00Z --end=2024-06-01T01:00:00Z --step=60s http://localhost:9090
# Top 5 busiest paths last hour
curl -s 'http://localhost:9090/api/v1/query?query=topk(5,%20sum%20by%20(path)(rate(http_requests_total[1h])))' | jq '.data.result[].metric.path'
# Deployment churn detection
curl -s 'http://localhost:9090/api/v1/query?query=changes(http_up[1h])' | jq '.data.result'
# Create a daily log index
curl -s -X PUT localhost:9200/api-logs-2024.06.01 | jq '.acknowledged'
# Count 500s in logs
curl -s 'http://localhost:9200/api-logs-*/_search?q=status:500&size=10' | jq '.hits.total.value'
Alert rule example (rules.yml)
groups:
- name: api
rules:
- alert: HighErrorRate
expr: |
sum(rate(http_requests_total{status=~"5.."}[5m])) /
sum(rate(http_requests_total[5m])) > 0.05
for: 10m
Best practices
- Validate rules with promtool before deploying
- Use changes()/predict_linear for anomaly correlation
- Keep log indices date-based for retention
Testing
promtool check rules rules.yml
curl -s 'http://localhost:9090/api/v1/alerts' | jq '.data.alerts[] | {name: .labels.alertname, state}'
Capabilities
analytics-deep
Advanced analytics queries and log correlation
Parameters:
index (string): Elasticsearch index pattern, e.g. api-logs-*
query (string): PromQL or ES query string
range (string): Time range for analysis
Commands:
curl -G 'http://localhost:9090/api/v1/query_range' --data-urlencode 'query=rate(http_requests_total[5m])' --data-urlencode 'start=2024-06-01T00:00:00Z' --data-urlencode 'end=2024-06-01T01:00:00Z' --data-urlencode 'step=60' | jq '.data.result[0].values | length'
curl -s -X PUT localhost:9200/api-logs-2024.06.01 | jq '.acknowledged'
curl -s 'http://localhost:9200/api-logs-*/_search?q=status:500&size=10' | jq '.hits.total.value'
promtool query range 'rate(http_requests_total[1m])' --start=2024-06-01T00:00:00Z --end=2024-06-01T01:00:00Z --step=60s http://localhost:9090
curl -s 'http://localhost:9090/api/v1/query?query=topk(5,%20sum%20by%20(path)(rate(http_requests_total[1h])))' | jq '.data.result[].metric.path'
Examples:
References
1---2name: "api-analytics-specialist"3description: "Deep API analytics: PromQL expertise, query range analysis, log-based analytics with Elasticsearch, and correlating metrics with deployments. Use when working with analytics deep or when the user mentions analytics deep."4license: "MIT"5compatibility: "Requires prometheus, grafana, elasticsearch, node.js, python, kibana. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-analytics-specialist8 author: Kdesk9 version: 2.0.010 category: sre11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(promtool:*)"12---1314Deep API analytics: PromQL expertise, query range analysis, log-based analytics with Elasticsearch, and correlating metrics with deployments.1516## Agentic Workflow: Read -> Reason -> Act (api-analytics-specialist)1718You are **api-analytics-specialist** (sre) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — sre context for `api-analytics-specialist`21- Domain: Deep API analytics: PromQL expertise, query range analysis, log-based analytics with Elasticsearch, and correlating metrics with deployments.22- **analytics-deep**: Advanced analytics queries and log correlation — `curl -G 'http://localhost:9090/api/v1/query_range' --data-urlencode 'query=rate(`23- Check `knowledge` and `prerequisites: prometheus, grafana, elasticsearch`2425### 2. Reason — think for `api-analytics-specialist`26- For `analytics-deep`: Advanced analytics queries and log correlation — decide which checks to run27- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs2829### 3. Act — execute with `api-analytics-specialist` 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-specialist:c6c39cd9`3334# API Analytics Specialist3536## What this skill does37Expert-level API analytics: range queries, alert rules, log-based analysis with Elasticsearch, and correlating metric anomalies with deployments and releases.3839## When to use40- Investigating performance regressions41- Building alert rules that don't false-positive42- Correlating logs and metrics4344## Real commands45```bash46# Range query over one hour47curl -G 'http://localhost:9090/api/v1/query_range' \48 --data-urlencode 'query=rate(http_requests_total[5m])' \49 --data-urlencode 'start=2024-06-01T00:00:00Z' \50 --data-urlencode 'end=2024-06-01T01:00:00Z' \51 --data-urlencode 'step=60' | jq '.data.result[0].values | length'5253# Same via promtool54promtool query range 'rate(http_requests_total[1m])' \55 --start=2024-06-01T00:00:00Z --end=2024-06-01T01:00:00Z --step=60s http://localhost:90905657# Top 5 busiest paths last hour58curl -s 'http://localhost:9090/api/v1/query?query=topk(5,%20sum%20by%20(path)(rate(http_requests_total[1h])))' | jq '.data.result[].metric.path'5960# Deployment churn detection61curl -s 'http://localhost:9090/api/v1/query?query=changes(http_up[1h])' | jq '.data.result'6263# Create a daily log index64curl -s -X PUT localhost:9200/api-logs-2024.06.01 | jq '.acknowledged'6566# Count 500s in logs67curl -s 'http://localhost:9200/api-logs-*/_search?q=status:500&size=10' | jq '.hits.total.value'68```6970## Alert rule example (rules.yml)71```yaml72groups:73 - name: api74 rules:75 - alert: HighErrorRate76 expr: |77 sum(rate(http_requests_total{status=~"5.."}[5m])) /78 sum(rate(http_requests_total[5m])) > 0.0579 for: 10m80```8182## Best practices83- Validate rules with promtool before deploying84- Use changes()/predict_linear for anomaly correlation85- Keep log indices date-based for retention8687## Testing88```bash89promtool check rules rules.yml90curl -s 'http://localhost:9090/api/v1/alerts' | jq '.data.alerts[] | {name: .labels.alertname, state}'91```9293## Capabilities9495### analytics-deep96Advanced analytics queries and log correlation9798**Parameters:**99- `index` (string): Elasticsearch index pattern, e.g. api-logs-*100- `query` (string): PromQL or ES query string101- `range` (string): Time range for analysis102103**Commands:**104- `curl -G 'http://localhost:9090/api/v1/query_range' --data-urlencode 'query=rate(http_requests_total[5m])' --data-urlencode 'start=2024-06-01T00:00:00Z' --data-urlencode 'end=2024-06-01T01:00:00Z' --data-urlencode 'step=60' | jq '.data.result[0].values | length'`105- `curl -s -X PUT localhost:9200/api-logs-2024.06.01 | jq '.acknowledged'`106- `curl -s 'http://localhost:9200/api-logs-*/_search?q=status:500&size=10' | jq '.hits.total.value'`107- `promtool query range 'rate(http_requests_total[1m])' --start=2024-06-01T00:00:00Z --end=2024-06-01T01:00:00Z --step=60s http://localhost:9090`108- `curl -s 'http://localhost:9090/api/v1/query?query=topk(5,%20sum%20by%20(path)(rate(http_requests_total[1h])))' | jq '.data.result[].metric.path'`109110**Examples:**111- curl -s 'http://localhost:9090/api/v1/query?query=changes(http_up[1h])' | jq '.data.result'112- curl -s 'http://localhost:9200/api-logs-*/_search?q=method:POST%20AND%20status:[400%20TO%20499]&size=5' | jq '.hits.hits[]._source'113- promtool query instant 'avg_over_time(http_request_duration_seconds_sum[1d])/avg_over_time(http_request_duration_seconds_count[1d])' http://localhost:9090114115## References116- [PromQL Documentation](https://prometheus.io/docs/prometheus/latest/querying/functions/)117- [Elasticsearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)