πΌ Meerschaum Compose¶
Meerschaum Compose does the same for Meerschaum as Docker Compose does for Docker: you can consolidate everything into a single YAML file, including all of the pipes and configuration needed for your project. Compose is built into Meerschaum 4.0 and later.
With mrsm compose up, you can stand up syncing jobs for your pipes defined in the Compose project, one job per instance. Because the configuration is contained in the YAML file (e.g. custom connectors), Compose projects are useful for prototyping, collaboration, and consistency.
Multiple Compose Files
For complicated projects, split the work into several compose files and tie them together with include:. The root file lists the others, and every compose command spans them:
You may also run each file on its own with --file, which lets multiple projects cleanly share root and plugins directories:
Example Compose File
This compose project demonstrates how to sync two pipes to a new database awesome.db:
sync:
schedule: "every 30 seconds"
pipes:
- connector: "plugin:noaa"
metric: "weather"
location: "atlanta"
parameters:
noaa:
stations:
- "KATL"
- connector: "sql:awesome"
metric: "fahrenheit"
target: "atl_temp"
parameters:
query: |-
SELECT
timestamp,
station,
(("temperature (degC)" * 1.8) + 32) AS fahrenheit
FROM plugin_noaa_weather_atlanta
columns:
datetime: "timestamp"
id: "station"
plugins:
- "noaa"
config:
meerschaum:
instance: "sql:awesome"
connectors:
sql:
awesome:
database: "awesome.db"
flavor: "sqlite"
βΊ Setup¶
Template Project
Want to skip the setup and work in a pre-configured environment? Create a new repository from the Meerschaum Compose Project Template.
Upgrading from the compose plugin
Compose has been built in since Meerschaum 4, and existing Compose files and commands do not need to change. To migrate:
- Upgrade Meerschaum. Compose is part of the core and needs no extra.
- Remove
mrsm install plugin composefrom project bootstrap scripts, then runmrsm uninstall plugin compose. Until it is removed, the built-in action takes precedence and warns once per process. - Continue using the same YAML files, commands, and flags. Legacy Compose imports and registered
plugin:composepipes remain compatible.
compose down -v deletes only resources whose project ownership is clear. Shared pipes are untagged, and ambiguous resources are preserved.
From a new directory, create a file mrsm-compose.yaml. You can paste the example file above to get started.
Plugins Directories
You may set multiple paths for plugins_dir. This is very useful if you want to group plugins together. A value of null will include the environment's plugins in your project.
πͺ Commands¶
If you've used docker-compose, you'll catch on to Meerschaum Compose pretty quickly. Here's a quick summary:
| Command | Description | Useful Flags |
|---|---|---|
compose init |
Initialize a new project and install dependencies. | |
compose run |
Update and sync the pipes defined in the compose file. | --debug: Verbosity toggle. All flags are passed to sync pipes. |
compose up |
Bring up the syncing jobs (one job per instance; systemd services on a systemd host) |
-f: Follow the logs once the jobs are running. |
compose down |
Take down the syncing jobs. | -v: Drop the pipes ("volumes"). |
compose logs |
Follow the jobs' logs. | --nopretty: Print the logs files instead of following. |
compose ps |
Show the running status of background jobs. | |
compose explain |
Print defined pipes, registration status, a read-only engine plan (definition changes, planned flushes, flush_pending), and lint findings. Nothing is created, installed or fetched. |
--project: Limit to one project; --fail-on-flush: Fail closed (exit 1) on flushes or unplannable graphs; --nopretty: Emit a single JSON preflight report. |
For our example project awesome-sauce, let's bring up the syncing jobs:
Running mrsm compose without a subaction opens the Meerschaum shell inside the project's environment. The project name is appended to the prompt and shown in the bottom toolbar so you can tell which project a command will run against:
All other commands are executed as regular actions from within the project environment.
### Print out the environment variables set by the compose file.
mrsm compose show environment
### Verify that custom connectors are able to be parsed.
mrsm compose show connectors sql:awesome
### The default instance for this project is sql:awesome, so pipes will be fetched from there by default.
mrsm compose show pipes
mrsm compose show columns
mrsm compose show rowcounts
### Jump into an interactive CLI.
mrsm compose sql awesome
π Flags¶
The built-in compose action provides the following flags. You can quickly view the available flags with mrsm -h or mrsm show help.
| Flag | Description | Example |
|---|---|---|
-f |
Follow the logs when running compose up. |
mrsm compose up -f |
-v, --volumes |
Delete pipes when running compose down. |
mrsm compose down -v |
--dry |
For compose up, update the pipes' registrations but don't actually begin syncing. |
mrsm compose up --dry |
--file, --compose-file |
Specify an alternate compose file (default: mrsm-compose.yaml). | mrsm compose show connectors --file config-only.yaml |
--env, --env-file |
Specify an alternate environment file (default: .env). | mrsm compose show environment --env secrets.env |
--project |
Limit the command to one project of an included tree. | mrsm compose up --project weather |
--standalone |
Ignore the file's parent: and run it on its own. |
mrsm compose up --standalone |
--no-stagger |
Start jobs without the startup jitter and slots. | mrsm compose up --no-stagger |
--fail-on-flush |
Fail closed (exit 1) from compose explain if any node plans flush or flush_pending, or if any project or tree cannot be safely planned (alias --fail-on-rebuild). |
mrsm compose explain --fail-on-flush |
The flags may come before or after the subaction, and -f <file>.yaml is accepted as a shorthand for --file (a bare -f still follows the logs): mrsm compose --file other.yaml up and mrsm compose up -f other.yaml are the same command.
𧬠Schema¶
Below are the supported top-level keys in a Compose file. Note that all keys are optional.
connectorsDefine the available connectors for the project. Alias forconfig.meerschaum.connectors.instanceConnector keys for the default instance for the project. Alias forconfig.meerschaum.instance.pipesList all of the pipes to be used in this project. See the ThepipesKey section below.pipelinesDefine named, exact Pipe selections. Jobs reference these names; dependencies remain in Pipe parameters. See Pipelines in Compose.syncGovern the behavior of the syncing process. See ThesyncKey section below.jobsIf provided,compose upwill start the defined jobs. See ThejobsKey below.project_name(optional)
Tag applied to all pipes in this project. Defaults to the folder name formrsm-compose.yaml/mrsm-compose.yml, or the filename stem for custom files (e.g.,metrics.yamlβmetrics). Every project in aninclude:tree must have a unique name.root_dir(default./root/)
Path to the root directory; seeMRSM_ROOT_DIR.plugins_dir(default./plugins/)
Path or list of paths to plugins directories (nullincludes the host's plugins directories). SeeMRSM_PLUGINS_DIR.plugins
Plugins to ensure are installed (fromapi:mrsmby default, or append@api:<label>for a custom repository).config
Configuration overrides layered on top of host config (MRSM_CONFIG). Compose jobs receive this via an owner-only file (MRSM_CONFIG_FILE) in the job directory instead of/proc/<pid>/environorsystemdunit files.environmentAdditional environment variables to pass to subprocesses.includeCompose files, directories and globs to include. See Multiple Projects.parentThe compose file or directory of the project which includes this one. See Multiple Projects.isolationIfisolationis set tosubprocess, thencomposewill execute commands as subprocesses, ensuring the truest level of isolation. By default, commands are executed within the host Meerschaum process, with isolated configuration and plugins and root directories. This behavior may be temporarily enabled with the flag--isolated.daemonIfdaemonisfalse, thencomposewill not use a persistent CLI daemon but will instead execute all commands in-process (i.e. appends--no-daemonto each command).
Accessing the host configuration
The Meerschaum Compose YAML file also supports Meerschaum symlinks. For example, to alias a new connector sql:foo to your host's sql:main:
File Path and Environment Variables
Each Compose file substitutes the string values {MRSM_ROOT_DIR} and {__file__} with the corresponding file paths (root directory and compose file, respectively). Similarly, you may reference standard environment variables with $:
The connectors Key¶
The connectors key (an alias for config.meerschaum.connectors) defines the connectors available to the project. Project-defined connectors may reference connectors from the host Meerschaum configuration by referencing the host keys (in braces). For example, below is how you would define sql:main within a project to be sql:dev from the host environment.
The pipes Key¶
The pipes key contains a list of keyword arguments to build mrsm.Pipe objects, notably:
connector(required)metric(required)location(defaultnull)instance(default toconfig:meerschaum:instance)parameterscolumns(alias forparameters:columns)target(alias forparameters:target)tags(alias forparameters:tags)dtypes(alias forparameters:dtypes)
The sync Key¶
Keys under the parent key sync are the following:
scheduleDefine a regular interval for syncing processes by setting a schedule. This corresponds to the flag-s/--schedule.min_seconds(default1) If a schedule is not set, pipes will be constantly synced and sleepmin_secondsbetween laps. This corresponds to the flags--min-secondsand--loop.timeout_secondsIf this value is set, long-running syncing processes which exceed this value will be terminated. This corresponds to the flag--timeout-seconds/--timeout.argsThis value may be a string or list of command-line arguments to append to the syncing command. This option is available for specific edge case scenarios, such as when working with custom flags or specific intervals (i.e.--beginand--end).
The jobs Key¶
Define custom jobs under jobs to override the default per-instance syncing jobs (compose up registers pipes and starts these jobs; add --presync to run an initial sync first). Set jobs: {} to register pipes without starting any jobs.
Example jobs
- Project ownership:
compose up,start/stop/pause/restart/delete jobsonly touch jobs stamped by this project (refusing to clobber another project's job before making any changes). systemdby default: On systemd hosts, Compose starts jobs as user units (mrsm-<project>.<job>.service) so they survive reboots. Setconfig: {meerschaum: {executor: local}}to keep local daemons instead (Executors).- Non-destructive
-fguard: Background and Compose jobs append-ffor job-lifecycle prompts, but-fnever consents to clearing a pipe whoseflush.modeis unset.
π§© Multiple Projects: include and parent¶
Split large deployments into smaller Compose files tied together from a root file. Commands like mrsm compose up, down, run, ps, logs, and explain then span the entire tree.
# mrsm-compose.yaml
project_name: acme
root_dir: ./root
plugins_dir: [./plugins]
include:
- projects/ # every *.yaml / *.yml, plus projects/*/mrsm-compose.yaml
- extra/weather.yaml # a single file
- 'regions/*.yaml' # a glob
- path: local-overrides.yaml
required: false # missing optional files only warn
config:
meerschaum:
instance: "sql:acme"
# projects/weather.yaml
project_name: weather
parent: .. # optional: run from the root project automatically
plugins: [noaa]
pipes:
- connector: "plugin:noaa"
metric: "weather"
location: "atlanta"
How overrides work¶
Each included project keeps its own project_name, plugins_dir, and relative .env, while the root project wins when values overlap:
| Key | Merge behavior |
|---|---|
config / environment / .env |
Deep-merged; root wins (each project keeps its own stack.project_name). |
pipes |
Matched by (connector, metric, location, instance); root entry replaces the child's. |
plugins |
Matched by name; root spec (e.g., noaa@api:custom) wins. |
jobs |
Scoped to each project; override from the root with <project>/<job> (e.g., weather/sync). |
- Execution order: Depth-first (included projects before the root;
compose downreverses order). Pass--project <name>to target one project. parent:: Lets you runmrsm compose upfrom a subproject directory while inheriting the root's config and overrides (pass--standaloneto ignoreparent:).- Startup gate: Multi-job startups stagger automatically; pass
--no-staggerto start immediately.
π Explaining a project¶
mrsm compose explain prints defined pipes, registration status, parameter diffs, a read-only engine plan against the proposed pipe definitions, and lint findingsβcompletely read-only (no directories or database files created, no packages installed, no plugins downloaded):
mrsm compose explain
mrsm compose explain --project weather
mrsm compose explain --fail-on-flush
mrsm compose explain --nopretty --fail-on-flush
Plain compose explain exits 0 and surfaces lint warnings and [PREFLIGHT ERROR] diagnostics in the Syncing Engine Preflight banner (clean up-to-date projects print only the explain table). Pass --fail-on-flush (alias --fail-on-rebuild) in CI deploy gates to fail closed (exit 1) whenever any project in the tree has:
- A planned clearing
flushorflush_pendingnode (forward-sync definition changes withoutflush.modestill pass). - An unplannable graph or instance: dependency cycles, unreachable instances, failed registration or config loads, unreadable engine state (
state_errors/upstream_failed), or eligible pipes missing from the plan. - A blocking multi-project tree problem (
include-load-failedorduplicate-project-name).
Every project in an include: tree is evaluated without short-circuiting so all flushes and errors appear in one run. Intentionally empty, jobs-only, and all-temporary projects pass with status: "empty"; absent local SQLite or GeoPackage files are planned in memory without creating files on disk (still catching dependency cycles).
Machine-readable output (--nopretty)¶
Pass --nopretty to emit a single JSON document to stdout (no tables or info lines mixed in; lint findings are included in lint). Combine with --fail-on-flush to parse stdout directly and gate on exit code 0 or 1:
mrsm compose explain --nopretty --fail-on-flush | jq '{ok, eligible_count, planned_count, blocking_flush_count, tree_errors}'
JSON report fields
| Scope | Fields |
|---|---|
| Top-level | ok, fail_on_flush, eligible_count, planned_count, unplanned_count, blocking_flush_count, definition_changed_count, tree_errors, lint, projects |
Each item in projects |
project, default_instance, status ("planned", "empty", or "failed"), eligible_count, planned_count, unplanned_count, temporary_count, eligible_pipes, planned_pipes, unplanned_pipes, blocking_flushes, definition_changes, errors ({ project, instance, kind, cause }), plan (Engine Plan or null) |
Generate a Compose file from existing pipes
Run mrsm compose init -c <connector> -m <metric> -t <tag> -i <instance> in an empty folder to scaffold a new mrsm-compose.yaml from matching registered pipes.