Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json logs #6600

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ executors:
SHARED_BUFFERS_SIZE: "1GB"
EFFECTIVE_CACHE_SIZE: "1GB"
STATS_TARGET: 100
FLOWDB_LOG_DEST: stderr
- image: bitnami/redis:latest
environment:
REDIS_PASSWORD: "fm_redis"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed
- FlowDB now triggers an ANALYZE on newly created cache tables to generate statistics rather than waiting for autovacuum
- FlowDB now produces JSON formatted logs by default. Set `FLOWDB_LOG_DEST=csvlog` for the old default behaviour.
- The logging destination of FlowDB can now be configured at init by setting the `FLOWDB_LOG_DEST` environment variable, valid options are `stderr`, `csvlog`, and `jsonlog`.


### Fixed

Expand Down
25 changes: 13 additions & 12 deletions docs/source/administrator/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ FlowDB is distributed as a docker container. To run it, you will need to provide

You may also provide the following environment variables:

| Variable name | Purpose | Default value |
|-----------------------------------| ------- | ------------- |
| CACHE_SIZE | Maximum size of the cache schema | 1 tenth of available space in pgdata directory |
| CACHE_PROTECTED_PERIOD | Amount of time to protect cache tables from being cleaned up | 86400 (24 hours) |
| CACHE_HALF_LIFE | Speed at which cache tables expire when not used | 1000 |
| MAX_CPUS | Maximum number of CPUs that may be used for parallelising queries | The greater of 1 or 1 less than all CPUs |
| SHARED_BUFFERS_SIZE | Size of shared buffers | 16GB |
| MAX_WORKERS | Maximum number of CPUs that may be used for parallelising one query | MAX_CPUS/2 |
| MAX_WORKERS_PER_GATHER | Maximum number of CPUs that may be used for parallelising part of one query | MAX_CPUS/2 |
| EFFECTIVE_CACHE_SIZE | Postgres cache size | 25% of total RAM |
| FLOWDB_ENABLE_POSTGRES_DEBUG_MODE | When set to TRUE, enables use of the [pgadmin debugger](https://www.pgadmin.org/docs/pgadmin4/4.13/debugger.html) | FALSE |
| MAX_LOCKS_PER_TRANSACTION | Controls the maximum number of locks one transaction can take, you may wish to reduce this on low-memory servers. | 36500 |
| Variable name | Purpose | Default value |
|-----------------------------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| CACHE_SIZE | Maximum size of the cache schema | 1 tenth of available space in pgdata directory |
| CACHE_PROTECTED_PERIOD | Amount of time to protect cache tables from being cleaned up | 86400 (24 hours) |
| CACHE_HALF_LIFE | Speed at which cache tables expire when not used | 1000 |
| MAX_CPUS | Maximum number of CPUs that may be used for parallelising queries | The greater of 1 or 1 less than all CPUs |
| SHARED_BUFFERS_SIZE | Size of shared buffers | 16GB |
| MAX_WORKERS | Maximum number of CPUs that may be used for parallelising one query | MAX_CPUS/2 |
| MAX_WORKERS_PER_GATHER | Maximum number of CPUs that may be used for parallelising part of one query | MAX_CPUS/2 |
| EFFECTIVE_CACHE_SIZE | Postgres cache size | 25% of total RAM |
| FLOWDB_ENABLE_POSTGRES_DEBUG_MODE | When set to TRUE, enables use of the [pgadmin debugger](https://www.pgadmin.org/docs/pgadmin4/4.13/debugger.html) | FALSE |
| MAX_LOCKS_PER_TRANSACTION | Controls the maximum number of locks one transaction can take, you may wish to reduce this on low-memory servers. | 36500 |
| FLOWDB_LOG_DEST | Controls the logging destination, may be be one of `stderr`, `jsonlog`, `csvlog`. | `jsonlog` |

However in most cases, the defaults will be adequate.

Expand Down
3 changes: 3 additions & 0 deletions flowdb.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ ENV FLOWAPI_FLOWDB_USER=flowapi
# Default location table
ENV LOCATION_TABLE=infrastructure.cells

# Default logging destination
ENV FLOWDB_LOG_DEST=jsonlog

#
# Copy file spinup build scripts to be execed.
#
Expand Down
9 changes: 9 additions & 0 deletions flowdb/bin/build/configurate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def bool_env(var):
if bool_env("FLOWDB_ENABLE_POSTGRES_DEBUG_MODE"):
preload_libraries.append("plugin_debugger")

possible_log_destinations = ["stderr", "jsonlog", "csvlog"]
log_destination = os.getenv("FLOWDB_LOG_DEST", "jsonlog").lower()
if log_destination not in possible_log_destinations:
raise ValueError(
f"Invalid log destination. Valid values for FLOWDB_LOG_DEST are {possible_log_destinations}"
)

with open("/docker-entrypoint-initdb.d/pg_config_template.conf") as fin:
config_file = fin.read().format(
cores=cores,
Expand All @@ -92,6 +99,8 @@ def bool_env(var):
stats_target=stats_target,
use_jit=use_jit,
max_locks=max_locks,
log_destination=log_destination,
collecter_on="on" if log_destination != "stderr" else "off",
)

print("Writing config file to", config_path)
Expand Down
4 changes: 2 additions & 2 deletions flowdb/bin/build/pg_config_template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#
# Logging options
#
log_destination = 'csvlog'
log_destination = '{log_destination}'
log_directory = 'pg_log'
logging_collector = 'on'
logging_collector = '{collecter_on}'
log_filename = 'postgres-%Y-%m-%d_%H%M%S'
log_rotation_age = 1d
log_rotation_size = 1GB
greenape marked this conversation as resolved.
Show resolved Hide resolved
Expand Down