Skip to content

Samba Audit Grafana dashboard filters do not work correctly #8226

Open

Description

@nrauso

Steps to reproduce

  1. Install and configure Samba AD on NethServer 8;

  2. Create a couple of users and a couple of shares and do some operations;

  3. Enable Grafana, open its UI and navigate to Dashboards → modules → Samba Audit search;

  4. Select a Samba share using the Share filter;

  5. The query fails with the following PostgreSQL error:

    db query error: ERROR: column "myshare" does not exist
    (SQLSTATE 42703)
    
  6. Select a domain user, such as NETHE\goofy, using the User filter.

  7. 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 $username

This 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 DESC

The 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.0
  • ns8-metrics:1.5.1

Activity

  1. added theissue type on Oct 12, 2026
  2. DavidePrincipi commented on Oct 13, 2026

    @DavidePrincipi
    Member

    In Testing 3.5.1-dev.2

    Test case

    Check the bug is not reproducible with the Testing version

  3. removed their assignment
    on Oct 13, 2026
  4. self-assigned this
    on Oct 13, 2026
  5. DavidePrincipi commented on Oct 13, 2026

    @DavidePrincipi
    Member

    VERIFIED

  6. removed
    testingPackages are available from testing repositories
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    verifiedAll test cases were verified successfully

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions