Skip to content
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

Multiple series can't be distinguished in legend #517

Open
cdeil opened this issue Nov 16, 2022 · 3 comments
Open

Multiple series can't be distinguished in legend #517

cdeil opened this issue Nov 16, 2022 · 3 comments

Comments

@cdeil
Copy link
Contributor

cdeil commented Nov 16, 2022

When I use the query builder and add two queries and time series they are both shown as avg_Value in the legend and it's not clear which is which.

Other Plugins like Graphite have a nice way to alias time series names.

Could you please offer something like this for ADX as well?

PS: this was already mentioned in #14 and probably I should have filed it as a feature request, but I thought maybe bug reports get more attention. :-)

Screenshot 2022-11-16 at 20 40 10

Screenshot 2022-11-16 at 20 37 25

@cdeil cdeil added datasource/ADX type/bug Something isn't working labels Nov 16, 2022
@andresmgot andresmgot moved this to Incoming in Partner Datasources Nov 17, 2022
@andresmgot andresmgot added enhancement New feature or request and removed type/bug Something isn't working labels Nov 24, 2022
@andresmgot
Copy link
Contributor

hi @cdeil, this is due to the fact that that's the column name of the returned values.

In fact, we could add an Alias field so we can rename it but that would be a new feature request. In the meantime, you can manually rename the column if you edit the KQL code, using the project-rename function:

| summarize avg(Value) by bin(DateTime, $__timeInterval)
| project-rename W1_KAL_SCIN=avg_Value

@andresmgot andresmgot moved this from Incoming to Backlog in Partner Datasources Nov 24, 2022
@Grrrolf
Copy link

Grrrolf commented Nov 25, 2022

Hello @cdeil,

Have you considered using a query where you add the SensorTag column in the summarize / group by?

Plant_Metric_0762
| where $__timeFilter(DateTime)
| where SensorTag in ('W1_Kal_OSADY', 'W1_KAL_SCIN')
| summarize average(Value) by bin(Datetime, $__timeinterval), SensorTag
| order by Datetime asc;

This will give you an output like:

DateTime     SensorTag,        avg_value
2022-01-01   W1_Kal_OSADY      10
2022-01-01   W1_KAL_SCIN       16
etc.

The graph would then look like this:
image

However, this does not solve the Alias field, but in my opinion, one should not define 'friendly names' hardcoded in queries, but add a friendly name column in Plant_Metric_0762 table. An alternative is creating a fact table and use a join to get the friendly name. However, this is not always possible depending on the situation.

In such situation where you need to hardcode this, you can use the let statement to define a key/value list with the SensorTag as the key and the friendly name as the value. Then use strcat() to format the label.
For example:

let FriendlyNames=dynamic({'W1_Kal_OSADY': 'Friendly name 1', 'W1_KAL_SCIN': 'Friendly name 2'});
Plant_Metric_0762
| where $__timeFilter(DateTime)
| where SensorTag in ('W1_Kal_OSADY', 'W1_KAL_SCIN')
| summarize average(Value) 
         by bin(Datetime, $__timeinterval), 
            SensorName=strcat(SensorTag, ' = ', Friendlynames[SensorTag])
| order by Datetime asc;

Which will result in something like this:
image
Still not the label names we expect in the legend.
We can use the Grafana "labels to fields" transformation to apply the values of the SensorName column to the labels:
image
Now the sensor tags have both the sensor tag and the 'Alias'.

@Grrrolf
Copy link

Grrrolf commented Nov 25, 2022

In the meantime, you can manually rename the column if you edit the KQL code, using the project-rename function:

| summarize avg(Value) by bin(DateTime, $__timeInterval)
| project-rename W1_KAL_SCIN=avg_Value

| project-rename ['W1_KAL_SCIN = RDF calciner']=avg_Value also works to have the friendly name included too.

@alyssabull alyssabull moved this from Backlog to Feature Requests in Partner Datasources Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Feature Requests
Development

No branches or pull requests

4 participants