Skip to content

feature request: add opt-in support for special handling the metric label in time-series queries #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gabor opened this issue Feb 20, 2024 · 1 comment

Comments

@gabor
Copy link

gabor commented Feb 20, 2024

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

@gabor gabor moved this to Backlog in OSS Big Tent Feb 20, 2024
@gabor
Copy link
Author

gabor commented Feb 20, 2024

i added the info to the original issue instead, closing this one.

@gabor gabor closed this as completed Feb 20, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Complete in OSS Big Tent Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Complete
Development

No branches or pull requests

1 participant