Hi,
I want to use the Infinity plugin to fetch JSON responses from an external REST API, but the external API requires to call the login action first (BasicAuth with a user token) and then it responds with session_id. All consecutive REST calls should authenticate through API Key-Value Pair using the obtained session_id, not the initial user token.
I don’t know how to implement this two-step process of call and capture of session_id to use it the http header for regular calls.
I am new to Grafana. How could that be implemented?
Hi,
You can either create a dashboard variable which will store the session_id or check out if infinity plugin supports this kind of authentication (if you decide to do the authentication from infinity, it will be used for all the datasource requests, so if you’re using infinity elsewhere, you’d need to create another datasource).
Thanks a lot, Dawid. I moved forward with your suggestion - dedicated datasource that uses BasicAuth (healthcheck OK) and query-based variable.
In the dashboard variables I’ve set up an HTML type backend parser for URL to capture server’s response and parse it with regex expression to capture the “qOP-g0vfGzsFB5Y8Yc14_Q” value (from the example below) as a dashboard variable but even before setting the regex, the preview of the query shows empty response, even though the HTML console in a browser shows Status OK 200.
Is the response just not recognized as the TEXT/HTML? Tried with JSON, CSV etc. It’s always empty…
Expected server 's response is as follows:
HTTP/2 200
content-length: 0
content-type: text/html
server: Microsoft-HTTPAPI/2.0
enterprisemanager.apisessionid: qOP-g0vfGzsFB5Y8Yc14_Q
date: Wed, 18 Dec 2024 09:56:21 GMT