victorialogs-datasource icon indicating copy to clipboard operation
victorialogs-datasource copied to clipboard

incorrect interpolating query with variable inside the reg exp

Open frli4797 opened this issue 1 month ago • 1 comments

Describe the bug

When using a query like _time:16h {host=~"(?i)$host",job="rsyslog",level=~"(error|warning|critical)"} an error message is generated and nothing is returned by the query.

error from datasource: cannot parse query [_time:16h {host=~"(?i)"hostname"",job="rsyslog",level=~"(error|warning|critical)"} | sort by (_time) desc]: unexpected token "hostname" in _stream filter after "host=~\"(?i)\""; want 'or', 'and', '}' or ','; context: [_time:16h {host=~"(?i)"hostname]

Running the query in vm-ui works fine, given that the variable is replaced with a valid hostname.

To Reproduce

Create a dashboard widget for a query like _time:16h {host=~"(?i)$host",job="rsyslog",level=~"(error|warning|critical)"}

Error is thrown

Versions of VictoriaLogs datasource and VictoriaLogs backend

Version: victoria-logs-20251114-183126-tags-v1.38.0-0-g83b6b92169 Plugin version: 0.21.4 Grafana: v12.2.1

Link to dashboard in Victoria Metrics

No response

Please provide dashboard JSON if it is possible

{
  "id": 157,
  "type": "logs",
  "title": "Syslog errors",
  "gridPos": {
    "x": 0,
    "y": 5,
    "h": 5,
    "w": 21
  },
  "fieldConfig": {
    "defaults": {},
    "overrides": []
  },
  "pluginVersion": "12.2.1",
  "targets": [
    {
      "datasource": {
        "type": "victoriametrics-logs-datasource",
        "uid": "ce80jyaoi1tz4b"
      },
      "editorMode": "code",
      "expr": "_time:16h {host=~\"(?i)$host\",job=\"rsyslog\",level=~\"(error|warning|critical)\"} ",
      "hide": false,
      "queryType": "instant",
      "refId": "A"
    }
  ],
  "datasource": {
    "type": "victoriametrics-logs-datasource",
    "uid": "ce80jyaoi1tz4b"
  },
  "interval": "1m",
  "options": {
    "showTime": true,
    "showLabels": false,
    "showCommonLabels": false,
    "wrapLogMessage": true,
    "prettifyLogMessage": false,
    "enableLogDetails": true,
    "enableInfiniteScrolling": false,
    "dedupStrategy": "none",
    "sortOrder": "Descending"
  },
  "timeFrom": "16h",
  "hideTimeOverride": false,
  "links": [
    {
      "title": "Details",
      "url": "http://metrics.domain.com/d/ddqxdmho6msjke/log-details?orgId=1&var-host=$host&var-job=rsyslog&var-level=critical&var-level=error&var-level=warning"
    }
  ]
}

Additional information

No response

frli4797 avatar Nov 17 '25 08:11 frli4797

Worked previously on plugin version: 0.21.0

frli4797 avatar Nov 17 '25 08:11 frli4797

@frli4797 The issue was fixed in the v0.22.3 plugin version. Close the issue as fixed. If you find any problems, feel free to reopen the issue.

arturminchukov avatar Dec 02 '25 06:12 arturminchukov