Skip to content

Instantly share code, notes, and snippets.

@kiwicopple
Created September 21, 2021 06:49
Show Gist options
  • Save kiwicopple/66572da655c8f45a840d99db37e9684e to your computer and use it in GitHub Desktop.
Save kiwicopple/66572da655c8f45a840d99db37e9684e to your computer and use it in GitHub Desktop.
Filter Postgres executions using Vector
version: "3.9"
services:
vector:
image: timberio/vector:0.16.1-debian
ports:
- "8383:8383"
volumes:
- ./vector.toml:/etc/vector/vector.toml:ro
- ./:/logs:z
postgres:
image: supabase/postgres
restart: always
ports:
- 5432:5432
command: postgres -c logging_collector=on -c log_destination=stderr,csvlog -c log_directory=/logs -c log_statement='all'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./:/logs:z
environment:
POSTGRES_DB: postgres
POSTGRES_USER: docker
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: postgres
[sources.pg_query_log]
type = "file"
ignore_older_secs = 600
include = [ "/logs/postgresql.log" ]
read_from = "beginning"
[transforms.filter_logs]
type = "filter"
inputs = [ "pg_query_log" ]
condition = 'contains!(.message, "execute")'
[sinks.send_to_file]
type = "file"
inputs = [ "filter_logs" ]
idle_timeout_secs = 30
compression = "none"
path = "/logs/vector-formatted.log"
[sinks.send_to_file.encoding]
codec = "text"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment