Workflow Lifecycle Observability
This document explains how to follow workflow instances from creation to completion in Lemline: which lifecycle events are emitted, where to see them, and how to query them.
Workflow Lifecycle Phases
A workflow goes through these phases:
Definition: the definition is registered with
lemline definition postCreation: an instance is created (
lemline instance start, the gRPC gateway, a schedule or a parent workflow)Execution: the instance runs its tasks; it may wait for events or timers
Completion: the instance ends as
COMPLETEDorFAULTED
Core Observability Events
Lemline emits a CloudEvent for each lifecycle transition, following the Open Workflow specification:
Event type | Emitted when | Main data |
|---|---|---|
| An instance is created | workflow name, input, definition reference |
| An instance starts | workflow name, definition reference |
| An instance completes | workflow name, output |
| An instance faults | workflow name, error |
| A task is created | workflow, task, input |
| A task starts | workflow, task |
| A task completes | workflow, task, output |
| A task faults | workflow, task, error |
| A task is retried | workflow, task, retry count |
Errors carry the standard fields type, status, title, instance and detail.
The events are published on the lifecycle events channel (by default the lemline-lifecycle-events topic or queue). See Lifecycle Events.
Monitoring Workflow Definitions
List and read the registered definitions from the CLI:
Without arguments the command asks which definition to print. In a script, pass the namespace, name and version.
The gRPC gateway also exposes per-definition counters (ListDefinitionStats, WatchDefinitionStats), shown in the dashboard.
Monitoring Workflow Instances
The CLI does not list or inspect instances. Use the dashboard, or the gRPC gateway directly:
ListInstances/GetInstance: find instances by namespace, workflow, version, status and creation timeWatchInstances: follow instance changes liveListInstanceEvents/WatchInstanceEvents: read or follow the lifecycle events of one instance
Storing Lifecycle Events
With lifecycle analytics enabled, a runner stores the complete CloudEvent in the payload column of lemline_lifecycle_events. Dedicated columns hold the workflow ID, namespace, name and version. See Lifecycle Analytics Reference to configure SQLite or PostgreSQL.
Run the following queries on PostgreSQL. Replace the lemline schema qualifier if you changed lemline.analytics.postgresql.schema.
For SQLite, open the configured file with sqlite3 -readonly /var/lib/lemline/analytics.db. Query the unqualified table and order by id to read events in the same order as the gateway history. SQLite returns event_time in Unix epoch microseconds.
Metrics
Runners expose Prometheus metrics at /q/metrics. They count and time message processing per channel (for example lemline_messaging_commands_processing_completed_total, lemline_messaging_commands_processing_failed_total and lemline_messaging_commands_processing_duration_seconds), tagged by workflow name and version. Lemline does not publish per-instance or per-task duration metrics; derive those from the lifecycle events.
These counters track message handling. A workflow that faults (an HTTP call returning 500, a raise…) is processed successfully from the runner's point of view and does not increase processing_failed_total: alert on faulted workflows with the workflow.faulted lifecycle events instead.
Example Prometheus alert on message-processing failures (broker, database or infrastructure problems):
Best Practices for Workflow Lifecycle Observability
Enable lifecycle analytics in environments where you need an instance history
Alert on faulted workflows using the
workflow.faultedevents; use processing failure metrics for message-handling and infrastructure failuresCorrelate logs with instances: every runner log line carries the workflow namespace, name, version and instance id
Define a retention policy for the analytics table
For more details on specific types of observability data, see: