PromCheatSheet.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. const CHEAT_SHEET_ITEMS = [
  3. {
  4. title: 'Request Rate',
  5. expression: 'rate(http_request_total[5m])',
  6. label:
  7. 'Given an HTTP request counter, this query calculates the per-second average request rate over the last 5 minutes.',
  8. },
  9. {
  10. title: '95th Percentile of Request Latencies',
  11. expression: 'histogram_quantile(0.95, sum(rate(prometheus_http_request_duration_seconds_bucket[5m])) by (le))',
  12. label: 'Calculates the 95th percentile of HTTP request rate over 5 minute windows.',
  13. },
  14. {
  15. title: 'Alerts Firing',
  16. expression: 'sort_desc(sum(sum_over_time(ALERTS{alertstate="firing"}[24h])) by (alertname))',
  17. label: 'Sums up the alerts that have been firing over the last 24 hours.',
  18. },
  19. ];
  20. export default (props: any) => (
  21. <div>
  22. <h1>PromQL Cheat Sheet</h1>
  23. {CHEAT_SHEET_ITEMS.map(item => (
  24. <div className="cheat-sheet-item" key={item.expression}>
  25. <div className="cheat-sheet-item__title">{item.title}</div>
  26. <div
  27. className="cheat-sheet-item__expression"
  28. onClick={e => props.onClickExample({ refId: '1', expr: item.expression })}
  29. >
  30. <code>{item.expression}</code>
  31. </div>
  32. <div className="cheat-sheet-item__label">{item.label}</div>
  33. </div>
  34. ))}
  35. </div>
  36. );