Skip to content

Commit

Permalink
Fix missing labels in response data frame
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Apr 19, 2022
1 parent 91ad43b commit f0842bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/datasource/response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,25 @@ func seriesToDataFrame(series *timeseries.TimeSeriesData, valuemaps []zabbix.Val
Name: seriesName,
}
}

scopedVars := map[string]ScopedVar{
"__zbx_item": {Value: item.Name},
"__zbx_item_name": {Value: item.Name},
"__zbx_item_key": {Value: item.Key},
"__zbx_item_interval": {Value: item.Delay},
}

valueField.Labels = data.Labels{
"item": item.Name,
"item_key": item.Key,
}

if len(item.Hosts) > 0 {
scopedVars["__zbx_host"] = ScopedVar{Value: item.Hosts[0].Name}
scopedVars["__zbx_host_name"] = ScopedVar{Value: item.Hosts[0].Name}
valueField.Labels["host"] = item.Hosts[0].Name
}

valueField.Config = &data.FieldConfig{
Custom: map[string]interface{}{
"scopedVars": scopedVars,
Expand Down

0 comments on commit f0842bf

Please sign in to comment.