How can i expand a single log entry from Loki into multiple rows

  • What Grafana version and what operating system are you using?
    Grafana v10.1.1 (0cfa76b22d) running in a K8s cluster. Client machine is latest MacOS running Chrome

  • What are you trying to achieve?
    I have retrieved a single logline from Loki using limit=1. That logline contains a json object, including an array.
    I want to use the Table panel to show a line for each element in the JSON array

  • How are you trying to achieve it?
    I have tried various transformations, including the Extract field transformation, but i’m still left with just one row in my table.

  • What happened?
    I can’t get to a point, where i can show a row for each item in the JSON array

  • What did you expect to happen?
    I was expecting to be able to pass a JSON array to the Table panel, and it would then iterate through the items, generating one row per array entry.

  • Can you copy/paste the configuration(s) that you are having problems with?
    My logline holds this data

{
  "snapshot": [
    {
      "title": "Microsoft Azure Information Protection Unified Labeling Client v2.16.79.0",
      "update_revision": "200"
    },
    {
      "title": "2023-10 Update for Windows 10 Version 21H2 for x64-based Systems (KB4023057)",
      "update_revision": "1"
    },
    {
      "title": "Feature update to Windows 10, version 22H2",
      "update_revision": "1"
    },
    {
      "title": "2023-10 Cumulative Update for .NET Framework 3.5, 4.8 and 4.8.1 for Windows 10 Version 21H2 for x64 (KB5031223)",
      "update_revision": "200"
    }
  ]
}

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors. I just have one row in the table which contains all the data.

  • Did you follow any online instructions? If so, what is the URL?
    Transform data | Grafana documentation

1 Like