How do I convert a data with a timestamp and number to a histogram with the average of the number every X minutes

Grafana version: 11.5

I’m trying to make a line graph/time series which shows the average execution time of my application.

Currently I have a data that looks like this

I want to get the average executionTime for every 10 minutes. I can’t figure out what to do next to transform this data to something that looks like

Timestamp average executionTime
2025-02-27 03:20:00 1200
2025-02-27 03:30:00 1300
2025-02-27 03:40:00 1100
2025-02-27 03:50:00 1180

I think I’ve tried most of the other transformations that might be relevant like group by, reduce, histogram, partition, either I’m doing something wrong with those or I’m missing a step.

If it’s relevant, the datasource of this are logs in opensearch, each row in the screenshot is 1 log message where I just extracted the timestamp and executionTime data.

1 Like

can you post some sample document data?

Sorry I’m new to this, how should I give the sample data? what format?

Is the data in the screenshot not enough? it’s just logs but I only captured the timestamp field and executionTime, although the execution time was a string so I had to convert it to number as seen in the screenshot as well.

Copy paste open search document minus sensitive data

Like these?

[{
  "_index": "dev-",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2025-02-27T03:24:28.264+08:00",
    "level": "INFO",
    "executionTime": "1279",
    "UUID": "0114a0a8-e1f2-48fd-84da-39bd1ceb90c8",
    "logger_name": "Logger",
    "@log_name": "dev-"
  },
  "fields": {
    "@timestamp": [
      "2025-02-26T19:24:28.264Z"
    ],
    "executionTimeMs": [
      1279
    ]
  },
  "sort": [
    1740597868264
  ]
},
{
  "_index": "dev-",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2025-02-27T03:23:56.001",
    "level": "INFO",
    "executionTime": "1279",
    "UUID": "7ec3ed19-6bfc-4090-a0e2-c88c7fefdd34",
    "logger_name": "Logger",
    "@log_name": "dev-"
  },
  "fields": {
    "@timestamp": [
      "2025-02-27T03:23:56.001"
    ],
    "executionTimeMs": [
      1267
    ]
  },
  "sort": [
    1740597836001
  ]
}]
1 Like