Repository navigation
Samba Audit Grafana dashboard filters do not work correctly #8226
Description
Steps to reproduce
-
Install and configure Samba AD on NethServer 8;
-
Create a couple of users and a couple of shares and do some operations;
-
Enable Grafana, open its UI and navigate to Dashboards → modules → Samba Audit search;
-
Select a Samba share using the
Sharefilter; -
The query fails with the following PostgreSQL error:
db query error: ERROR: column "myshare" does not exist (SQLSTATE 42703) -
Select a domain user, such as
NETHE\goofy, using theUserfilter. -
With the original query, PostgreSQL returns:
db query error: ERROR: syntax error at or near "\" (SQLSTATE 42601)
Even after fixing SQL variable quoting, the user filter returns no results because PostgreSQL interprets \ as an escape character in LIKE patterns.
Expected behavior
All filters in the Samba Audit search dashboard should work correctly, including:
- Share
- User
- Address
- Result
- Protocol
- Operation
- Path
Domain usernames containing backslashes must be handled correctly.
The All option must continue to work for every filter.
Actual behavior
The dashboard SQL query interpolates Grafana variables without explicitly quoting their values.
For example:
AND share LIKE $share
AND username LIKE $usernameThis causes PostgreSQL errors when selecting specific values.
Additionally, PostgreSQL interprets backslashes as escape characters in LIKE patterns, preventing correct filtering of domain usernames.
Proposed fix
Use Grafana's ${variable:sqlstring} formatting to quote SQL string values correctly.
Add ESCAPE '' to the LIKE conditions to disable backslash escaping while preserving wildcard support.
The corrected query is:
SELECT
time AS DateTime,
share AS Share,
regexp_replace(path, '/srv/shares/' || share, '', '') AS Path,
username AS Username,
addr AS Address,
CASE
WHEN aux IS NOT NULL
AND aux <> '' THEN op || ' (' || aux || ')'
ELSE op
END AS Operation,
result AS Result,
proto AS Protocol
FROM
samba_audit
WHERE
$__timeFilter(time)
AND share LIKE ${share:sqlstring} ESCAPE ''
AND path LIKE ${path:sqlstring} ESCAPE ''
AND username LIKE ${username:sqlstring} ESCAPE ''
AND addr LIKE ${addr:sqlstring} ESCAPE ''
AND op LIKE ${op:sqlstring} ESCAPE ''
AND proto LIKE ${proto:sqlstring} ESCAPE ''
AND result LIKE ${result:sqlstring} ESCAPE ''
ORDER BY
time DESCThe fix has been tested successfully by editing the query directly in Grafana. All filters now work correctly, including domain usernames containing backslashes.
The fix should be applied to the dashboard's source definition to make it persistent across dashboard provisioning and application updates.
Components
ns8-samba:3.5.0ns8-metrics:1.5.1
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsVerified
Activity
DavidePrincipi commentedon Oct 13, 2026
In Testing 3.5.1-dev.2
Test case
Check the bug is not reproducible with the Testing version
DavidePrincipi commentedon Oct 13, 2026
VERIFIED