Azure DevOps JSON with infinity datasource

I am facing an issue while trying to extract JSON data from Azure DevOps using the yesoreyeram-infinity-datasource plugin in Grafana. I have verified that the URL used returns data correctly in the browser, but in Grafana, the fields appear as “Not Found”.

I am using the following URL in the yesoreyeram-infinity-datasource plugin to get data for work items from Azure DevOps:
https://dev.azure.com///_apis/wit/wiql/f8c3f594-e827-4e8f-aa7a-da55aff0c66f?api-version=7.1-preview.2

could it be it is because you are already logged in? try that link in an incognito chrome web browser

The authentication configuration in Grafana does not present an error, it authenticates successfully. I think that, if when I am logged in the data appears in the browser and there is no authentication error in Grafana, the data should appear. Maybe it is the type of data transformation I am using ($.workItems[*].id), but I have tried several and nothing.

you didnt mentiion the above in first post

what kind if transformation?

please post raw json result from api

Hi, here is the JSON:

{
“datasource”: {
“uid”: “fdsj1cukcuhhce”,
“type”: “yesoreyeram-infinity-datasource”
},
“fieldConfig”: {
“defaults”: {
“custom”: {
“align”: “auto”,
“cellOptions”: {
“type”: “auto”
},
“inspect”: false
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
},
“color”: {
“mode”: “thresholds”
}
},
“overrides”: [
{
“matcher”: {
“id”: “byName”,
“options”: “name”
},
“properties”: [
{
“id”: “custom.width”,
“value”: 164
}
]
},
{
“matcher”: {
“id”: “byName”,
“options”: “referenceName”
},
“properties”: [
{
“id”: “custom.width”,
“value”: 219
}
]
}
]
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 0,
“y”: 0
},
“id”: 1,
“options”: {
“showHeader”: true,
“cellHeight”: “sm”,
“footer”: {
“show”: false,
“reducer”: [
“sum”
],
“countRows”: false,
“fields”: “”
},
“sortBy”:
},
“pluginVersion”: “11.1.0”,
“targets”: [
{
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “fdsj1cukcuhhce”
},
“columns”: ,
“filters”: ,
“format”: “table”,
“global_query_id”: “”,
“refId”: “A”,
“root_selector”: “”,
“source”: “url”,
“type”: “json”,
“url”: “https://dev.azure.com/{organization}/{project}/_apis/wit/wiql/{queryid}?api-version=7.1-preview.2”,
“url_options”: {
“body_content_type”: “text/plain”,
“body_type”: “raw”,
“data”: “{\r\n "query": "SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] FROM workitems"\r\n}\r\n”,
“headers”: [
{
“key”: “Content-Type”,
“value”: “application/json”
}
],
“method”: “GET”,
“params”:
}
}
],
“title”: “All Work Items”,
“transformations”: [
{
“id”: “extractFields”,
“options”: {
“format”: “json”,
“jsonPaths”: [
{
“alias”: “ID”,
“path”: “$.workItems[*].id”
}
],
“source”: “url”,
“replace”: false,
“keepTime”: false
}
}
],
“type”: “table”
}

not the json of ypur dashboard but json from your api

Sorry, here it is:

1 Like

which part of this data do you want to visualize and in what kind of visualization?

I mainly need the dates, status and tags (which is the current stage of the work item within the flow). I also need the history of the work item to understand how long it was stuck in a certain stage within the flow, but I get the history with another API. The problem is that I can’t display the data from any of them.

I don’t see any of those data points in the json you posted

Yes, you are right. The problem is that I need to understand how to extract the value of the fields, no matter which one it is, because if I can understand how to do this, I can apply it to any other Azure Devops API.

As I said, I believe the problem is the data transformation that is incorrect, since the data is loaded via the browser, but I have not found a transformation that displays the data in Grafana.

I just need to understand what I am doing wrong, because if I understand it, I can solve the problem in any other Azure Devops API. If I can understand how to extract the data from this API that I sent you, I will be able to do it in the others too. I think.

here is the docu for infinity thwt will help you understand how to parse your json.

https://grafana.github.io/grafana-infinity-datasource/docs/uql

read it try it out on the real json data, and when stuck post back

Hello,
How did you connected grafana infinity to azure devops api? I’m trying using PAT and basic or bearer token (tried i think all possible settings) authentication but getting code 203. If using curl got proper respond from Azure DevOps

health check failed with url https: //dev.azure.com/xxx. http status code received: 203

Try the curl from within the grafana server. Does it work?

I tried below from my local and it worked.
$PAT = ‘xxx’
$encodedPat = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(“:$PAT”))
$encodedPat
$url = “\https://dev.azure.com/xxx/xxx/_apis/wit/workitems?ids=xxxxxx&api-version=7.1”
$response = Invoke-RestMethod -Uri $url -Method GET -Headers @{Authorization = “Basic $encodedPat”} -ContentType ‘application/json’
$response

but when i choose basic authentication in grafana ininifty settings got 203. I used value the same as in $encodedPat

Grafana is self-hosted as container in azure