-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PostgreSQL integration to support logs in CSV format (#747)
Import latest changes in Beats. Including support for logs in CSV format. * Import pipelines and test files from Beats. * Update README. * Add docker deployment and system tests. * Add missing ECS fields to make tests pass.
- Loading branch information
Showing
111 changed files
with
9,883 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ARG SERVICE_VERSION=${SERVICE_VERSION:-9.5.3} | ||
FROM postgres:${SERVICE_VERSION} | ||
COPY docker-entrypoint-initdb.d /docker-entrypoint-initdb.d | ||
HEALTHCHECK --interval=10s --retries=6 CMD psql -h localhost -U postgres -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '2.3' | ||
services: | ||
postgresql: | ||
# Commented out `image:` below until we have a process to refresh the hosted images from | ||
# Dockerfiles in this repo. Until then, we build the image locally using `build:` below. | ||
# image: docker.elastic.co/integrations-ci/beats-postgresql:${POSTGRESQL_VERSION:-9.5.3}-1 | ||
build: . | ||
ports: | ||
- 5432 | ||
volumes: | ||
- ${SERVICE_LOGS_DIR}/postgresql:/var/log/postgresql |
22 changes: 22 additions & 0 deletions
22
packages/postgresql/_dev/deploy/docker/docker-entrypoint-initdb.d/0-enable-logging.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
chmod a+wx /var/log/postgresql | ||
|
||
cat <<-EOF >> $PGDATA/postgresql.conf | ||
# Enable some log facilities. | ||
log_duration = 'on' | ||
log_connections = 'on' | ||
log_disconnections = 'on' | ||
# Ensure that statements are logged, with their durations. | ||
log_statement = 'none' | ||
log_min_duration_statement = 0 | ||
# Give agent read permissions. In NO case for production usage. | ||
log_file_mode = '0666' | ||
# Try to imitate logging behaviour in Debian/Ubuntu, but there the logging collector | ||
# is not used. | ||
logging_collector = 'on' | ||
log_directory = '/var/log/postgresql' | ||
log_line_prefix = '%m [%p] %q%u@%d ' | ||
EOF |
6 changes: 6 additions & 0 deletions
6
...s/postgresql/_dev/deploy/docker/docker-entrypoint-initdb.d/1-enable-pg_stat_statements.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
cat <<-EOF >> $PGDATA/postgresql.conf | ||
shared_preload_libraries = 'pg_stat_statements' | ||
pg_stat_statements.max = 10000 | ||
pg_stat_statements.track = all | ||
EOF |
1 change: 1 addition & 0 deletions
1
...l/_dev/deploy/docker/docker-entrypoint-initdb.d/2-create-extension-pg_stat_statements.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create extension pg_stat_statements; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variants: | ||
v9_5_3: | ||
SERVICE_VERSION: 9.5.3 | ||
default: v9_5_3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/postgresql/data_stream/activity/_dev/test/system/test-default-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vars: | ||
hosts: | ||
- postgres://{{Hostname}}:{{Port}}?sslmode=disable | ||
username: postgres | ||
password: postgres | ||
data_stream: | ||
vars: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/postgresql/data_stream/bgwriter/_dev/test/system/test-default-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vars: | ||
hosts: | ||
- postgres://{{Hostname}}:{{Port}}?sslmode=disable | ||
username: postgres | ||
password: postgres | ||
data_stream: | ||
vars: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/postgresql/data_stream/database/_dev/test/system/test-default-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vars: | ||
hosts: | ||
- postgres://{{Hostname}}:{{Port}}?sslmode=disable | ||
username: postgres | ||
password: postgres | ||
data_stream: | ||
vars: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/postgresql/data_stream/log/_dev/test/pipeline/test-postgresql-10-default.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
2020-04-15 12:02:55.244 CEST [23922] LOG: database system was shut down at 2020-04-15 12:02:52 CEST | ||
2020-04-15 12:02:55.247 CEST [23920] LOG: database system is ready to accept connections | ||
2020-04-15 12:04:45.416 CEST [24981] FATAL: password authentication failed for user "root" | ||
2020-04-15 12:04:45.416 CEST [24981] DETAIL: Role "root" does not exist. | ||
Connection matched pg_hba.conf line 80: "local all all md5" | ||
2020-04-15 12:04:45.416 CEST [24981] LOG: could not send data to client: Broken pipe | ||
2020-04-15 12:06:36.719 CEST [25143] ERROR: syntax error at or near "l" at character 1 | ||
2020-04-15 12:56:29.569 CEST [25143] STATEMENT: SELECT al.id, al.tenant_id, al.created_by_id, al.create_ip, al.audit_date, al.audit_table, al.entity_id, al.entity_name, al.reason_for_change, al.audit_log_event_type_id, | ||
aet.lookup_code, al.old_value, al.new_value, al.event_crf_id, al.event_crf_version_id, al.study_id, al.study_site_id, ss.rc_oid, al.subject_id, s.unique_identifier, | ||
al.study_event_id, sed.name AS studyEventName, al.user_id, al.value_index, al.crf_version_id, al.global_logs, cv.version_name, crf.id AS crfId, crf.name AS crfName | ||
FROM public.rc_audit_log_events AS al | ||
LEFT JOIN rc_crf_versions AS cv ON cv.id=al.crf_version_id | ||
LEFT JOIN rc_crfs AS crf ON crf.id=cv.crf_id | ||
LEFT JOIN ad_lookup_codes AS aet ON aet.id=al.audit_log_event_type_id | ||
LEFT JOIN rc_study_sites AS ss ON ss.id=al.study_site_id | ||
LEFT JOIN rc_subjects AS s ON s.id=al.subject_id | ||
LEFT JOIN rc_study_events AS se ON se.id=al.study_event_id | ||
LEFT JOIN rc_study_event_definitions AS sed ON sed.id=se.study_event_definition_id | ||
WHERE al.tenant_id=$1 AND al.study_id=$2 AND aet.lookup_code IN ($3, $4, $5, $6) AND al.audit_date >= $7 ORDER BY al.id DESC limit $8 | ||
; |
4 changes: 4 additions & 0 deletions
4
...s/postgresql/data_stream/log/_dev/test/pipeline/test-postgresql-10-default.log-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dynamic_fields: | ||
event.ingested: ".*" | ||
multiline: | ||
first_line_pattern: '^\d{4}-\d{2}-\d{2} ' |
Oops, something went wrong.