How to use UQL parser to get this field's value?

  • What Grafana version and what operating system are you using?
    Grafana v9.2.1 Windows 11
  • What are you trying to achieve?
    To select a field’s value of a JSON payload.
  • How are you trying to achieve it?
    Using UQL parser for Infinity data source.
  • What happened?
    It returns “No data”.
  • What did you expect to happen?
    To see the value appear.
  • Can you copy/paste the configuration(s) that you are having problems with?
    This is the command I typed:
| project "metricName"

This is the JSON I’m trying to parse.

        "metricId": 180021,
        "metricName": "aaa",
        "metricPath": "bbb",
        "frequency": "ONE_MIN",
        "metricValues": [
                "startTimeInMillis": 1705057800000,
                "occurrences": 0,
                "current": 0,
                "min": 0,
                "max": 0,
                "useRange": false,
                "count": 2714,
                "sum": 195,
                "value": 3,
                "standardDeviation": 0

I know it’s being parsed somehow because, if I didn’t write the command, it displays the first field’s value by default. I’m using Stat panel.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

It looks like you need mv-expand command from UQL. Example

| mv-expand "metricValue"="metricValues"
| project "metricName", "time"=unixtime_milliseconds_todatetime("metricValue.startTimeInMillis"), "value"="metricValue.value"

What do you want your data to look like? Can you share a mock-up of what you want?

If possible, share the URL that is providing you with the JSON data so that others here can try to help.


Thank you. I think my problem has been solved.