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

Using SQL Server as a Metastore

Seq stores two kinds of data. Log events are stored in Seq's embedded storage engine, called Flare. Documents, like users and signals are stored in a separate metastore, which may be Flare (the default), or a SQL database like SQL Server or PostgreSQL.

📘

Events aren't stored in the metastore

Seq won't store log events in the SQL Server 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 SQL Server metastore are not supported

Seq needs exclusive access to its metastore. To host multiple metastores on the same SQL Server instance, specify --schema when converting to SQL Server storage, or set the SEQ_METASTORE_MSSQL_SCHEMA environment variable/metastore.msSql.Schema configuration setting.

Pointing Seq at a SQL Server database

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

seq secret set -k metastore.msSql.connectionString -v "Initial Catalog=seq-local;Integrated Security=True"

The connection string can also be specified in the SEQ_METASTORE_MSSQL_CONNECTIONSTRING environment variable, or piped from a file/STDIN using --value-stdin:

cat connection-string.txt | seq secret set -k metastore.msSql.connectionString --value-stdin

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

Migrating an existing instance to the SQL Server metastore

As an example, say we want to use the connection string Initial Catalog=seq-local\;Integrated Security=True. An existing Seq instance can be migrated to this SQL Server database using the metastore to-mssql command:

seq metastore to-mssql --connection-string "Initial Catalog=seq-local;Integrated Security=True" --skip-config

In this example, we also pass --skip-config, so that the connection string itself isn't saved into the Seq.json file. To see a full list of options that to-mssql accepts, run seq help metastore to-mssql.

Now when starting the container, passing the same connection string in the SEQ_METASTORE_MSSQL_CONNECTIONSTRING environment variable will use that database as the metastore:

SEQ_METASTORE_MSSQL_CONNECTIONSTRING="Initial Catalog=seq-local;Integrated Security=True" seq run

Managed Service Identities for Azure SQL Database

Many Azure services use managed service identities for connecting to SQL databases. When connecting to an Azure SQL Database instance, specify ActiveDirectoryDefault as the authentication type in your connection string:

Server=tcp:yourdbserver.database.windows.net,1433;Database=your_db;Authentication=ActiveDirectoryDefault

If the managed service identity has access to multiple tenants, an additional --msi-tenant-id/SEQ_METASTORE_MSSQL_MSITENANTID value must be provided to select the tenant in which the identity is acting.