Skip to content

Instantly share code, notes, and snippets.

@kylebrandt
Created September 12, 2024 15:11
Show Gist options
  • Save kylebrandt/0183f065fa4584795597a34e55cb69fc to your computer and use it in GitHub Desktop.
Save kylebrandt/0183f065fa4584795597a34e55cb69fc to your computer and use it in GitHub Desktop.
Recorded Query Multi-Dimensions - Dataplane + SSE

Recorded Queries and Multiple Dimensions, The Ugly Details

Docs (https://grafana.com/docs/grafana/latest/administration/recorded-queries/#how-recorded-queries-work):

Recorded queries only work with backend data source plugins. Refer to Backend data source plugin for more information about backend data source plugins. You can recorded four types of queries:

  • single row and column - A query that returns a single row and column.
  • row count - A query that returns meaningful rows to be counted.
  • expression - Any expression. To learn more about creating and using expressions, see Write expression queries.
  • dataplane numeric - A query that returns dataplane numeric kind data.

Generally, the two ways that allow multi-dimension metrics to be recorded are (3rd and 4th item above):

  • Use a data source that is directly sending data back in the dataplane numeric format (including version) see dataplane docs and example json Frames. The datasources delcare that they are sending data plane by specify the data type and version in the response.
  • SSE (Server-Side-Expressions) will guess various time series formats and numeric format when the input data in not in data plane. If you add a reduce SSE operation on data that it can guess, you can record that reduce statement as multiple dimensions with recorded queries.

Using SSE method, the numeric format that SSE can guess is a table format with a single numeric column, and one or more string columns (basically what looks like numeric-long in the examples above).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment