moxious / triage

testing triage actions for issues
0 stars 1 forks source link

Dashboards: JSON view not working with Azure Monitor #291

Open tonypowa opened 4 months ago

tonypowa commented 4 months ago

What happened?

A field set to JSON view cell type is showing escaped JSON as a single string:

image

What did you expect to happen?

The JSON should not be wrapped in a string.

Did this work before?

I don't know.

How do we reproduce it?

  1. Use Azure Monitor as data source

  2. Select Logs as Service

  3. Create a query that includes a column which contains JSON (parse_json(col) doesn't make a difference)

  4. Set the Cell type of the JSON column as JSON View

Is the bug inside a dashboard panel?

| Key | Value |

|--|--|

| Panel | table @ 9.5.15 |

| Grafana | 9.5.15 (5f5a096c79a0200a4a2cddbb499c50095edc3401) // Pro |

Panel debug snapshot dashboard ```json { "panels": [ { "type": "table", "title": "Reproduced with embedded data", "gridPos": { "h": 13, "w": 15, "x": 0, "y": 0 }, "datasource": { "type": "grafana", "uid": "grafana" }, "id": 2, "targets": [ { "refId": "A", "datasource": { "type": "grafana", "uid": "grafana" }, "queryType": "snapshot", "snapshot": [ { "schema": { "refId": "A", "meta": { "typeVersion": [ 0, 0 ], "custom": { "azureColumnTypes": [ "string", "string", "string", "string", "dynamic", // NOTE: dynamic and string yield the same result "real" ] } }, "fields": [ { "name": "AccountName", "type": "string", "typeInfo": { "frame": "string", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } }, { "name": "OperationName", "type": "string", "typeInfo": { "frame": "string", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } }, { "name": "DatabaseName", "type": "string", "typeInfo": { "frame": "string", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } }, { "name": "CollectionName", "type": "string", "typeInfo": { "frame": "string", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } }, { "name": "PIICommandText", "type": "string", "typeInfo": { "frame": "string", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } }, { "name": "DurationMs", "type": "number", "typeInfo": { "frame": "float64", "nullable": true }, "config": { "links": [ { "title": "View in Azure Portal", "targetBlank": true, "url": "..." } ] } } ] }, "data": { "values": [ [ "test" ], [ "Aggregate" ], [ "somedb" ], [ "somecoll" ], [ "{\"request\":\"{ \"aggregate\" : \"somecoll\", \"pipeline\" : [{ \"$match\" : { } }, { \"$group\" : { \"_id\" : 1, \"n\" : { \"$sum\" : 1 } } }], \"cursor\" : { }, \"lsid\" : { \"id\" : CSUUID(\"...\") }, \"$db\" : \"somedb\" }\"} " ], [ 6381.2555 ] ] } } ] } ], "options": { "showHeader": true, "cellHeight": "sm", "footer": { "show": false, "reducer": [ "sum" ], "countRows": false, "fields": "" } }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "value": null, "color": "green" }, { "value": 80, "color": "red" } ] }, "color": { "mode": "thresholds" } }, "overrides": [ { "matcher": { "id": "byName", "options": "PIICommandText" }, "properties": [ { "id": "custom.cellOptions", "value": { "type": "json-view" } } ] }, { "matcher": { "id": "byRegexp", "options": "/.*/" }, "properties": [ { "id": "links" } ] } ] }, "pluginVersion": "9.5.15", "transformations": [] }, { "gridPos": { "h": 7, "w": 9, "x": 15, "y": 0 }, "id": 5, "options": { "content": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Paneltable @ 9.5.15
QueriesA[grafana-azure-monitor-datasource]
Transforms (0)
Data 1 frames, 6 fields, 1 rows
Grafana9.5.15 (5f5a096c79a0200a4a2cddbb499c50095edc3401) // Pro
", "mode": "html" }, "title": "Debug info", "type": "text" }, { "id": 6, "title": "Original Panel JSON", "type": "text", "gridPos": { "h": 13, "w": 9, "x": 15, "y": 7 }, "options": { "content": "...", "mode": "code", "code": { "language": "json", "showLineNumbers": true, "showMiniMap": true } } }, { "id": 3, "title": "Data from panel above", "type": "table", "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "gridPos": { "h": 7, "w": 15, "x": 0, "y": 13 }, "options": { "showTypeIcons": true }, "targets": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "panelId": 2, "withTransforms": true, "refId": "A" } ] } ], "schemaVersion": 37, "title": "Debug: Panel Title // 2024-02-06 22:22:01", "tags": [ "debug", "debug-table" ], "time": { "from": "2024-01-30T22:22:01.636Z", "to": "2024-02-06T22:22:01.636Z" } } ```

Environment (with versions)?

Grafana: 9.5.15

OS: Windows

Browser: Edge

Grafana platform?

Other

Datasource(s)?

Azure Monitor 1.0.0

tonypowa commented 4 months ago

This issue is a test copy of an issue in another repo. Original issue: https://github.com/grafana/grafana/issues/#82026

moxious commented 4 months ago

Summary: An issue is open where JSON data displayed in Grafana dashboards using the Azure Monitor datasource appears as an escaped string instead of formatted JSON. The user expects the JSON not to be wrapped in a string and has provided steps to reproduce the issue, along with environment details and a snapshot of the dashboard configuration.

moxious commented 4 months ago

Hello @tonypowa, thank you for the detailed report. It seems the issue is related to the Azure Monitor datasource parsing and displaying JSON data within the dashboard panels. This issue may best fit under the Azure Datasources project, where it concerns parsing and visualizing data from Azure Monitor within Grafana. I'll tag the issue for the Azure Datasources team to take a look.

/project Azure Datasources project
moxious commented 4 months ago

Elaboration:

Thank you for providing a detailed description of the issue and the environment in which it occurs. To investigate this further, we need some additional information. Here are a few questions and requests that will help us get to the bottom of this issue:

  1. Could you confirm if this issue persists when using a different browser or in incognito mode to rule out any browser-specific problems or conflicts with browser extensions?

  2. When you mentioned that parse_json(col) doesn't make a difference, have you tried other ways to parse the JSON within the query itself? If so, could you please provide the alternative query expressions you have used?

  3. Is the escaping of JSON happening consistently across all the rows in the table where the JSON view is expected, or is it only occurring in specific cases?

  4. Can you provide a screenshot or a copy of how the raw data looks when queried directly from Azure Monitor before it is processed by Grafana? This could help determine if the issue is with the data format returned from Azure or with how Grafana is interpreting it.

  5. Have you attempted to upgrade to a newer version of Grafana or the Azure Monitor plugin, if available, to see if this issue has been addressed in a subsequent release?

  6. Are there any errors or warnings in the Grafana server logs or in the web console that could provide additional insight into what might be going wrong?

  7. If possible, could you provide a sanitised (redacted of any sensitive information) version of the original panel JSON? This could be helpful for replicating the exact configuration you are using.

Once we have this information, we'll be better positioned to understand the issue and provide a solution or a workaround. Thank you for working with us on this!