Documentation
DocumentationDiscussions
Documentation
These docs are for v2023.2. Click to read the latest docs for v2024.3.

Using PostgreSQL as a Metastore

Seq stores two kinds of data. Log events are stored in Seq's event store. Documents, like users and signals are stored in a separate metastore, which may be Seq's built-in one, or a SQL database like SQL Server or PostgreSQL.

The built-in metastore is easy and self-contained, but an external PostgreSQL database may be more convenient if application data is already stored there, and can be more reliable if Seq's local filesystem is a network-based cloud filesystem.

📘

Events aren't stored in the metastore

Seq won't store log events in the PostgreSQL database. Only documents like users and signals will be stored there. Since the metastore is usually small, even for large instances, you probably won't need to provision a large server for its documents.

🚧

Multiple Seq instances using the same Postgres metastore are not supported

You'll need to configure a (DR) Instance if you'd like to share a single metastore with multiple Seq instances.

Pointing Seq at a PostgreSQL database

If the metastore.postgres.connectionString configuration setting is given a non-null value then Seq will use that connection string as the source of the metastore.

In an init script:

seqsvr secret set -k metastore.postgres.connectionString -v "Host=example;Port=5432;Database=seq"

Use the --value-stdin flag to pipe your connection string from a file or other source through STDIN.

The connection string can also be specified in the SEQ_METASTORE_POSTGRES_CONNECTIONSTRING environment variable.

The first time it runs, Seq will execute its migrations on the chosen schema.

Migrating an existing instance to the PostgreSQL metastore

As an example, say we want to use the connection string Host=localhost;Port=5432;Database=seq. An existing Seq instance can be migrated to this SQL Server database using the metastore to-postgresql command:

seqsvr metastore to-postgresql --connection-string "Host=example;Port=5432;Database=seq"

To see a full list of options that to-postgresql accepts, run seq help metastore to-postgresql.