How to merge 2 data series from different datetime into 1 graph

hi

i am using grafana to visualize data using elastic-search data source
i have CPU data from telegraf plugin which hold the CPU data and the server tag

now is the question:
i need to show in one graph the CPU utilization from two different datetime, for example, today and yesterday, but i need it in 2 lines, to do a comparison

there is NO unique field , for sure X axis should not be a date but something like logical interval from the beginning of the datetime
can i do such? merge two different time series and convert it to logical date ?

1 Like

Please define logical interval. Maybe create for us a visual sample using Paint


attached is a how a record is looked, it is taken from cpu plugin for telegraf
i have many of those records, the only data that changes is the @timestamp and the cpu. values

just as example, i want to show a line of all the records created on Saturday and another line in the graph to show last week Saturday
so it is the same metric, no unique values in it but the timestamp and i need to see it in 1 graph

attached is how a record is looked, it is taken from cpu plugin for telegraf
i have many of those records, the only data that changes is the @timestamp and the cpu. values

just as example, i want to show a line of all the records created on Saturday and another line in the graph to show last week Saturday
so it is the same metric, no unique values in it but the timestamp and i need to see it in 1 graph

So is it a daily line graph showing just one day? Or a multi day line graph

Still waiting for “Please define logical interval”

Also please your sample data as json rather than an image?

those records are part of a bigger execution, that execution can happened on any day, so it does not relate for today or tomorrow
i need to be able to view CPU over an 1 hour execution which happened 1 month ago and compare it to a different execution which took place a week ago, so the X axis is not date time since there are two different dates here

{
  "_index": "telegraf-v1-2022.08",
  "_type": "_doc",
  "_id": "yNtWwIIBBbUWfQ01LHHH",
  "_version": 1,
  "_score": 1,
  "_source": {
    "@timestamp": "2022-08-21T15:17:25+03:00",
    "cpu": {
      "usage_guest": 0,
      "usage_guest_nice": 0,
      "usage_idle": 26.434426230876962,
      "usage_iowait": 23.975409836280665,
      "usage_irq": 1.4344262295350831,
      "usage_nice": 0,
      "usage_softirq": 0.40983606559210217,
      "usage_steal": 0,
      "usage_system": 15.163934426385937,
      "usage_user": 32.58196721319297
    },
    "measurement_name": "cpu",
    "tag": {
      "cpu": "cpu2",
      "host": "lab4049"
    }
  },
  "fields": {
    "cpu.usage_user": [
      32.581966
    ],
    "cpu.usage_irq": [
      1.4344262
    ],
    "cpu.usage_nice": [
      0
    ],
    "tag.cpu": [
      "cpu2"
    ],
    "cpu.usage_system": [
      15.163935
    ],
    "cpu.usage_idle": [
      26.434425
    ],
    "cpu.usage_guest_nice": [
      0
    ],
    "@timestamp": [
      "2022-08-21T12:17:25.000Z"
    ],
    "measurement_name": [
      "cpu"
    ],
    "cpu.usage_softirq": [
      0.40983605
    ],
    "cpu.usage_guest": [
      0
    ],
    "cpu.usage_steal": [
      0
    ],
    "tag.host": [
      "lab4049"
    ],
    "cpu.usage_iowait": [
      23.97541
    ]
  }
}
1 Like

I would use the $from $to dates of grafana date filter to use as your comparison dates.

So you can select any 2 dates to compare by using each dates to filter your datain 2 separate queries?