Need to display Timeseries Panel with Infinity Plugin

Hello,

I am using inifinity-datasource where I am calling the Elasticsearch with some query and getting some result like below, I need to visualize this result using Timeseries panel (specially the key_as_string and value) but I am getting a message like “Data is missing a time field”,

Can anyone please help me on this ?

[{
        "key_as_string" : "2024-01-14",
        "key" : 1705170400000,
        "doc_count" : 10,
        "average_of_age" : {
          "value" : 13.86
        }
}]

Hi @laksh009

Something like this?

First thing I did was create some dummy data based on your template in order to get some different values that could be plotted over time. I created 3 different values with 3 different dates (3-14, 3-15 3-16):

[{
        "key_as_string" : "2024-03-14",
        "key" : 1705170400000,
        "doc_count" : 10,
        "average_of_age" : {
          "value" : 17.33
        }
},
{
        "key_as_string" : "2024-03-15",
        "key" : 1705170400000,
        "doc_count" : 11,
        "average_of_age" : {
          "value" : 12.86
        }
},
{
        "key_as_string" : "2024-03-16",
        "key" : 1705170400000,
        "doc_count" : 9,
        "average_of_age" : {
          "value" : 26.86
        }
}]

In the Infinity data source, remember to select Time Series.

I used the following UQL commands:

parse-json
| project "key_as_string", "average_of_age.value"
| extend "value"="average_of_age.value"
| extend "date"=todatetime("key_as_string")
| project-away "key_as_string", "average_of_age"

which does the following:

  • parse-json is the command to instruct the UQL to parse the response as JSON
  • project command is used to select the columns to include in the results. To select a property inside a nested object, I used dot notation (average_of_age.value).
  • extend command is similar to project but instead of selecting the columns, it adds/replaces columns in existing data and I also used the todatetime function to convert key_as_string so that it can be interpreted by Grafana as a date/time field.
  • project-away command is exactly opposite as project . It drops specific columns from the data. It doesn’t support alias or dot notation selector.
2 Likes

Thankyou so much for your update, I will be trying this solution and will let you know.