Passing $__from and $__to as custom variables incorrectly

  • What Grafana version and what operating system are you using?

    • 12.2.0-16677249643
  • What are you trying to achieve?

    • Apply a filter on the time range with ‘filter data by values’ transformation.
  • How are you trying to achieve it?

    • Create 2 custom hidden variables $start_date and $end_date as set these respectively as $__from and $__to. I do this because it is a library panel and in this dashboard doesn’t need an extra time range filter, but I cannot delete the transformation.
  • What happened?

    • it does not show all the data if time range is for example set to -1h (see screenshot). the last part is cut off if the filter is enabled. I other words, if the filter is set to [$start_date;$end_date] it does not show the same data as [$__from,$__to] while this is essentially the same?
    • without the filter
    • with the filter (data after 10:20 is missing)
  • What did you expect to happen?

    • to show all the data with or without the filter enabled. that [$start_date,$end_date] is passed the same as [$__from,$__to]
  • Can you copy/paste the configuration(s) that you are having problems with?

{
  "libraryPanel": {
    "id": 30,
    "orgId": 1,
    "folderId": 14,
    "folderUid": "cegbo7j0wujuoa",
    "uid": "cesvxoltepm

gwa",
    "name": "Latency ",
    "kind": 1,
    "type": "timeseries",
    "description": "Frame Latency is the time it takes from the captured image until the end of the streaming pipeline. In other words, the streaming latency.\nRendering Latency is measured until it is shown on the screen\n",
    "model": {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "description": "Frame Latency is the time it takes from the captured image until the end of the streaming pipeline. In other words, the streaming latency.\nRendering Latency is measured until it is shown on the screen\n",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "dashed"
            }
          },
          "fieldMinMax": false,
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 2000
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Frame Latency (95%)"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    0,
                    10
                  ],
                  "fill": "dot"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Rendering Latency (99%)"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    0,
                    10
                  ],
                  "fill": "dot"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 1
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Rendering Latency MAX"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    0,
                    10
                  ],
                  "fill": "dot"
                }
              }
            ]
          }
        ]
      },
      "interval": "15s",
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "12.2.0-16606054638",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "code",
          "expr": "rendering_latency_milliseconds_sum{device_id=~\"$device|$tablet\"} / (rendering_latency_milliseconds_count{ device_id=~\"$device|$tablet\"})",
          "hide": false,
          "instant": false,
          "interval": "",
          "legendFormat": "latency",
          "range": true,
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(0.99, sum by(le) (rate(rendering_latency_milliseconds_bucket{device_id=~\"$device|$tablet\"}[${interval}])))",
          "hide": false,
          "instant": false,
          "legendFormat": "Rendering Latency (99%)",
          "range": true,
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "code",
          "expr": "histogram_quantile(1.0, sum by(le) (rate(rendering_latency_milliseconds_bucket{device_id=~\"$device|$tablet\"}[${interval}])))",
          "hide": false,
          "instant": false,
          "legendFormat": "Rendering Latency MAX",
          "range": true,
          "refId": "C"
        }
      ],
      "title": "Latency ",
      "transformations": [
        {
          "id": "filterByValue",
          "options": {
            "filters": [
              {
                "config": {
                  "id": "between",
                  "options": {
                    "from": "${start_date}",
                    "to": "${end_date}"
                  }
                },
                "fieldName": "Time"
              }
            ],
            "match": "all",
            "type": "include"
          }
        }
      ],
      "type": "timeseries"
    },
    "version": 15,
    "meta": {
      "folderName": "V2 analytics",
      "folderUid": "cegbo7j0wujuoa",
      "connectedDashboards": 2,
      "created": "2025-07-24T09:49:42Z",
      "updated": "2025-08-05T13:27:08Z",
      "createdBy": {
        "id": 10,
        "name": "tech1e46",
        "avatarUrl": "/avatar/38aceb2d2a7e727c104ea16b4546227c"
      },
      "updatedBy": {
        "id": 10,
        "name": "tech1e46",
        "avatarUrl": "/avatar/38aceb2d2a7e727c104ea16b4546227c"
      }
    }
  },
  "id": 11,
  "type": "timeseries",
  "title": "Latency ",
  "description": "Frame Latency is the time it takes from the captured image until the end of the streaming pipeline. In other words, the streaming latency.\nRendering Latency is measured until it is shown on the screen\n",
  "gridPos": {
    "x": 0,
    "y": 38,
    "h": 11,
    "w": 24
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "drawStyle": "line",
        "lineInterpolation": "linear",
        "barAlignment": 0,
        "barWidthFactor": 0.6,
        "lineWidth": 1,
        "fillOpacity": 0,
        "gradientMode": "none",
        "spanNulls": false,
        "insertNulls": false,
        "showPoints": "auto",
        "pointSize": 5,
        "stacking": {
          "mode": "none",
          "group": "A"
        },
        "axisPlacement": "auto",
        "axisLabel": "",
        "axisColorMode": "text",
        "axisBorderShow": false,
        "scaleDistribution": {
          "type": "linear"
        },
        "axisCenteredZero": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "thresholdsStyle": {
          "mode": "dashed"
        },
        "lineStyle": {
          "fill": "solid"
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 2000
          }
        ]
      },
      "fieldMinMax": false,
      "min": 0,
      "unit": "ms"
    },
    "overrides": [
      {
        "matcher": {
          "id": "byName",
          "options": "Frame Latency (95%)"
        },
        "properties": [
          {
            "id": "custom.lineStyle",
            "value": {
              "dash": [
                0,
                10
              ],
              "fill": "dot"
            }
          },
          {
            "id": "custom.lineWidth",
            "value": 2
          }
        ]
      },
      {
        "matcher": {
          "id": "byName",
          "options": "Rendering Latency (99%)"
        },
        "properties": [
          {
            "id": "custom.lineStyle",
            "value": {
              "dash": [
                0,
                10
              ],
              "fill": "dot"
            }
          },
          {
            "id": "custom.lineWidth",
            "value": 1
          }
        ]
      },
      {
        "matcher": {
          "id": "byName",
          "options": "Rendering Latency MAX"
        },
        "properties": [
          {
            "id": "custom.lineStyle",
            "value": {
              "dash": [
                0,
                10
              ],
              "fill": "dot"
            }
          }
        ]
      }
    ]
  },
  "transformations": [
    {
      "id": "filterByValue",
      "options": {
        "filters": [
          {
            "config": {
              "id": "between",
              "options": {
                "from": "${start_date}",
                "to": "${end_date}"
              }
            },
            "fieldName": "Time"
          }
        ],
        "match": "all",
        "type": "include"
      },
      "disabled": true
    }
  ],
  "pluginVersion": "12.2.0-16677249643",
  "targets": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "editorMode": "code",
      "expr": "rendering_latency_milliseconds_sum{device_id=~\"$device|$tablet\"} / (rendering_latency_milliseconds_count{ device_id=~\"$device|$tablet\"})",
      "hide": false,
      "instant": false,
      "interval": "",
      "legendFormat": "latency",
      "range": true,
      "refId": "B"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "editorMode": "code",
      "expr": "histogram_quantile(0.99, sum by(le) (rate(rendering_latency_milliseconds_bucket{device_id=~\"$device|$tablet\"}[${interval}])))",
      "hide": false,
      "instant": false,
      "legendFormat": "Rendering Latency (99%)",
      "range": true,
      "refId": "D"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "editorMode": "code",
      "expr": "histogram_quantile(1.0, sum by(le) (rate(rendering_latency_milliseconds_bucket{device_id=~\"$device|$tablet\"}[${interval}])))",
      "hide": false,
      "instant": false,
      "legendFormat": "Rendering Latency MAX",
      "range": true,
      "refId": "C"
    }
  ],
  "datasource": {
    "type": "prometheus",
    "uid": "grafanacloud-prom"
  },
  "interval": "15s",
  "options": {
    "tooltip": {
      "mode": "single",
      "sort": "none",
      "hideZeros": false
    },
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom",
      "calcs": []
    }
  }
}
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were. NO

  • Did you follow any online instructions? If so, what is the URL? NO

Hi @toon2 ,

After analyzing the issue, I believe I have identified the underlying problem. Please find below the recommended steps that may help resolve it

Step 1. Start Prometheus
Ensure that the Prometheus server is up and running.

Step 2. Integrate Prometheus with Grafana
Step 3. Create a custom variable.


Step 4. Create a Panel and Write the Query

go_gc_duration_seconds_sum

Final Output :-

Note: I implemented this solution using Prometheus data. As you can see in the final output, there is no gap at the start or end of the panel.

In your case, any gaps might be caused by one of the following reasons:

  • No data is available for certain time ranges.
  • There is a mismatch between the data timestamps and the Grafana time frame.

Hi @toon2
Just checking in—did this solution resolve your issue, or are you still facing the same problem?

Hi @infofcc3 ,

Thanks for the reply and clarification. It did not resolve my issue. I think it lies in the transformation of the the variables. I use these variables to do a transformation to filter in between.

these do not give the same results if the time range filter is set on for example -1h (see screenshots). here it shows the last data if the time filters are used. but these are essentially the same right? Its like if you are converting the $__from $__to with a variables the timestamps runs behind?

with variables filters:

with time filters:

thanks!

Could you please provide sample (dummy) data that can be used to implement the problem, along with the expected output for reference?

The issue lies in the updating of the custom variables, so the dates $start_date and $end_date are outdated when a time filter of last x minutes is used. See at the end for the dummy data (time range set on last 15 minutes).

when the time filter is not set:. the data runs until 8:46

screenshot when the time filter is set with the custom variables. the data only runs until 8:42. To solve the variables has to be updated regularly.

By switching the type to query (results), it can update on the time range changes. That fixes the issue! the first screenshot is the query type variable setting and 2nd the data filtered with the variables to $end_date_query. This shows the same results as without the filtering, which was the goal!

Dummy data

Time packet loss
2025-08-21 08:31:30 0.302%
2025-08-21 08:31:45 0.300%
2025-08-21 08:32:00 0.299%
2025-08-21 08:32:15 0.297%
2025-08-21 08:32:30 0.296%
2025-08-21 08:32:45 0.295%
2025-08-21 08:33:00 0.293%
2025-08-21 08:33:15 0.292%
2025-08-21 08:33:30 0.294%
2025-08-21 08:33:45 0.293%
2025-08-21 08:34:00 0.291%
2025-08-21 08:34:15 0.290%
2025-08-21 08:34:30 0.289%
2025-08-21 08:34:45 0.287%
2025-08-21 08:35:00 0.286%
2025-08-21 08:35:15 0.285%
2025-08-21 08:35:30 0.284%
2025-08-21 08:35:45 0.282%
2025-08-21 08:36:00 0.281%
2025-08-21 08:36:15 0.280%
2025-08-21 08:36:30 0.279%
2025-08-21 08:36:45 0.278%
2025-08-21 08:37:00 0.276%
2025-08-21 08:37:15 0.275%
2025-08-21 08:37:30 0.274%
2025-08-21 08:37:45 0.273%
2025-08-21 08:38:00 0.272%
2025-08-21 08:38:15 0.270%
2025-08-21 08:38:30 0.269%
2025-08-21 08:38:45 0.268%
2025-08-21 08:39:00 0.267%
2025-08-21 08:39:15 0.266%
2025-08-21 08:39:30 0.265%
2025-08-21 08:39:45 0.264%
2025-08-21 08:40:00 0.263%
2025-08-21 08:40:15 0.262%
2025-08-21 08:40:30 0.261%
2025-08-21 08:40:45 0.260%
2025-08-21 08:41:00 0.259%
2025-08-21 08:41:15 0.257%
2025-08-21 08:41:30 0.256%
2025-08-21 08:41:45 0.255%
2025-08-21 08:42:00 0.254%
2025-08-21 08:42:15 0.253%
2025-08-21 08:42:30 0.252%
2025-08-21 08:42:45 0.251%
2025-08-21 08:43:00 0.250%
2025-08-21 08:43:15 0.250%
2025-08-21 08:43:30 0.249%
2025-08-21 08:43:45 0.248%
2025-08-21 08:44:00 0.247%
2025-08-21 08:44:15 0.246%
2025-08-21 08:44:30 0.245%
2025-08-21 08:44:45 0.244%
2025-08-21 08:45:00 0.243%
2025-08-21 08:45:15 0.242%
2025-08-21 08:45:30 0.241%
2025-08-21 08:45:45 0.240%
2025-08-21 08:46:00 0.239%
2025-08-21 08:46:15 0.242%
2025-08-21 08:46:30 0.241%
1 Like