MappingsHelp.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import React from 'react';
  2. import { Alert } from '@grafana/ui';
  3. type Props = {
  4. onDismiss: () => void;
  5. };
  6. export default function MappingsHelp(props: Props): JSX.Element {
  7. return (
  8. <Alert severity="info" title="How to map Graphite metrics to labels?" onRemove={props.onDismiss}>
  9. <p>Mappings are currently supported only between Graphite and Loki queries.</p>
  10. <p>
  11. When you switch your data source from Graphite to Loki, your queries are mapped according to the mappings
  12. defined in the example below. To define a mapping, write the full path of the metric and replace nodes you want
  13. to map to label with the label name in parentheses. The value of the label is extracted from your Graphite query
  14. when you switch data sources.
  15. </p>
  16. <p>
  17. All tags are automatically mapped to labels regardless of the mapping configuration. Graphite matching patterns
  18. (using &#123;&#125;) are converted to Loki&apos;s regular expressions matching patterns. When you use functions
  19. in your queries, the metrics, and tags are extracted to match them with defined mappings.
  20. </p>
  21. <p>
  22. Example: for a mapping = <code>servers.(cluster).(server).*</code>:
  23. </p>
  24. <table>
  25. <thead>
  26. <tr>
  27. <th>Graphite query</th>
  28. <th>Mapped to Loki query</th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. <tr>
  33. <td>
  34. <code>
  35. alias(servers.<u>west</u>.<u>001</u>.cpu,1,2)
  36. </code>
  37. </td>
  38. <td>
  39. <code>
  40. &#123;cluster=&quot;<u>west</u>&quot;, server=&quot;<u>001</u>&quot;&#125;
  41. </code>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td>
  46. <code>
  47. alias(servers.*.<u>&#123;001,002&#125;</u>.*,1,2)
  48. </code>
  49. </td>
  50. <td>
  51. <code>
  52. &#123;server=~&quot;<u>(001|002)</u>&quot;&#125;
  53. </code>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td>
  58. <code>interpolate(seriesByTag(&apos;foo=bar&apos;, &apos;server=002&apos;), inf))</code>
  59. </td>
  60. <td>
  61. <code>&#123;foo=&quot;bar&quot;, server=&quot;002&quot;&#125;</code>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </Alert>
  67. );
  68. }