grafana / grafana-infinity-datasource

CSV, JSON, GraphQL, XML and HTML datasource for grafana.
https://grafana.com/docs/plugins/yesoreyeram-infinity-datasource
Apache License 2.0
766 stars 103 forks source link

[Bug] Using jsonata % for parent node access not working in Backend parser #1016

Open yosiasz opened 1 month ago

yosiasz commented 1 month ago

https://try.jsonata.org/iXnJpt6A5

When using

$.metrics.{'name': name,'unit': unit,'value': value,'timestamp': %.timestamp}

on the following json and with Parser backend

[
  {
    "timestamp": 1706220908,
    "metrics": [
      {
        "name": "p50",
        "unit": "us",
        "value": 56
      },
      {
        "name": "p90",
        "unit": "us",
        "value": 125
      },
      {
        "name": "p99",
        "unit": "us",
        "value": 280
      }
    ],
    "attributes": {
      "git_repo": "https://github.com/mytest/test",
      "branch": "main",
      "git_commit": "6995e2de6891c724bfeb2db33d7b87775f913ad1"
    }
  },
  {
    "timestamp": 1706221200,
    "metrics": [
      {
        "name": "p50",
        "unit": "us",
        "value": 60
      },
      {
        "name": "p90",
        "unit": "us",
        "value": 130
      },
      {
        "name": "p99",
        "unit": "us",
        "value": 300
      }
    ],
    "attributes": {
      "git_repo": "https://github.com/mytest/test",
      "branch": "main",
      "git_commit": "7a9f8c1b2dcf134defabcfe329cf5f9a58c8d9d6"
    }
  }
]

but when using same with jsonata it works

parse-json
| jsonata "$.metrics.{  'name': name,  'unit': unit,  'value': value,  'timestamp': %.timestamp,  'git_repo': %.attributes.git_repo,  'branch': %.attributes.branch,  'git_commit': %.attributes.git_commit}"