|
| 1 | +name: crowdsecurity/supavisor-logs |
| 2 | +description: "Parse Supavisor connection pooler logs for authentication failures" |
| 3 | +filter: "evt.Parsed.program == 'supavisor'" |
| 4 | +onsuccess: next_stage |
| 5 | +debug: false |
| 6 | + |
| 7 | +# Supavisor uses Elixir Logger format with metadata |
| 8 | +# Real log example: |
| 9 | +# 18:38:17.778 project=dev_tenant user=postgres region=local mode=transaction type=single app_name=psql peer_ip=123.123.123.123 [error] ClientHandler: Exchange error: "Wrong password" when method :auth_query |
| 10 | +pattern_syntax: |
| 11 | + SUPAVISOR_TS: '%{TIME:timestamp}\.%{INT:timestamp_ms}' |
| 12 | + SUPAVISOR_LEVEL: '\[%{WORD:log_level}\]' |
| 13 | + SUPAVISOR_META_FULL: 'project=%{DATA:project}\s+user=%{DATA:db_user}\s+region=%{DATA:region}\s+mode=%{DATA:pool_mode}\s+type=%{DATA:pool_type}\s+app_name=%{DATA:app_name}\s+peer_ip=%{IP:source_ip}' |
| 14 | + SUPAVISOR_META_PARTIAL: 'region=%{DATA:region}' |
| 15 | + |
| 16 | +nodes: |
| 17 | + - grok: |
| 18 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_FULL}\s+%{SUPAVISOR_LEVEL}\s+ClientHandler:\s+Exchange error:\s+"Wrong password"%{GREEDYDATA}' |
| 19 | + apply_on: message |
| 20 | + statics: |
| 21 | + - meta: log_type |
| 22 | + value: supavisor_auth_fail |
| 23 | + - meta: service |
| 24 | + value: supavisor |
| 25 | + - meta: source_ip |
| 26 | + expression: evt.Parsed.source_ip |
| 27 | + - target: evt.StrTime |
| 28 | + expression: evt.Parsed.timestamp |
| 29 | + |
| 30 | + - grok: |
| 31 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_FULL}\s+%{SUPAVISOR_LEVEL}\s+ClientHandler:\s+Tenant is not allowed to connect without SSL%{GREEDYDATA}' |
| 32 | + apply_on: message |
| 33 | + statics: |
| 34 | + - meta: log_type |
| 35 | + value: supavisor_ssl_required |
| 36 | + - meta: service |
| 37 | + value: supavisor |
| 38 | + - meta: source_ip |
| 39 | + expression: evt.Parsed.source_ip |
| 40 | + - target: evt.StrTime |
| 41 | + expression: evt.Parsed.timestamp |
| 42 | + |
| 43 | + - grok: |
| 44 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_FULL}\s+%{SUPAVISOR_LEVEL}\s+ClientHandler:\s+Exchange error:%{GREEDYDATA:error_detail}' |
| 45 | + apply_on: message |
| 46 | + statics: |
| 47 | + - meta: log_type |
| 48 | + value: supavisor_auth_fail |
| 49 | + - meta: service |
| 50 | + value: supavisor |
| 51 | + - meta: source_ip |
| 52 | + expression: evt.Parsed.source_ip |
| 53 | + - target: evt.StrTime |
| 54 | + expression: evt.Parsed.timestamp |
| 55 | + |
| 56 | + - grok: |
| 57 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_FULL}\s+%{SUPAVISOR_LEVEL}\s+%{GREEDYDATA:error_message}' |
| 58 | + apply_on: message |
| 59 | + filter: "evt.Parsed.log_level == 'error'" |
| 60 | + statics: |
| 61 | + - meta: log_type |
| 62 | + value: supavisor_error_with_ip |
| 63 | + - meta: service |
| 64 | + value: supavisor |
| 65 | + - meta: source_ip |
| 66 | + expression: evt.Parsed.source_ip |
| 67 | + - target: evt.StrTime |
| 68 | + expression: evt.Parsed.timestamp |
| 69 | + |
| 70 | + - grok: |
| 71 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_PARTIAL}\s+%{SUPAVISOR_LEVEL}\s+ClientHandler:\s+Client startup message error:\s+:bad_startup_payload' |
| 72 | + apply_on: message |
| 73 | + statics: |
| 74 | + - meta: log_type |
| 75 | + value: supavisor_bad_startup |
| 76 | + - meta: service |
| 77 | + value: supavisor |
| 78 | + - target: evt.StrTime |
| 79 | + expression: evt.Parsed.timestamp |
| 80 | + |
| 81 | + - grok: |
| 82 | + pattern: '%{SUPAVISOR_TS}\s+%{SUPAVISOR_META_PARTIAL}\s+%{SUPAVISOR_LEVEL}\s+ClientHandler:\s+User not found:%{GREEDYDATA:enum_detail}' |
| 83 | + apply_on: message |
| 84 | + statics: |
| 85 | + - meta: log_type |
| 86 | + value: supavisor_user_not_found |
| 87 | + - meta: service |
| 88 | + value: supavisor |
| 89 | + - target: evt.StrTime |
| 90 | + expression: evt.Parsed.timestamp |
| 91 | + |
| 92 | +statics: |
| 93 | + - meta: service |
| 94 | + value: supavisor |
0 commit comments