Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loki: Ad hoc filters not added to every query expression if label filters are used #75101

Closed
svennergr opened this issue Sep 19, 2023 · 0 comments · Fixed by #75152
Closed

Loki: Ad hoc filters not added to every query expression if label filters are used #75101

svennergr opened this issue Sep 19, 2023 · 0 comments · Fixed by #75152
Assignees
Labels
datasource/Loki internal for issues made by grafanistas type/bug

Comments

@svennergr
Copy link
Contributor

What happened?

When using a dashboard with adhoc filters and a loki query containing two metric queries and label filters, the ad hoc filter is only added to the last label filter.

What did you expect to happen?

Ad hoc filter is added to each query expression.

Did this work before?

Not sure.

How do we reproduce it?

  1. Basically go to https://obslogs.grafana-dev.net/d/aad3c33c-d51e-40bb-a4f1-0a44ad696780/loki-ad-hoc-filter-bug?orgId=1&var-query0=host%7C%3D%7Cappfelstrudel&editPanel=1&inspect=1&inspectTab=query and see that only the second expression has the host="apfelstrudel" label filter added

Is the bug inside a dashboard panel?

Key Value
Panel timeseries @ 10.2.0-60854 (7209e84)
Grafana 10.2.0-60854 (7209e84) // Cloud Pro
Panel debug snapshot dashboard
{
  "panels": [
    {
      "datasource": {
        "type": "grafana",
        "uid": "grafana"
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "linear",
            "barAlignment": 0,
            "lineWidth": 1,
            "fillOpacity": 0,
            "gradientMode": "none",
            "spanNulls": false,
            "insertNulls": false,
            "showPoints": "auto",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "axisLabel": "",
            "axisColorMode": "text",
            "axisShow": false,
            "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": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 13,
        "w": 15,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "legend": {
          "showLegend": false,
          "displayMode": "hidden",
          "placement": "right",
          "calcs": []
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "grafana",
            "uid": "grafana"
          },
          "queryType": "snapshot",
          "snapshot": []
        }
      ],
      "title": "Reproduced with embedded data",
      "type": "timeseries"
    },
    {
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 15,
        "y": 0
      },
      "id": 5,
      "options": {
        "content": "<table width=\"100%\">\n    <tr>\n      <th width=\"2%\">Panel</th>\n      <td >timeseries @ 10.2.0-60854 (7209e84c)</td>\n    </tr>\n    <tr>\n      <th>Queries</th>\n      <td>A[loki]</td>\n    </tr>\n    \n    <tr><th>Data</th><td> 0 frames, 0 fields, 0 rows </td></tr>\n    \n    <tr>\n      <th>Grafana</th>\n      <td>10.2.0-60854 (7209e84c) // Cloud Pro</td>\n    </tr>\n  </table>",
        "mode": "html"
      },
      "title": "Debug info",
      "type": "text"
    },
    {
      "id": 6,
      "title": "Original Panel JSON",
      "type": "text",
      "gridPos": {
        "h": 13,
        "w": 9,
        "x": 15,
        "y": 7
      },
      "options": {
        "content": "{\n  \"datasource\": {\n    \"type\": \"loki\",\n    \"uid\": \"fd70b5e0-86ff-4393-b0f0-beda694083c7\"\n  },\n  \"fieldConfig\": {\n    \"defaults\": {\n      \"custom\": {\n        \"drawStyle\": \"line\",\n        \"lineInterpolation\": \"linear\",\n        \"barAlignment\": 0,\n        \"lineWidth\": 1,\n        \"fillOpacity\": 0,\n        \"gradientMode\": \"none\",\n        \"spanNulls\": false,\n        \"insertNulls\": false,\n        \"showPoints\": \"auto\",\n        \"pointSize\": 5,\n        \"stacking\": {\n          \"mode\": \"none\",\n          \"group\": \"A\"\n        },\n        \"axisPlacement\": \"auto\",\n        \"axisLabel\": \"\",\n        \"axisColorMode\": \"text\",\n        \"axisShow\": false,\n        \"scaleDistribution\": {\n          \"type\": \"linear\"\n        },\n        \"axisCenteredZero\": false,\n        \"hideFrom\": {\n          \"tooltip\": false,\n          \"viz\": false,\n          \"legend\": false\n        },\n        \"thresholdsStyle\": {\n          \"mode\": \"off\"\n        }\n      },\n      \"color\": {\n        \"mode\": \"palette-classic\"\n      },\n      \"mappings\": [],\n      \"thresholds\": {\n        \"mode\": \"absolute\",\n        \"steps\": [\n          {\n            \"color\": \"green\",\n            \"value\": null\n          },\n          {\n            \"color\": \"red\",\n            \"value\": 80\n          }\n        ]\n      }\n    },\n    \"overrides\": []\n  },\n  \"gridPos\": {\n    \"h\": 12,\n    \"w\": 24,\n    \"x\": 0,\n    \"y\": 0\n  },\n  \"id\": 1,\n  \"options\": {\n    \"tooltip\": {\n      \"mode\": \"single\",\n      \"sort\": \"none\"\n    },\n    \"legend\": {\n      \"showLegend\": false,\n      \"displayMode\": \"hidden\",\n      \"placement\": \"right\",\n      \"calcs\": []\n    }\n  },\n  \"targets\": [\n    {\n      \"datasource\": {\n        \"type\": \"loki\",\n        \"uid\": \"fd70b5e0-86ff-4393-b0f0-beda694083c7\"\n      },\n      \"editorMode\": \"code\",\n      \"expr\": \"sum(rate({agent=\\\"promtail\\\"} |= `Mozilla` | logfmt | __error__=`` [$__auto])) / sum(rate({agent=\\\"promtail\\\"} | logfmt | __error__=``  [$__auto]))\",\n      \"queryType\": \"range\",\n      \"refId\": \"A\"\n    }\n  ],\n  \"title\": \"Mozilla per all promtail logs\",\n  \"type\": \"timeseries\"\n}",
        "mode": "code",
        "code": {
          "language": "json",
          "showLineNumbers": true,
          "showMiniMap": true
        }
      }
    },
    {
      "id": 3,
      "title": "Data from panel above",
      "type": "table",
      "datasource": {
        "type": "datasource",
        "uid": "-- Dashboard --"
      },
      "gridPos": {
        "h": 7,
        "w": 15,
        "x": 0,
        "y": 13
      },
      "options": {
        "showTypeIcons": true
      },
      "targets": [
        {
          "datasource": {
            "type": "datasource",
            "uid": "-- Dashboard --"
          },
          "panelId": 2,
          "withTransforms": true,
          "refId": "A"
        }
      ]
    }
  ],
  "schemaVersion": 37,
  "title": "Debug: Mozilla per all promtail logs // 2023-09-19 15:22:33",
  "tags": [
    "debug",
    "debug-timeseries"
  ],
  "time": {
    "from": "2023-09-19T13:22:32.233Z",
    "to": "2023-09-19T13:22:33.233Z"
  }
}

Environment (with versions)?

Grafana:
OS:
Browser:

Grafana platform?

None

Datasource(s)?

Loki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/Loki internal for issues made by grafanistas type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant