sudo cscli collections install crowdsecurity/apiscpInstalls 9 parsers and 56 scenarios, via PostgreSQL - Bruteforce Protection.
View ApisCP →sudo cscli parsers install crowdsecurity/pgsql-logsThen reload CrowdSec: sudo systemctl reload crowdsec
Sign in to see which of your engines run it →Hover a line or a note to see what each field does.
onsuccess: next_stagename: crowdsecurity/pgsql-logsdescription: "Parse PgSQL and PgBouncer logs"filter: "evt.Parsed.program in ['postgres', 'pgbouncer']"nodes:- grok:#pgsql 12pattern: '%{DATESTAMP:timestamp} %{WORD:zone} \[%{INT:PID}\] %{IP:source_ip} %{USERNAME:pgsql_user}@%{GREEDYDATA:pgsql_dbname} FATAL: %{WORD:auth_method} authentication failed for user "%{USERNAME:pgsql_target_user}"'apply_on: message- grok:#aws aurora#%{DATESTAMP:timestamp} %{WORD:zone}:%{IP:source_ip}\(%{INT:source_port}\):%{USERNAME:pgsql_user}@%{GREEDYDATA:pgsql_dbname}:\[%{INT:pid}\]:FATAL: password authentication failed for user "%{USERNAME:pgsql_target_user}"pattern: '%{DATESTAMP:timestamp} %{WORD:zone}:%{IP:source_ip}\(%{INT:source_port}\):%{USERNAME:pgsql_user}@%{GREEDYDATA:pgsql_dbname}:\[%{INT:pid}\]:FATAL: %{WORD:auth_method} authentication failed for user "%{USERNAME:pgsql_target_user}"'apply_on: message- grok:#pgbouncer authentication failedpattern: '%{TIMESTAMP_ISO8601:timestamp} %{WORD:zone} \[%{INT:PID}\] ERROR C-%{NOTSPACE:connection_id}: %{DATA:pgsql_dbname}/%{DATA:pgsql_target_user}@\[?%{IP:source_ip}\]?:%{INT:source_port} %{WORD:auth_method} authentication failed'apply_on: messagestatics:- meta: log_typevalue: pgsql_failed_auth- meta: auth_methodexpression: "evt.Parsed.auth_method"- meta: source_ipexpression: "evt.Parsed.source_ip"- meta: userexpression: "evt.Parsed.pgsql_target_user"- meta: dbexpression: "evt.Parsed.pgsql_dbname"- target: evt.StrTimeexpression: evt.Parsed.timestamp
Sign in to see the Security Engines that run this log parser, the version they run and whether it was modified locally.
PostgreSQL and PgBouncer failed authentication parser.
Supports PostgreSQL (v12+, AWS Aurora) as well as PgBouncer authentication failure formats (IPv4 and IPv6).
Warning: By default (at least on Debian with PostgreSQL 12), PostgreSQL logs do not contain the source IP, and log_line_prefix needs to be edited to contain %h (the remote host). This parser assumes the log_line_prefix is %m [%p] %h%q %u@%d (instead of the default %m [%p] %q%u@%d ).
Please note that the parser ignores the timezone written by postgres.
Example configuration for PostgreSQL log file in /etc/crowdsec/acquis.yaml:
1filenames:2 - /var/log/postgresql/postgresql-*.log3labels:4 type: postgres
Example configuration for PgBouncer log file in /etc/crowdsec/acquis.yaml:
1filenames:2 - /var/log/postgresql/pgbouncer.log3labels:4 type: pgbouncer
Note: Both type: pgbouncer and type: postgres are supported by this parser.
| Field | Description |
|---|---|
source_ip | Remote client IP address (IPv4 or IPv6) |
user | Database user being authenticated |
db | Target database name |
auth_method | Authentication method used |
log_type | Set to pgsql_failed_auth |