What is Moleculer’s Laboratory?
Moleculer’s Laboratory is a self-hosted, open-source monitoring & observability dashboard for Moleculer-based microservices projects. It runs entirely inside your infrastructure: the Agent service collects the data, stores it in an embedded database (or in your own PostgreSQL server) and serves the dashboard web app itself. Nothing is uploaded to any cloud service — your data is yours.
Source code: github.com/moleculerjs/laboratory (MIT license)
Features
- Live cluster view — nodes, services, actions, events with real-time registry updates
- Topology & dependency graphs — animated traffic flow visualization
- Metrics — collection, aggregation, history charts and a metrics explorer with drag-and-drop dashboards (charts + KPI tiles)
- Distributed tracing — trace list with bubble chart, span waterfall view
- Centralized logs — live tailing with search
- Alerting — metric threshold / availability / log-rate rules, persisted alert history
- Data explorer — browse, filter and edit the entities of @moleculer/database services
- Workflows — job queues, task timelines and live signals of @moleculer/workflows
- REST API browser — list and invoke the endpoints published by moleculer-web gateways
- Interactive tools — call any action, emit/broadcast any event, command palette
Moleculer’s Laboratory works with Moleculer v0.14 and v0.15.
How does it work?
The Laboratory is a single NPM package (@moleculer/lab) which contains:
- Agent service (
$lab) — a common Moleculer service running in your project alongside the other services. It collects the data from local & remote nodes, stores it, evaluates the alert rules and serves both the HTTP API and the bundled dashboard UI (by default on port3210). It should be loaded by a single Moleculer node only. Do NOT run it on every node. - Collector modules — registered into Moleculer under the
Laboratoryname. They send the collected data to the Agent service via internal Moleculer events, so they work with any transporter:MetricReporter— metrics reporterTraceExporter— tracing exporterLogForwarder— logger that forwards the log messages
Use it in your project
Install the package
npm i @moleculer/lab |
Create the Agent service
Create a service file that loads the Agent service. It can be lab.service.js or any other name that you like.
// lab.service.js |
Make sure that the Agent service is loaded only once in your project.
Enable the collectors
Register the Laboratory collectors in the broker options to view metrics, traces and logs in the dashboard. Requiring @moleculer/lab registers the Laboratory metric reporter, trace exporter and logger types. Enable only the ones you need.
// moleculer.config.js |
The collectors must be enabled on every node whose data you want to see, not only on the node that runs the Agent service.
Open the dashboard
Start your project and open http://localhost:3210/lab in your browser. The exact URL is printed to the console at startup:
✔ Moleculer Laboratory started: http://localhost:3210/lab |
The Laboratory has no built-in authentication. If you expose it beyond your own network, protect it with a reverse proxy, or mount it behind your API gateway and use its authentication.
Settings
| Name | Type | Default | Description |
|---|---|---|---|
name |
String |
"Moleculer Project" |
The name of your project, shown in the UI. |
server.enabled |
Boolean |
true |
Start the embedded HTTP server. Set it to false when serving through moleculer-web. |
server.port |
Number |
3210 |
Port of the embedded HTTP server. Env var: LAB_PORT |
basePath |
String |
"/lab" |
URL path prefix of the UI and the API. |
store |
Object |
{} |
Storage options. See below. |
Storage
By default the data is stored in an embedded, in-memory PGLite database (PostgreSQL compiled to WebAssembly), so no external database is needed.
| Name | Type | Default | Description |
|---|---|---|---|
store.connectionString |
String |
null |
External PostgreSQL connection string. If set, the embedded database is not used. |
store.persistent |
Boolean |
false |
Persist the embedded database to disk. |
store.folder |
String |
"./.data/lab" |
Data folder of the persisted embedded database. |
store.metrics.retentionMins |
Number |
30 |
Retention of metrics data in minutes. |
store.metrics.timeWindow |
Number |
10 |
Aggregation time window of metrics in seconds. |
store.tracing.retentionMins |
Number |
30 |
Retention of tracing spans in minutes. |
store.logging.retentionMins |
Number |
30 |
Retention of log entries in minutes. |
store.alerts.retentionMins |
Number |
10080 |
Retention of the alert history in minutes (7 days). |
Long-term storage with PostgreSQL
For long-term data retention, point the Agent service to a PostgreSQL server:
// lab.service.js |
Serving through moleculer-web
Instead of the embedded HTTP server, you can mount the Laboratory behind your moleculer-web API gateway. In this case the Agent service and the API gateway must run on the same node.
Disable the embedded server in the Agent service:
// lab.service.js |
and add the Laboratory route to the API gateway:
// api.service.js |
This way the dashboard is available under your gateway address (e.g. http://localhost:3000/lab) and you can protect it with your gateway’s authentication.
FAQ
Is it free and open source?
Yes. Moleculer’s Laboratory is open source under the MIT license, and you can use it in any number of projects.
Does it send my data to the cloud?
No. Everything — the Agent service, the database and the dashboard UI — runs inside your infrastructure.
Can I use it in production?
Yes. During development the default embedded in-memory store is enough. In production use a PostgreSQL storage with a retention configuration that fits your needs, and don’t expose the dashboard without authentication.