Prometheus
Queries for python shopify orders api
Awesome! Now that youβve got Prometheus metrics from your Python Shopify Order API, hereβs a comprehensive guide with Prometheus queries to monitor key SLI, SLO, and infrastructure metrics β ready to be used in Grafana dashboards, alerting, or dashboards.
β
Available Metrics (from your metrics.py)
metrics.py)shopify_orders_fetch_total{status="..."}shopify_orders_fetch_duration_secondsshopify_orders_returned_totalshopify_orders_revenue_inr_totalshopify_orders_last_success_timestamp
π 1. Basic Metric Queries
πΉ Total Successful Order Fetches
increase(shopify_orders_fetch_total{status="success"}[1h])πΉ Total Errors (last 1 hour)
increase(shopify_orders_fetch_total{status="error"}[1h])πΉ Exceptions Count
increase(shopify_orders_fetch_total{status="exception"}[1h])π 2. SLI Queries
πΉ Availability SLI (% of successful requests)
(
sum(increase(shopify_orders_fetch_total{status="success"}[1h]))
/
sum(increase(shopify_orders_fetch_total[1h]))
) * 100π Use this to set a 95%+ target SLO for availability
π 3. SLO: Response Latency / Performance
πΉ 95th Percentile Order Fetch Latency
histogram_quantile(0.95, rate(shopify_orders_fetch_duration_seconds_bucket[5m]))You can track 95% of requests completed under
xseconds.
π 4. Order-Based Business Metrics
πΉ Current Returned Orders Count
shopify_orders_returned_totalπΉ Approximate Revenue (total in INR)
shopify_orders_revenue_inr_totalβ° 5. Last Order Sync Timestamp
To see when the last successful order fetch occurred:
time() - shopify_orders_last_success_timestampAlerts you if no successful fetch happened in the last 5β10 minutes.
π 6. Alert Examples
πΈ No orders fetched in 10 minutes
(shopify_orders_last_success_timestamp < (time() - 600))πΈ Error rate exceeds 5%
(
rate(shopify_orders_fetch_total{status="error"}[5m])
/
rate(shopify_orders_fetch_total[status!~"exception"][5m])
) > 0.05π 7. Grafana Chart Ideas
API Success Rate (%)
SLI Query Above
Gauge / Line
API Latency (95th %ile)
histogram_quantile(0.95, β¦)
Line
Orders Returned
shopify_orders_returned_total
Gauge
Revenue in INR
shopify_orders_revenue_inr_total
Stat
Order Fetch Statuses
increase(shopify_orders_fetch_total[1h])
Bar
Last Sync Delay
time() - shopify_orders_last_success_timestamp
Stat / Alert
π Want more?
Let me know if you want:
π JSON to import Grafana dashboard
π¦ Combine with Loki logs or Uptime probes
π€ Export data to Google Sheets / BigQuery / CSV
Youβre now observability-ready π
Last updated