Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when you use query_type=metrics, and add the
function
setAlias($__zbx_host_name: abcd)
, this will work.when you do the same for query_type=services, it does not work.
based on some investigation it seems it will not be easy to make it work for
query_type=services
.for
query_type=metrics
this works, because this is executed as a backend-query, and that handler eventually reaches this line:grafana-zabbix/src/datasource/datasource.ts
Line 214 in 62a292d
and
applyFrontendFunctions
callssetAlias
.when query_type=services, it is not a backend query, so the same code is not called.
instead, we call
grafana-zabbix/src/datasource/datasource.ts
Line 488 in 62a292d
applyFrontendFunctions
.in this draft PR, i tried some quick hacks to make things work, you can see i added the
applyFrontendFunctions
call indatasource.ts
.this will cause
setAlias
to be called.but that is not enough.
in
setAlias
, there is a mainIF
, which branches based on the field-count, if it's 2 or less, it goes into the first branch. we fall here, but the code looks for a field namedValue
, which it does not find. so it sets the frame-name and that's all.my second hack adjusts this, where, if the value-field is not found, it lets the code continue. and this will finally apply the
alias
.but that is not enough.
you see, the "happy path", when it works for
query_type=metrics
, works because of this line:grafana-zabbix/src/datasource/dataProcessor.ts
Line 10 in 62a292d
valueField.config.custom.scopedVars
, so that it has access to variables. this way, when you dosetAlias($__zbx_host_name...)
, the value forzbx_host_name
is found there (probably, i'm guessing 😁 ). but in our case, there is no such attribute, so while something likesetAlias(abcd)
, will work,setAlias($__zbx_host_name)
will not, because it's unable to find that variable's value.