grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
65.12k stars 12.15k forks source link

Time Series: Logarithmic scale option crashing panel #86819

Open nmarrs opened 6 months ago

nmarrs commented 6 months ago

The logarithmic scale option is crashing the attached panel. We need to investigate potential causes on why this is occurring. The runtime error seems to be occurring inside of the uplot library.

https://github.com/grafana/grafana/assets/22381771/96cd8c84-b0fa-49a0-82f4-a31525761e96

repro-panel-dashboard.txt

Error message - there is also a noticeable lag / JS loop freeze when trying to switch to the logarithmic option

uPlot.esm.js:1468 Uncaught RangeError: Invalid array length
    at Array.push (<anonymous>)
    at Object.logAxisSplits [as splits] (uPlot.esm.js:1468:1)
    at uPlot.esm.js:4386:1
    at Array.forEach (<anonymous>)
    at axesCalc (uPlot.esm.js:4351:1)
    at convergeSize (uPlot.esm.js:3291:1)
    at _commit (uPlot.esm.js:4666:1)

Original report in internal slack

leeoniya commented 6 months ago

probably the fact that stacking/100% setting forces a 0-1 axis range, and 0 cannot exist on a log axis, so it crashes while trying to find the ticks to place on the axis.

this is a pretty bizarre combo of settings to use. having a stacked graph (normal or %) with a log y axis will give you unintelligible nonsense. when stacking we should ignore the scale distribution setting and always use linear.

smaller repro:

stacking-log-scale-crash.json ```json { "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": 1034, "links": [], "panels": [ { "datasource": { "type": "grafana-testdata-datasource", "uid": "PD8C576611E62080A" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 26, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "percent" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 16, "w": 15, "x": 0, "y": 0 }, "id": 1, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "single", "sort": "none" } }, "targets": [ { "datasource": { "type": "grafana-testdata-datasource", "uid": "PD8C576611E62080A" }, "refId": "A", "scenarioId": "csv_metric_values", "stringInput": "5,100" }, { "datasource": { "type": "grafana-testdata-datasource", "uid": "PD8C576611E62080A" }, "refId": "B", "scenarioId": "csv_metric_values", "stringInput": "100,5" } ], "title": "Panel Title", "type": "timeseries" } ], "schemaVersion": 39, "tags": [], "templating": { "list": [] }, "time": { "from": "now-6h", "to": "now" }, "timeRangeUpdatedDuringEditOrView": false, "timepicker": {}, "timezone": "browser", "title": "stacking-log-scale-crash", "uid": "cdjnth3uwyghsc", "version": 3, "weekStart": "" } ```