Timeseries stacking not working correctly. It ignore not 0 values

I’m using latest grafana-oss docker.

When stacking is enabled on TimeSeries graphs, it appears to ignore some values and stacking is pretty incorrect. Each field can be 0 or 1, and is filled by previous value.

No Stacking:

Stacking enabled:

Pick one field (not 0):

Values not stacking are driving me crazy!.

How can I fix it?

Thanks!!

Could you please run that same flux query in influxdb:8086 and post back the csv here. by csv I do not mean the csv file, just the csv data

measurement,value,field,time
mqqt_consumer,0,LockStatus,425830945843543
mqqt_consumer,1,LockStatus,121212843543

Here’s the output csv.

#group,false,false,true,true,false,false,true,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string,string
#default,last,
,result,table,_start,_stop,_time,_value,DeviceID,_field,_measurement,host,topic
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:16:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:24:00Z,0,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:26:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T02:26:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T08:26:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,0,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T14:26:00Z,1,571936769,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:18:00Z,0,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:19:00Z,0,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:35:00Z,1,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:36:00Z,1,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:38:00Z,1,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:39:00Z,1,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,1,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:40:00Z,1,571936770,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:16:00Z,1,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:24:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:26:00Z,1,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:29:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T02:29:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T08:29:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,2,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T14:29:00Z,0,571936771,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:16:00Z,1,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:18:00Z,0,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,0,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:26:00Z,1,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T02:26:00Z,1,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T08:26:00Z,1,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,3,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T14:26:00Z,1,571936776,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:16:00Z,0,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:18:00Z,1,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:24:00Z,0,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,0,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:26:00Z,1,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T02:26:00Z,1,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T08:26:00Z,1,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,4,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T14:26:00Z,1,571936784,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:26:00Z,1,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,1,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T00:41:00Z,1,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T06:41:00Z,1,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T12:41:00Z,1,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,5,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T17:32:00Z,0,571936785,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,6,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:26:00Z,1,571936787,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,6,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T00:26:00Z,1,571936787,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,6,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T06:26:00Z,1,571936787,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,6,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T12:26:00Z,1,571936787,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,6,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T18:26:00Z,1,571936787,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:41:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T21:44:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T22:18:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T04:18:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T10:18:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,7,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T16:18:00Z,0,571936789,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:42:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T21:48:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T22:06:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T22:24:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T04:24:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T10:24:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,8,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T16:24:00Z,0,571936790,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,9,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:42:00Z,1,571936792,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,9,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T00:42:00Z,1,571936792,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,9,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T06:42:00Z,1,571936792,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,9,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T12:42:00Z,1,571936792,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,9,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T18:42:00Z,1,571936792,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,10,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:42:00Z,1,571936793,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,10,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T00:42:00Z,1,571936793,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,10,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T06:42:00Z,1,571936793,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,10,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T12:42:00Z,1,571936793,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,10,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T18:42:00Z,1,571936793,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:14:00Z,1,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:18:00Z,1,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:24:00Z,0,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:25:00Z,1,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T18:42:00Z,1,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:26:00Z,1,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-28T20:29:00Z,0,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T02:29:00Z,0,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T08:29:00Z,0,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data
,11,2023-06-28T16:34:40.526Z,2023-06-29T19:35:18.041Z,2023-06-29T14:29:00Z,0,571936802,LockStatus,mqtt_consumer,3f767f3cb092,/up_link_data

1 Like

not getting what you got when using this data you provided.

why are you doing mean calculation in your flux query?

I’s pretty strange you get results between 0 and 1, when values can be 0 or 1.
The only Transformation I’m doing is a regex rename.

image

[\s\S]+?(?:DeviceID=“([^”]*)")[\s\S]+

There’s the Panel JSON:

{
“datasource”: {
“uid”: “b4fd0b3b-2730-458f-95e9-62c8daacc56a”,
“type”: “influxdb”
},
“fieldConfig”: {
“defaults”: {
“custom”: {
“drawStyle”: “line”,
“lineInterpolation”: “stepAfter”,
“barAlignment”: 0,
“lineWidth”: 1,
“fillOpacity”: 35,
“gradientMode”: “none”,
“spanNulls”: true,
“showPoints”: “always”,
“pointSize”: 5,
“stacking”: {
“mode”: “normal”,
“group”: “A”
},
“axisPlacement”: “auto”,
“axisLabel”: “”,
“axisColorMode”: “text”,
“scaleDistribution”: {
“type”: “linear”
},
“axisCenteredZero”: false,
“hideFrom”: {
“tooltip”: false,
“viz”: false,
“legend”: false
},
“thresholdsStyle”: {
“mode”: “off”
},
“lineStyle”: {
“fill”: “solid”
}
},
“color”: {
“mode”: “palette-classic”
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
}
]
},
“max”: 5,
“min”: 0
},
“overrides”:
},
“gridPos”: {
“h”: 22,
“w”: 10,
“x”: 10,
“y”: 0
},
“id”: 2,
“options”: {
“tooltip”: {
“mode”: “single”,
“sort”: “none”
},
“legend”: {
“showLegend”: true,
“displayMode”: “list”,
“placement”: “bottom”,
“calcs”:
}
},
“targets”: [
{
“datasource”: {
“type”: “influxdb”,
“uid”: “b4fd0b3b-2730-458f-95e9-62c8daacc56a”
},
“key”: “Q-1602e317-b1e9-4cbb-8274-de5adac86a79-0”,
“query”: "from(bucket: "4ParkPrivData")\r\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n |> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")\r\n |> filter(fn: (r) => r["_field"] == "LockStatus")\r\n |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)\r\n |> yield(name: "last")\r\n ",
“refId”: “A”
}
],
“title”: “New Panel”,
“transformations”: [
{
“id”: “renameByRegex”,
“options”: {
“regex”: “[\s\S]+?(?:DeviceID="([^"]*)")[\s\S]+”,
“renamePattern”: “$1”
}
}
],
“type”: “timeseries”
}

still havent answered my question why do you use mean function in the flux query

Sorry that is because I had decimal at auto instead of 0

I’m super confused.

Flux query was generated from influx dataexplorer. Still trying to figure how it works, as I understand sql, not flux.

from(bucket: “4ParkPrivData”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “mqtt_consumer”)
|> filter(fn: (r) => r[“_field”] == “LockStatus”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)

probably best for you to take a course on it