Skip to content

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, else 127.0.0.1:28015, database audit, table audit_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 ​

PropertyDescriptionDefault
NameOptional label, shown in the editor before audit and the event type.""
LocaleLocale Config for the times of the Audit sidebar tab, which uses the Locale of the first Audit Manager node that has one.none
CategoryCategory of the catalogue; it filters the event types.Access
Event typeEvent stored for every incoming message (see Event catalogue). Required.access_login_success

Audit viewer destination (collapsible section): the RethinkDB store.

PropertyDescriptionDefault
EnabledStore the event in RethinkDB. When unticked, the event is only built (and published to NATS if enabled).ticked
RethinkDB hostEmpty: the RDB_HOST environment variable, else 127.0.0.1.""
RethinkDB portEmpty: RDB_PORT, else 28015.""
DatabaseEmpty: RDB_DB, else audit.""
TableEmpty: audit_events.""

NATS publishing (collapsible section):

PropertyDescriptionDefault
EnabledAlso publish the event to NATS after storing it.unticked
NATS URLEmpty: the NATS_URL environment variable. With neither, nothing is published.""
SubjectEmpty: 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.

TypeValue
strThe text as written.
numThe number; an empty value is stored as 0, and a value that is not a number leaves the field out.
booltrue or false.
msgPath inside the incoming message, such as payload.batchId.
flowPath inside the flow context, such as machine.currentValue.
globalPath 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:

js
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" }
};
PropertyMeaning
actionIdThe event type.
actionTypeIts category in lower case.
roleIdprofileId of the session user, or null.
sourcenode-red-flow for events of this node.
timestampTime the event was built, as a Date.
userIdE-mail of the session user, or null when the message did not come from a dashboard with a session.
payloadFields of the payload builder; absent when there are none.
natsPublishResult 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:

CategoryEvent types
Accessaccess_login_success, access_login_failed, access_logout, access_session_expired
Actionsbypass_activate, bypass_deactivate, conveyor_activate, conveyor_deactivate
Loglog_start, log_stop, log_show_errors, log_image_upload, log_stop_upload, log_clear
Capturecapture_start, capture_stop, capture_start_upload, capture_stop_upload, capture_remove_images
Alarmsalarm_detected, alarm_reset
Operationoperation_software_start, operation_software_stop
Sessionsession_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
Backupbackup_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 ​

StatusMeaning
green dot audit savedEvent 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 failedRethinkDB 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_SECRET set in the environment of Node-RED: it signs and verifies the dashboard session cookie (COOKIE_NAME, rp_token by default) that the plugin issues after a Rosepetal sign-in. Without a valid cookie, msg._client.user is 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:

TypeValueField name
msgpayload.batchIdbatchId

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.