[solved] Influx DB: maximum value group per day: double output on current day

  • What Grafana version and what operating system are you using?
    v9.3.3 on Roxy Linux 8 (Red Hat 8)

  • What are you trying to achieve?
    getting the maximum values of each day in Time Series Panel

  • How are you trying to achieve it?
    Influx DB Query:

from(bucket: "SAJ-GAB1")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "total power load energy")
  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)
  |> difference()
  • What happened?
    on the 25.12. there is no value
    on the 31.12 there are two values with the timestamp 2022-12-31 01:00:00 and 2022-12-31 13:37:53

  • What did you expect to happen?
    for each day one value

  • Can you copy/paste the configuration(s) that you are having problems with?

{
  "id": 45,
  "gridPos": {
    "h": 9,
    "w": 12,
    "x": 12,
    "y": 81
  },
  "type": "timeseries",
  "title": "Energie Bilanz pro Tag: Bezug und EInspeisung",
  "transformations": [],
  "datasource": {
    "uid": "-- Mixed --",
    "type": "datasource"
  },
  "pluginVersion": "9.3.0-beta1",
  "description": "",
  "fieldConfig": {
    "defaults": {
      "custom": {
        "drawStyle": "bars",
        "lineInterpolation": "linear",
        "barAlignment": 0,
        "lineWidth": 1,
        "fillOpacity": 35,
        "gradientMode": "none",
        "spanNulls": false,
        "showPoints": "auto",
        "pointSize": 5,
        "stacking": {
          "mode": "none",
          "group": "A"
        },
        "axisPlacement": "auto",
        "axisLabel": "",
        "axisColorMode": "text",
        "scaleDistribution": {
          "type": "linear"
        },
        "axisCenteredZero": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "thresholdsStyle": {
          "mode": "off"
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "yellow",
            "value": null
          },
          {
            "color": "blue",
            "value": 0
          }
        ]
      },
      "unit": "watth"
    },
    "overrides": []
  },
  "options": {
    "tooltip": {
      "mode": "single",
      "sort": "none"
    },
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom",
      "calcs": []
    }
  },
  "targets": [
    {
      "datasource": {
        "type": "influxdb",
        "uid": "p-3Ac1z4z"
      },
      "hide": true,
      "query": "from(bucket: \"EM3\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"sensors\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"total\" or r[\"_field\"] == \"total_returned\")\r\n  |> filter(fn: (r) => r[\"device\"] == \"house_phase0\" or r[\"device\"] == \"house_phase1\" or r[\"device\"] == \"house_phase2\")\r\n  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)\r\n  |> difference()",
      "refId": "A"
    },
    {
      "alias": "WP",
      "datasource": {
        "type": "influxdb",
        "uid": "000000009"
      },
      "groupBy": [
        {
          "params": [
            "1d"
          ],
          "type": "time"
        },
        {
          "params": [
            "null"
          ],
          "type": "fill"
        }
      ],
      "hide": true,
      "measurement": "WP_kWh_Day",
      "orderByTime": "ASC",
      "policy": "default",
      "refId": "B",
      "resultFormat": "time_series",
      "select": [
        [
          {
            "params": [
              "value"
            ],
            "type": "field"
          },
          {
            "params": [],
            "type": "max"
          },
          {
            "params": [
              "*1000"
            ],
            "type": "math"
          }
        ]
      ],
      "tags": []
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "jDls7qvVz"
      },
      "hide": true,
      "query": "from(bucket: \"SAJ-GAB1\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"PV 1 today Energy\")\r\n  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)\r\n  |> yield(name: \"mean\")",
      "refId": "C"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "jDls7qvVz"
      },
      "hide": false,
      "query": "from(bucket: \"SAJ-GAB1\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"total power load energy\")\r\n  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)\r\n  |> difference()",
      "refId": "D"
    }
  ]
}

Solved by myself, solution is:

aggregateWindow(every: 1d, fn: max, timeSrc: "_start")

adding in aggregate Window function timeSrc: “_start”