Essentially I have an API endpoint that works with Resource IDs instead of friendly names, but from an end-user perspective, this isn’t helpful.
I have a variable populated with various application names, i.e.
App1, App2, App3 etc.
However, in order to get related information out of the API, I need to first query the API with the friendly name, to get its ResourceID. Once I have the ResourceID, I can then make an API call to get the info I need.
Now, I have a panel using the InfinitySource plugin, that queries the API with an example ResourceID. This works, but is there a way to then link this to the variable mentioned above, that contains friendly names.
i.e. When the user selects a friendly name from the dropdown, it would need to make an API call first to get the ResourceID, store it, then make another API call to get the information I actually want displayed in the table panel.
You could (theoretically) create a resourceId variable that would depend on the friendly name. But maybe the friendly name and resourceId are in one-to-one relationship? If you knew them in advance, you could create a custom variable that would map them?
Hey, If you have mapping available in one of the tables in MySQL. I would suggest to use mixed-datasource.
For the query A, use inifinity datasource. For the query B use MySQL datasource.
In the transformation, apply “Join” transformation on “Inner” or “Left Join”
In this example screenshot, I’ve a fake api which gives me let’s say book id, and other fields.
Now, I’ve another MySql table which has mapping of book_id and book_title.
I joined both of the queries, using Join transformation.
This then allows me to make the call to the API with a ResourceID to get the information I need.
Is there a way in Grafana I can first make the API call with the FriendlyName, using the varaible that the user chooses from the dropdown, and then use that result in another API call to populate the table panel?
Do you have the datasource with this database? Can you create a variable of type query that would return FriendlyName, ResourceID in one query? If so, you can create a variable with __text and __value fields, in which __text represents what users see and __value what is being passed. So with that you would have one variable - users will be picking friendly names and the variable will evaluate to resourceID
to add to what @dawiddebowski said, you can go even further and dynamically create the url for the resourcedId as the __value in a variable called apps
select FriendlyName as __text,
concat('https://API/getResourceID?FriendlyName=',FriendlyName) as __value
from Kimchee
Yes, you can achieve this by implementing a two-step API query process in your panel. Here’s how you can approach it:
First API Call: When the user selects a friendly name from the dropdown, trigger an API call to fetch the corresponding ResourceID based on the selected name. This can be done dynamically by mapping each friendly name to its ResourceID.
Store ResourceID: Once the ResourceID is retrieved from the first API call, store it in a variable (or use a callback function to keep track of it).
Second API Call: Use the stored ResourceID to make the second API call to retrieve the information you want for display.
You can achieve this functionality using JavaScript or similar scripting within the panel or plugin settings, depending on the customization options provided by the InfinitySource plugin. This approach allows the user to interact with friendly names while still querying the API with the correct ResourceID.