A query returned too many datapoints and the results have been truncated

  • What Grafana version and what operating system are you using?
    Grafana v9.3.2
    Ubuntu Server 20.04

  • What are you trying to achieve?
    Displaying an energy consumption and coast panel for the current month using stat panel type.

  • What happened?
    Getting Errormessage “A query returned too many datapoints and the results have been truncated at 7151 points to prevent memory issues. At the current graph size, Grafana can only draw 715.” on the panel and consumption seems not to be correct. I guess this is because of missing datapoints which cannot be used. Data is coming into influxdb via telegraf, every 5 minutes i get the current consumption as an float value.

  • What did you expect to happen?
    Stat panel should calculate all data without errormessage shown.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Attached you can see the configuration of the Stat panel.



Im using FLUX-Query:

from(bucket: v.defaultBucket)
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r.topic == "shelly-keller/status/switch:1" and
    r._field == "aenergy_total"
  )
  |>map(fn: (r) => ({ r with _field: "Stromverbrauch"}))
  |>drop(columns: ["host", "topic","_measurement"])
  |> aggregateWindow(every: 5m, fn: mean)
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Errormessage on stat Panel “A query returned too many datapoints and the results have been truncated at 7151 points to prevent memory issues. At the current graph size, Grafana can only draw 715.”

I’m seeing this same behavior. Is this the appropriate place to chime in? I don’t know a resolution, but I can provide more information to anyone who can resolve. My initial implementation was with influxdb 1.X and fluxquery on a raspberry pi. I’m querying gps coordinates to generate heat maps on the geomap. This architecture has no problem returning and plotting 57k records on the map.

More recently I wanted to migrate to using docker containers on PC and the latest influxdb docker is 2.X so now I’m using flux. To the best of my knowledge I’m using the flux equivalent of the fluxquery and I get all the results in the influx explorer, but when I query from Grafana I get the error of this topic except the limits are 14631/1463. So when using fluxquery Grafana seems content processing 57k records, but when using flux I get limited to 10x the pixel width. I’ve seen the referenced in a few searches that the limitation is 10x the pixel width.

I can provide whatever detailed version info and schema information to the appropriate personnel to help resolve.

As the error implies, I switched to a 4k monitor and now my query returns 2x the records it did at 1920x1080. However, in this context of the geomap the traces are a tiny cluster in that space. I don’t understand why screen resolution matters with flux but not with fluxquery.

Really nobody knows a solution? :frowning: Im really new to Grafana. Is there a way to calculate the huge amount of data? Or does anyone have the same “setup”?

Im just getting the current power usage in kilowatts per hour from my shelly device and i want to see the usage separated per month.

So for example: December '22: Usage: 100 kWh, January '23 (so far): 80 kWh.

Hi @marcowa,
Have you tried adjusting Max data points under Query options? From your last picture I can see that Max data points is set to auto which is 715. Maybe increasing Max data points would solve the issue.

Best regards,
ldrascic