Description
the core sql datasources (postgres/mysql/mssql) handle the field-naming in a certain scenario in a special way. the situation is:
- time series mode
- exactly 3 columns of data
- one of the columns is named
metric
for example, this sql query:
SELECT CURRENT_TIMESTAMP as time, 'sku' AS metric, 1 AS cost
produces the following name in the legend
of a timeseries-graph, in postgres, in timeseries-mode: sku
.
the same scenario in the bigquery datasource produces cost sku
.
the reason is that posgres/mysql/mssql has this special code: https://github.com/grafana/grafana/blob/cdd3e1c77601a3b87d07678cc1e1aec27e9fbc04/pkg/tsdb/sqleng/sql_engine.go#L340-L354
it could be useful to add opt-in support for this naming behavior in some form.
open questions:
- how exactly would the user opt in (checkbox next to the field in the query editor? how to handle it in the raw query editor?)
- special case only the field named
metric
, or should it be possible to set it on any field? - what about cases that are not covered by the core-sql behaviour, for example multiple label-fields in the sql result
NOTE: we do not want to make this the default behavior, it would be surprising for new users.
originally reported in #205
see also discussion in grafana/sqlds#109
Metadata
Metadata
Assignees
Labels
Type
Projects
Status