LokiCheatSheet.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react';
  2. const CHEAT_SHEET_ITEMS = [
  3. {
  4. title: 'See your logs',
  5. label: 'Start by selecting a log stream from the Log labels selector.',
  6. },
  7. {
  8. title: 'Logs from a "job"',
  9. expression: '{job="default/prometheus"}',
  10. label: 'Returns all log lines emitted by instances of this job.',
  11. },
  12. {
  13. title: 'Combine stream selectors',
  14. expression: '{app="cassandra",namespace="prod"}',
  15. label: 'Returns all log lines from streams that have both labels.',
  16. },
  17. {
  18. title: 'Search for text',
  19. expression: '{app="cassandra"} (duration|latency)\\s*(=|is|of)\\s*[\\d\\.]+',
  20. label: 'Add a regular expression after the selector to filter for.',
  21. },
  22. ];
  23. export default (props: any) => (
  24. <div>
  25. <h2>Loki Cheat Sheet</h2>
  26. {CHEAT_SHEET_ITEMS.map(item => (
  27. <div className="cheat-sheet-item" key={item.title}>
  28. <div className="cheat-sheet-item__title">{item.title}</div>
  29. {item.expression && (
  30. <div
  31. className="cheat-sheet-item__expression"
  32. onClick={e => props.onClickExample({ refId: '1', expr: item.expression })}
  33. >
  34. <code>{item.expression}</code>
  35. </div>
  36. )}
  37. <div className="cheat-sheet-item__label">{item.label}</div>
  38. </div>
  39. ))}
  40. </div>
  41. );