Prometheus

chevron-rightQueries for python shopify orders apihashtag

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)

  • shopify_orders_fetch_total{status="..."}

  • shopify_orders_fetch_duration_seconds

  • shopify_orders_returned_total

  • shopify_orders_revenue_inr_total

  • shopify_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 x seconds.


πŸ›’ 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_timestamp

Alerts 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

Panel Title
Prometheus Query
Type

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