Panel query timeout

Hy all,

I’ve running a Grafana Enterprise 9.2.3 and InfluxDB 2.6.0-1 on a Ubuntu 22.04.1 LTS (12Gb RAM, 6Cores, 50GB).

I collect measurement results from several testequipment into an influxDB bucket.

In Grafana i successfully set up some panels, where i can query and calculate metrics like testing time, counts, first-pass yield, and so on.

Most of them works fine (and quick) as long as the number of returned results are lower than approx 500, and as long as the selected time range is not longer than 3 days. If the number of the returned results is getting higher, the queries are timed out with error:
Post "http://localhost:8086/api/v2/query?org=My-org": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

To clarify: I’m not sure if the amount of data or timerange is really the cause for the timeout!? Anyway, in InfluxDB I set up the same flux query and the result is returned in some few seconds. This tells me that InfluxDB (and the server hardware) is performant enough to handle also higher amount of data.

The query is

import "date"


//definiere den Zeitbereich, in welchem die Auswertung erfolgen soll
auswertungsIntervallStart = 2w
auswertungsIntervallStop = 1w
//Measurement Name
prueflingAuswahl = "DUT_XY"
//Produktionsnummer
pmAuswahl = 12345


//get the Start-time upon the day to shift value 
// dayShift = 0 -> today
// dayShift = 1 -> vesterday
// dayShift = 2 -> day before yesterday
getStartRange = (dayShift=0) =>{
    ret = if (dayShift) == 0 then
        today()
    else
        date.sub(from: today(), d: duration(v: dayShift))

    return ret
}

//get the End-time upon the day to shift value 
// dayShift = 0 -> now
// dayShift = 1 -> today
// dayShift = 2 -> yesterday
getEndRange = (dayShift=0) => {
    shift = dayShift - int(v: 1d)
    ret = if (dayShift) == 0 then
        now()
    else if (dayShift) == 1 then
        today()
    else
        date.sub(from: today(), d: duration(v: shift))

    return ret
}


from(bucket: "Testdaten_2")
  |> range(start: getStartRange(dayShift: int(v: auswertungsIntervallStart)),
           stop: getEndRange(dayShift: int(v: auswertungsIntervallStop)))
  |> filter(fn: (r) => 
    r._measurement == prueflingAuswahl and
    r["PM"] == string(v: pmAuswahl) and
    r._field == "ok" and
    r._value == false )
  |> group(columns: ["Messwert"])
  |> count()
  |> group()

The panel looks like this, when all results are returned without timeout:

I don’t understand why Grafana times out, even tough the same flux query works fine in the influxDB?

Is there a way to find out, why or where this timeout occurs?

thanks and regards