Our requirement:
In a variable dropdown we should show concatenation of tenantname and shortform like tenantname (shortform). These values coming from calling a postgrest api which call one table. From that table these values will be picked. On change of that variable it should pass only shortform to the table view which we are calling through postgrest api. Based on this result will populate with tables.
Ex: From table, pfm_tenantmanagement_tenant, we will get shortform and tenantname. It should display tenantname(shortform) in variable ‘ActiveTenants’. On change of this values from dropdown, it should pass only shortform value to the view we created which called through postgrest API.
Here Can you please give us solution how to do, in first step concatenation and in second step only taking shortform from cancatenated value .
Sorry, not enough information to solve this. It’s unclear what you mean by “Postgres API”
Your best option if you’re using Postgres SQL is to define a query variable, and then use SQL to do the concat and shortform stuff, since in essence SQL is a full programming language.
As of now we are using database functions which is called through PostgREST API for concatenation and to take only shortform from that concatenated vale on change of variable. But this is causing two database calls.
Our question is, is there any way where concatenation of the values (values will be gets from database) we can do only in grafana for the values taken from database and to take shortform (a column value) only from concatenated value to avoid two database calls?
Or is there any option, where through SQL we can write query for to get required values and do the concatenation in grafana?
I would recommend taking a look at data transformations.
The idea is that if you can get the right data from one fetch instead of 2, you can add extra transformations to cut it down, reformat, and do a wide variety of other operations. If fundamentally you have to do 2 calls in order to get the right information out of the API, then you’re going to have to do 2 calls.
What datasource do you use to call the API? Is it Infinity Plugin or something else? Do you use the variable of Query type? If so, there’s a regex field that you could (probably) use to achieve what you want?
Thank you for your suggestions. This is to filter and display on variable column. But our requirement is, on change of a variable, which contains tenantname(shortform), needed only shortform to be passed to the database view which we are calling.
Kindly suggest on this.
Thank you for your suggestions. Our requirement is, on change of a variable, which contains tenantname(shortform), needed only shortform to be passed to the database view which we are calling.
Kindly suggest on this.