Can "Config from query results" assign custom label to table columns?

Hello,

I am discovering the “Config from Query Result” transformation and wonder whether it is supposed to allow assigning field label. Is there any information stating whether and how field labels could be assigned through this transformation ?

  • What Grafana version and what operating system are you using?
    Grafana 13.1

  • What are you trying to achieve?
    I am looking for a way to assign labels to columns (or fields) based on external datasource
    (json configuration, query, …)

  • How are you trying to achieve it?
    I try and leverage the Config from query results transformation in order to assign field label

  • What happened?
    Label was not assigned/overriden by the Config from query results transformation

  • What did you expect to happen?
    I expect the label to be assigned/overriden based on data handled by the Config from query results transformation

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No error

  • Did you follow any online instructions? If so, what is the URL?
    I tried and adapted instructions from reference documentation ( Transform data | Grafana documentation )

Kind regards
Denis

Hi Denis,

Config from query results does not directly support assigning arbitrary field labels. It applies supported field configuration options, such as unit, min, max, thresholds, and value mappings, to fields selected under Apply to. Field labels and display names are separate concepts.

Set field display names: Use the Display name option if available in your version. This changes how a field is displayed, but does not assign field labels.

Create fields with labels from rows: The Rows to fields transformation can convert rows into fields and map additional columns to field labels. However, it operates on the query result being transformed; it does not directly apply labels from a separate configuration query to existing fields.

Rename existing columns dynamically: If the names are known in advance, Organize fields by name or Rename by regex may help. For dynamic renaming based on an external mapping, the solution depends on the structure of your data and may require handling the mapping in the query itself.

For more details, see the

, particularly the sections on Config from query results and Rows to fields.

If your specific requirement is to populate field.labels from a separate query, that would likely require a feature enhancement.

Could you share a small example of your main query result and the external mapping data, along with the expected output? We can then suggest the most suitable approach.

Hi, thank you for this feedback

Let me clarify my objective as "assigning display name for fields/columns in the table.

Here is a rough example illustrating what I try and do

  • Main query result provide elements resulting from an opensearch index
    (let’s imagine 2 rows in the snippet below

[
{
“doc_name” : “Doc 001”,
“doc_type” : “Contract”,
“effective” : true,
“doc_version” : 2.0
},
{
“doc_name” : “Doc 002”,
“doc_type” : “Report”,
“effective” : false,
“doc_version” : 3.0
}
]

  • Mapping data, that i emulated as JSON (leveraging the infinity data source plugin), which could result from another query against opensearch

[
{ “field” : “doc_name”, “label” : “Document Name” },
{ “field” : “doc_type”, “label” : “Document Type” },
{ “field” : “effective”, “label” : “Is Effective ?” },
{ “field” : “doc_version”, “label” : “Version” }
]

What I intend to build is a table that would be displayed as below (where labels from columns stand for what is retrieved as mapping data

Document Name Document Type Is Effective ? Version
Doc 001 Contract true 2.0
Doc 002 Report false 3.0

Kind regards
Denis