Skip to content

Commit

Permalink
docs: link external docs for target format
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Aug 27, 2024
1 parent dbba2fa commit 019fe16
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,24 +648,24 @@ in Excel or OpenOffice Calc) or MySQL/MariaDB database.

You can select one of following query log types:

- `mysql` - log each query in the external MySQL/MariaDB database
- `postgresql` - log each query in the external PostgreSQL database
- `timescale` - log each query in the external Timescale database
- `csv` - log into CSV file (one per day)
- `csv-client` - log into CSV file (one per day and per client)
- `console` - log into console output
- `none` - do not log any queries
- `mysql`: log each query in the external MySQL/MariaDB database
- `postgresql`: log each query in the external PostgreSQL database
- `timescale`: log each query in the external Timescale database
- `csv`: log into CSV file (one per day)
- `csv-client`: log into CSV file (one per day and per client)
- `console`: log into console output
- `none`: do not log any queries

### Query log fields

You can choose which information from processed DNS request and response should be logged in the target system. You can define one or more of following fields:

- `clientIP` - origin IP address from the request
- `clientName` - resolved client name(s) from the origins request
- `responseReason` - reason for the response (e.g. from which upstream resolver), response type and code
- `responseAnswer` - returned DNS answer
- `question` - DNS question from the request
- `duration` - request processing time in milliseconds
- `clientIP`: origin IP address from the request
- `clientName`: resolved client name(s) from the origins request
- `responseReason`: reason for the response (e.g. from which upstream resolver), response type and code
- `responseAnswer`: returned DNS answer
- `question`: DNS question from the request
- `duration`: request processing time in milliseconds

!!! hint
If not defined, blocky will log all available information
Expand All @@ -687,8 +687,26 @@ Configuration parameters:
Please ensure, that the log directory is writable or database exists. If you use docker, please ensure, that the directory is properly
mounted (e.g. volume)

example for CSV format with limited logging information
### Database URLs

To connect to a database, you must provide a URL like value for `target`. The exact format and supported parameters depends on the DB type.
Parsing is handled not by Blocky, but third-party libraries, therefore the documentation is external:

- `mysql`: see Go MySQL driver [Data Source Name](https://github.com/go-sql-driver/mysql?tab=readme-ov-file#dsn-data-source-name)
Basic format: `[username[:password]@][protocol[(host:port)]]/dbname[?param1=value1&...&paramN=valueN]`
Example: `username:password@tcp(localhost:3306)/blocky_query_log?timeout=15s`

- `postgresql`: see [pgx.ParseConfig](https://pkg.go.dev/github.com/jackc/pgx/v5/pgconn#ParseConfig)
Basic format: `postgres://username:password@host:port/dbname?param=value`
Example: `postgres://username:password@localhost:5432/blocky_query_log?param=value`
Note that password is recommended to be configured via the `PGPASSFILE` env var.

- `timescale`: Same as `postgresql`

### Examples

!!! example
**CSV format with limited logging information**

```yaml
queryLog:
Expand All @@ -701,13 +719,13 @@ example for CSV format with limited logging information
flushInterval: 30s
```

example for Database
!!! example
**MySQL Database**

```yaml
queryLog:
type: mysql
target: db_user:db_password@tcp(db_host_or_ip:3306)/db_user?charset=utf8mb4&parseTime=True&loc=Local
target: username:password@tcp(localhost:3306)/blocky_query_log?charset=utf8mb4&parseTime=True&loc=Local&timeout=15s
logRetentionDays: 7
```

Expand Down

0 comments on commit 019fe16

Please sign in to comment.