Audit Manager
The Audit Manager node turns every message it receives into an audit event and stores it in RethinkDB. The event type is chosen in the node from a catalogue of events (organised by category); the user is taken from the dashboard session; extra fields come from the payload builder. The database, the table and its indexes are created on first use. Optionally, the stored event is also published to NATS.
Two more parts come with the node:
- A plugin adds the dashboard user to the messages sent by Dashboard 2 widgets, as
msg._client.user, when the browser has a valid Rosepetal session cookie. That object is the only source of the user of the events of this node. - An Audit tab in the editor sidebar shows whether a user is verified, whether RethinkDB is reachable, the dashboard user, the time of the last event and the last 10 events. The status uses the store of the first Audit Manager node; the event list always reads the default store (the
RDB_*environment variables, else127.0.0.1:28015, databaseaudit, tableaudit_events). The tab refreshes when the editor loads, when an edit dialog opens, after each deploy, every 15 seconds while it is visible, and with its Refresh button.
Palette: category storage, label audit db. 1 input, 1 output.
Configuration
| Property | Description | Default |
|---|---|---|
| Name | Optional label, shown in the editor before audit and the event type. | "" |
| Locale | Locale Config for the times of the Audit sidebar tab, which uses the Locale of the first Audit Manager node that has one. | none |
| Category | Category of the catalogue; it filters the event types. | Access |
| Event type | Event stored for every incoming message (see Event catalogue). Required. | access_login_success |
Audit viewer destination (collapsible section): the RethinkDB store.
| Property | Description | Default |
|---|---|---|
| Enabled | Store the event in RethinkDB. When unticked, the event is only built (and published to NATS if enabled). | ticked |
| RethinkDB host | Empty: the RDB_HOST environment variable, else 127.0.0.1. | "" |
| RethinkDB port | Empty: RDB_PORT, else 28015. | "" |
| Database | Empty: RDB_DB, else audit. | "" |
| Table | Empty: audit_events. | "" |
NATS publishing (collapsible section):
| Property | Description | Default |
|---|---|---|
| Enabled | Also publish the event to NATS after storing it. | unticked |
| NATS URL | Empty: the NATS_URL environment variable. With neither, nothing is published. | "" |
| Subject | Empty: NATS_AUDIT_SUBJECT, else audit. | "" |
Audit payload builder: rows added with New param. Each row has a type, a value and a field name, and adds payload.<field name> to the event. Rows without a field name are dropped when the dialog is saved.
| Type | Value |
|---|---|
str | The text as written. |
num | The number; an empty value is stored as 0, and a value that is not a number leaves the field out. |
bool | true or false. |
msg | Path inside the incoming message, such as payload.batchId. |
flow | Path inside the flow context, such as machine.currentValue. |
global | Path inside the global context, such as config.siteId. |
A path that leads to nothing (undefined) leaves the field out; a null value is stored. When no field is left, the event has no payload.
Input
Any message. The node reads only msg._client.user (set by the plugin) and the paths of the payload builder; msg.payload is not stored unless a row asks for it.
Output
The incoming message, sent once the event is stored, with the event in msg.audit:
msg.audit = {
actionId: "session_batch_start",
actionType: "session",
roleId: "prof-operator",
source: "node-red-flow",
timestamp: new Date("2026-07-15T10:00:00.000Z"),
userId: "operator@example.com",
payload: { batchId: "BATCH-001" },
natsPublish: { ok: true, subject: "audit" }
};| Property | Meaning |
|---|---|
actionId | The event type. |
actionType | Its category in lower case. |
roleId | profileId of the session user, or null. |
source | node-red-flow for events of this node. |
timestamp | Time the event was built, as a Date. |
userId | E-mail of the session user, or null when the message did not come from a dashboard with a session. |
payload | Fields of the payload builder; absent when there are none. |
natsPublish | Result of the NATS step: { ok: true, subject }, { ok: false, skipped: true, reason: "nats_disabled" } when NATS is disabled or has no URL, or { ok: false, error } when publishing failed (then also natsPublishError). It is not part of the stored or published event. |
Event catalogue
The event types come from the catalogue bundled with the package:
| Category | Event types |
|---|---|
| Access | access_login_success, access_login_failed, access_logout, access_session_expired |
| Actions | bypass_activate, bypass_deactivate, conveyor_activate, conveyor_deactivate |
| Log | log_start, log_stop, log_show_errors, log_image_upload, log_stop_upload, log_clear |
| Capture | capture_start, capture_stop, capture_start_upload, capture_stop_upload, capture_remove_images |
| Alarms | alarm_detected, alarm_reset |
| Operation | operation_software_start, operation_software_stop |
| Session | session_batch_start, session_batch_stop, session_recipe_creation, session_recipe_deletion, session_recipe_rename, session_recipe_model_change, session_recipe_modification, session_recipe_import, session_recipe_export, session_recipe_version_change, session_ai_model_load, session_ai_model_version_change, session_ai_model_hash_calculation |
| Backup | backup_creation, backup_creation_error, backup_recovery, backup_recovery_error |
The editor shows each type with its label, for example Batch start (session_batch_start). A saved event type that is not in the catalogue is stored as access_login_success.
Besides the events of this node, the plugin stores the access_login_success, access_login_failed and access_logout events that the Rosepetal sign-in reports for the dashboard session (source: "dashboard-sso"). They use the RethinkDB and NATS settings of the first Audit Manager node that is not disabled, or the environment defaults when there is none.
Status and errors
| Status | Meaning |
|---|---|
green dot audit saved | Event stored (or built, with the store disabled) and, if NATS is enabled, published. |
yellow dot audit saved, nats: <reason> | Event stored, but NATS is enabled and the event was not published; the reason is nats_disabled (no URL) or the error. The message is still sent. |
red ring audit failed | RethinkDB could not be reached or the insert failed; the error is raised as a node error (a Catch node receives it) and no message is sent. |
Requirements
- A RethinkDB server reachable from Node-RED.
- A NATS server, only for NATS publishing.
JWT_SECRETset in the environment of Node-RED: it signs and verifies the dashboard session cookie (COOKIE_NAME,rp_tokenby default) that the plugin issues after a Rosepetal sign-in. Without a valid cookie,msg._client.useris not set and events have no user.
Usage example
Record the start of a production batch from a dashboard button. In the node, select category Session and event type Batch start (session_batch_start), and add one row to the payload builder:
| Type | Value | Field name |
|---|---|---|
msg | payload.batchId | batchId |
Connect the button to the Audit Manager. When an operator with a dashboard session presses it with msg.payload = { batchId: "BATCH-001" }, the node stores session_batch_start with that operator's e-mail and payload.batchId = "BATCH-001", shows audit saved and sends the message on with msg.audit. With the default store, the event appears in the Audit sidebar tab.