grafana / timestream-datasource

Amazon Timestream in Grafana
https://grafana.com/grafana/plugins/grafana-timestream-datasource
Apache License 2.0
23 stars 19 forks source link

Retrieve query name as macro variable #288

Open victormico opened 2 months ago

victormico commented 2 months ago

Is your feature request related to a problem? Please describe. Currently I have my grafana dashboards as code. I would like to paramtertize the query parameters as much as possbile in order to not have things hardcoded in the query string. For instance:

{
  "database": ":database_name",
  "datasource": {
    "type": "grafana-timestream-datasource",
    "uid": ":datasource_id"
  },
  "hide": true,
  "measure": "sensor_1",
  "rawQuery": "SELECT \r\n  time,\r\n  measure_value::double AS 'First Sensor'\r\n FROM $__database.$__table    \r\nWHERE $__timeFilter\r\n AND measure_name = $__measure \r\n \r\nORDER BY time ASC",
  "refId": "First Sensor",
  "table": ":table_name"
}

I would like to have the query name, this is the refId parameter, as a variable in the rawQuery.

Describe the solution you'd like An additional macro called $__refId. To be able to do the following query:

SELECT
  time,
  measure_value::double AS $__refId
FROM $__database.$__table
WHERE $__timeFilter
AND measure_name = $__measure
ORDER BY time ASC

Describe alternatives you've considered NA Additional context Link to a petition in the grafana forum:

iwysiu commented 2 months ago

Hi @victormico ! Thanks for the feature request, I'll move this to our backlog to be considered.