host id as alias function (#1913)
This commit is contained in:
@@ -337,6 +337,7 @@ Following template variables available for using in `setAlias()` and `replaceAli
|
|||||||
- `$__zbx_item`, `$__zbx_item_name` - item name
|
- `$__zbx_item`, `$__zbx_item_name` - item name
|
||||||
- `$__zbx_item_key` - item key
|
- `$__zbx_item_key` - item key
|
||||||
- `$__zbx_host_name` - visible name of the host
|
- `$__zbx_host_name` - visible name of the host
|
||||||
|
- `$__zbx_host_id` - id of the host
|
||||||
- `$__zbx_host` - technical name of the host
|
- `$__zbx_host` - technical name of the host
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@@ -400,9 +401,9 @@ For more details see [String.prototype.replace()](https://developer.mozilla.org/
|
|||||||
**NOTE:** Other transforms in Grafana Dashboard, like ["Join by label"](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#join-by-labels) will overwrite the alias functions.
|
**NOTE:** Other transforms in Grafana Dashboard, like ["Join by label"](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#join-by-labels) will overwrite the alias functions.
|
||||||
This will happen because the Grafana Dashboard transforms will be applied on the raw data returned by a query.
|
This will happen because the Grafana Dashboard transforms will be applied on the raw data returned by a query.
|
||||||
If such issues arise, you can always use other Dashboard transforms, like:
|
If such issues arise, you can always use other Dashboard transforms, like:
|
||||||
* [Rename by regex](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#rename-by-regex) for fields names
|
|
||||||
* [Value mappings > Regex ](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-value-mappings/#regex) for cell values
|
|
||||||
|
|
||||||
|
- [Rename by regex](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#rename-by-regex) for fields names
|
||||||
|
- [Value mappings > Regex ](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-value-mappings/#regex) for cell values
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ func seriesToDataFrame(series *timeseries.TimeSeriesData, valuemaps []zabbix.Val
|
|||||||
|
|
||||||
if len(item.Hosts) > 0 {
|
if len(item.Hosts) > 0 {
|
||||||
scopedVars["__zbx_host"] = ScopedVar{Value: item.Hosts[0].Name}
|
scopedVars["__zbx_host"] = ScopedVar{Value: item.Hosts[0].Name}
|
||||||
|
scopedVars["__zbx_host_id"] = ScopedVar{Value: item.Hosts[0].ID}
|
||||||
scopedVars["__zbx_host_name"] = ScopedVar{Value: item.Hosts[0].Name}
|
scopedVars["__zbx_host_name"] = ScopedVar{Value: item.Hosts[0].Name}
|
||||||
valueField.Labels["host"] = item.Hosts[0].Name
|
valueField.Labels["host"] = item.Hosts[0].Name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) {
|
|||||||
const host = _.find(hosts, { hostid: item.hostid });
|
const host = _.find(hosts, { hostid: item.hostid });
|
||||||
scopedVars['__zbx_host'] = { value: host.host };
|
scopedVars['__zbx_host'] = { value: host.host };
|
||||||
scopedVars['__zbx_host_name'] = { value: host.name };
|
scopedVars['__zbx_host_name'] = { value: host.name };
|
||||||
|
scopedVars['__zbx_host_id'] = { value: host.id };
|
||||||
|
|
||||||
// Only add host when multiple hosts selected
|
// Only add host when multiple hosts selected
|
||||||
if (_.keys(hosts).length > 1 && addHostName) {
|
if (_.keys(hosts).length > 1 && addHostName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user