1

I have a collection of servers which submit metrics to a single kafka topic. This data is stored as a row in a snowflake database in this format:

{
  "disk_util": 47.7,
  "location": "location1",
  "timestamp": "1683703169378"
}

I'm using this snowflake plugin: https://github.com/michelin/snowflake-grafana-datasource

What I'm trying to do is represent this disk_util metric on a single grafana panel.

I have created a variable named locations using this query:

SELECT LOWER(JSON_EXTRACT_PATH_TEXT(RECORDS, 'location')) FROM METRICS

The panel query:

SELECT
  INSERT_TIME as time,
  to_number(JSON_EXTRACT_PATH_TEXT(RECORDS, 'disk_util'), 10, 1)
FROM
  METRICS
WHERE
  $__timeFilter(INSERT_TIME)
AND
  JSON_EXTRACT_PATH_TEXT(RECORDS, 'location') IN (${locations:singlequote})

The problem is I don't know how to get each location to appear as it's own plot line on one panel as his query mashes it all together on one line when I select multiple locations.

Tom Newton
  • 93
  • 1
  • 8
doublespaces
  • 121
  • 3

1 Answers1

0

Just add location coulmn to your select, so Grafana can actually differentiate between metrics.

Something like this should help:

SELECT
  INSERT_TIME as time,
  to_number(JSON_EXTRACT_PATH_TEXT(RECORDS, 'disk_util'), 10, 1),
  JSON_EXTRACT_PATH_TEXT(RECORDS, 'location')
FROM
  METRICS
WHERE
  $__timeFilter(INSERT_TIME)
AND
  JSON_EXTRACT_PATH_TEXT(RECORDS, 'location') IN (${locations:singlequote})
markalex
  • 126
  • 6