-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Add regex filtering support for domains on the Query Log #1611
Conversation
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/option-to-ignore-domains-from-appearing-in-the-query-log/6319/68 |
There are two related endpoints |
My log is full of errors 023-08-02 21:19:35.597 [31064M] INFO: ########## FTL started on nanopi! ##########
2023-08-02 21:19:35.597 [31064M] INFO: FTL branch: new/queryLogRegex
2023-08-02 21:19:35.597 [31064M] INFO: FTL version: vDev-d3a6a9d
2023-08-02 21:19:35.597 [31064M] INFO: FTL commit: d3a6a9d2
2023-08-02 21:19:35.597 [31064M] INFO: FTL date: 2023-08-01 16:31:35 +0200
2023-08-02 21:19:35.597 [31064M] INFO: FTL user: pihole
2023-08-02 21:19:35.598 [31064M] INFO: Compiled for linux/arm64/v8 (compiled on CI) using cc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924
2023-08-02 21:19:35.604 [31064M] WARNING: Failed to open /etc/pihole/config_backups/pihole.toml.13 for reading: Permission denied
2023-08-02 21:19:35.637 [31064M] INFO: Writing config file
2023-08-02 21:19:35.667 [31064M] ERR: Cannot open /etc/pihole/custom.list for writing, unable to update custom.list: Permission denied
2023-08-02 21:19:35.675 [31064M] INFO: PID of FTL process: 31064
2023-08-02 21:19:35.683 [31064M] INFO: Database version is 13
2023-08-02 21:19:35.687 [31064M] INFO: Database successfully initialized
2023-08-02 21:19:35.737 [31064M] ERR: SQLite3 message: table query_storage has 11 columns but 12 values were supplied in "INSERT INTO query_storage SELECT * FROM disk.query_storage WHERE timestamp >= ?" (1)
2023-08-02 21:19:35.739 [31064M] ERR: import_queries_from_disk(): SQL error prepare: SQL logic error
2023-08-02 21:19:35.739 [31064M] INFO: Parsing queries in database
2023-08-02 21:19:35.743 [31064M] INFO: Imported 0 queries from the long-term database
2023-08-02 21:19:35.744 [31064M] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:19:35.744 [31064M] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:19:35.744 [31064M] INFO: -> Total DNS queries: 0
2023-08-02 21:19:35.744 [31064M] INFO: -> Cached DNS queries: 0
2023-08-02 21:19:35.745 [31064M] INFO: -> Forwarded DNS queries: 0
2023-08-02 21:19:35.745 [31064M] INFO: -> Blocked DNS queries: 0
2023-08-02 21:19:35.745 [31064M] INFO: -> Unknown DNS queries: 0
2023-08-02 21:19:35.745 [31064M] INFO: -> Unique domains: 0
2023-08-02 21:19:35.746 [31064M] INFO: -> Unique clients: 0
2023-08-02 21:19:35.746 [31064M] INFO: -> Known forward destinations: 0
2023-08-02 21:19:35.766 [31064M] INFO: listening on 0.0.0.0 port 53
2023-08-02 21:19:35.768 [31064M] INFO: listening on :: port 53
2023-08-02 21:19:35.782 [31064M] INFO: PID of FTL process: 31064
2023-08-02 21:19:35.785 [31064M] INFO: FTL is running as user pihole (UID 999)
2023-08-02 21:19:35.798 [31064M] INFO: Blocking status is enabled
2023-08-02 21:19:35.900 [31064/T31066] INFO: Compiled 1 allow and 2 deny regex for 0 client in 6.0 msec
2023-08-02 21:19:37.141 [31064/T31072] WARNING: API: Unauthorized
2023-08-02 21:19:37.141 [31064/T31071] WARNING: API: Unauthorized
2023-08-02 21:20:00.062 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:20:00.067 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:21:00.095 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:21:00.095 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:22:00.138 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:22:00.145 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:23:00.148 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:23:00.153 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:24:00.095 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:24:00.100 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:25:00.100 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:25:00.106 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:26:00.050 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:26:00.055 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:27:00.128 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:27:00.133 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:28:00.077 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:28:00.081 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:29:00.064 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:29:00.065 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:30:00.185 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:30:00.189 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:31:00.095 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:31:00.100 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:31:47.611 [31064/T31071] WARNING: API: Not found (/api/docs/specs/action.yaml)
2023-08-02 21:32:00.088 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:32:00.093 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:33:00.073 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:33:00.080 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:34:00.013 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:34:00.013 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error
2023-08-02 21:35:00.073 [31064/T31066] ERR: SQLite3 message: statement aborts at 4: [ATTACH ? AS ?] database disk is already in use (1)
2023-08-02 21:35:00.077 [31064/T31066] ERR: attach_database(): Failed to attach database: SQL logic error |
This has been discussed in https://discourse.pi-hole.net/t/option-to-ignore-domains-from-appearing-in-the-query-log/6319/65 and following comments. It seems that this is not wanted to be part of the Top Lists. But this can for sure be further discussed (but maybe addressed in a separate PR?).
All the errors come from
We have #1615 that tries to avoid the following errors but it will not always succeed. The root cause is that you've tried the |
…option webserver.api.excludeRegex) Signed-off-by: DL6ER <[email protected]>
Rebased on latest |
d3a6a9d
to
d37c0d1
Compare
No need to rebase this PR |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
Signed-off-by: DL6ER <[email protected]>
@PromoFaux You are right, I will adjust the example regex. We need to double-backslash the
|
…e TOML file Signed-off-by: DL6ER <[email protected]>
754dee3
to
c89a239
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
What I suggested above is now implemented:
|
Sorry for the delay. So, I now have the below in my excludeClients The output is as follows: I tried various permutations with and without quotes and nothing seemed to make any difference. pihole-FTL --config webserver.api.excludeClients Neither of these appeared to mask these domains in the query log: |
Wait, |
Signed-off-by: DL6ER <[email protected]>
What you actually found was a bug appearing when you have multiple regular expressions - in your case I did just push a fix for this. I think this will also solve @martinconroy's observation:
It didn't happen all the time so I missed this before. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: DL6ER <[email protected]>
Conflicts have been resolved. |
It did! Thanks for your awesome support on this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you have large, identical codeblocks in stats.c
and queries.c
where you get the regex from the config, check for validity and compile the regex.
Would it increase readability if you factor this part out and re-use it to decrease code duplicity?
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Something is not right
|
It can be triggert when more then one client regex is added and the web interfaced accessed. |
Signed-off-by: DL6ER <[email protected]>
Ah thanks, this is a clear referencing error that should be solved by the most recent commit. It was introduced by me factoring out this into a subroutine which is now accessing the regex as pointer variable and |
@martinconroy Please go back to |
Thanks @DL6ER for all your help making this an even better product! |
|
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: |
What does this implement/fix?
Add regex filtering support for domains on the Query Log (new config optionwebserver.api.excludeRegex
accepting an array of strings).updated description: Add regex filtering support for domains on the Query Log as well as the "Top Items" tables on the dashboard. This is implemented by offering regex support for existing
webserver.api.excludeClients
andwebserver.api.excludeDomains
settings.This implements a highly upvoted Discourse feature request (see comment below).
Related issue or feature (if applicable): N/A
Pull request in docs with documentation (if applicable): TBD
By submitting this pull request, I confirm the following:
git rebase
)Checklist:
developmental
branch.