logs method retrieves workflow run logs using the List Workflow Runs API.
Arguments
string
A pagination cursor from a previous request.
Use this to fetch the next set of results.
number
Maximum number of runs to return. Defaults to a system-defined value if not specified.
object
Filter options for narrowing down workflow run logs.
Hide child attributes
Hide child attributes
string
Filter by a specific workflow run ID.
string
Filter workflow runs by execution state.
| State | Description |
|---|---|
RUN_STARTED | The workflow run is in progress. |
RUN_SUCCESS | The workflow run completed successfully. |
RUN_FAILED | The run failed after all retries. |
RUN_CANCELED | The run was manually canceled. |
string
Filter by the exact workflow URL.
string | string[]
Filter by workflow label. Pass an array to match runs that have any
of the given labels (OR semantics).
number
Filter by the workflow creation time (Unix timestamp).
string
Filter by a specific message ID.
Date | number
Filter workflow runs created after this date.
Date | number
Filter workflow runs created before this date.
string
Filter by the IP address that triggered the workflow.
string
Filter by flow control key.
Response
string
A cursor to use for pagination.
If no cursor is returned, there are no more workflow runs.
Array
Show child attributes
Show child attributes
string
The ID of the workflow run.
string
The URL address of the workflow endpoint.
string
The current state of the workflow run at this point in time
| Value | Description |
|---|---|
RUN_STARTED | The workflow has started to run and currently in progress. |
RUN_SUCCESS | The workflow run has completed succesfully. |
RUN_FAILED | Some errors has occured and workflow failed after all retries. |
RUN_CANCELED | The workflow run has canceled upon user request. |
number
The Unix timestamp (in milliseconds) when the workflow run started.
string
The Unix timestamp (in milliseconds) when the workflow run was completed, if applicable.
string[]
The labels of the run assigned by the user on trigger.
string
deprecated
Deprecated. Use
labels instead. When a run has multiple labels, this only
contains the first one.FailureFunction
The details of the failure callback message, if a failure function was defined for the workflow.
Show child attributes
Show child attributes
string
The ID of the failure callback message
string
The URL address of the failure function
string
The state of the failure callback
| Value |
|---|
CALLBACK_INPROGRESS |
CALLBACK_SUCCESS |
CALLBACK_FAIL |
string
The HTTP headers of the message that triggered the failure function.
string
The HTTP response status of the message that triggered the failure function.
string
The response body of the message that triggered the failure function.
string
The DLQ ID of the workflow run.
string
Response body of the failure function/url.
When failure function is used, this contains
the returned message from the failure function.
array
Reponse headers of the failure function/url. This is valuable when the call to run the failure function/url is rejected
because of a platform limit.
int
Reponse status of the failure function/url. This is valuable when the call to run the failure function/url is rejected
because of a platform limit.
array
A call to failure url/function can be retried as
maxRetries time. This array contains errors of all retry
attempts.Show child attributes
Show child attributes
int
Response status of the endpoint that caused the error
array
Response Headers of the endpoint that caused the error
string
Response Body of the endpoint that caused the error if available
string
An error message that happened before/after calling the user's endpoint.
int64
The time of the error happened in Unix time milliseconds
string
Max number of retries configured when seeing an error.
Array
Hide child attributes
Hide child attributes
string
The type of grouped steps
| Value | Description |
|---|---|
sequential | Indicates only one step is excuted sequentially |
parallel | Indicates multiple steps being executed in parallel. |
next | Indicates there is information about currently executing step(s) |
Array
Show child attributes
Show child attributes
number
The ID of the step which increases monotonically.
string
The name of the step. It is specified in workflow by user.
string
Execution type of the step which indicates type of the context function.
| Value | Function |
|---|---|
Initial | The default step which created automatically |
Run | context.run() |
Call | context.call() |
SleepFor | context.sleepFor() |
SleepUntil | context.sleepUntil() |
Wait | context.waitForEvent() |
Notify | context.notify() |
Invoke | context.invoke() |
string
The ID of the message associated with this step.
string
The output returned by the step
string
The total number of concurrent steps that is running alongside this step
string
The state of this step at this point in time
| Value |
|---|
STEP_SUCCESS |
STEP_RETRY |
STEP_FAILED |
STEP_CANCELED |
string
The unix timestamp in milliseconds when the message associated with this step has created.
number
The unix timestamp in milliseconds when this step will be retried.
This is set only when the step state is
STEP_RETRYstring
The duration in milliseconds which step will sleep. Only set if stepType is
SleepFor.string
The unix timestamp (in milliseconds) which step will sleep until. Only set if stepType is
SleepUntil.string
The event id of the wait step. Only set if stepType is
Wait.string
The unix timestamp (in milliseconds) when the wait will time out.
string
The duration of timeout in human readable format (e.g. 120s, 1m, 1h).
string
Set to true if this step is cause of a wait timeout rather than notifying the waiter.
string
The URL of the external address. Available only if stepType is
Call.string
The HTTP method of the request sent to the external address. Available only if stepType is
Call.string
The HTTP headers of the request sent to the external address. Available only if stepType is
Call.string
The body of the request sent to the external address. Available only if stepType is
Call.number
The HTTP status returned by the external call. Available only if stepType is
Call.string
The body returned by the external call. Available only if stepType is
Call.array
The HTTP headers returned by the external call. Available only if stepType is
Call.string
The ID of the invoked workflow run if this step is an invoke step.
string
The URL address of the workflow server of invoked workflow run if this step is an invoke step.
number
The Unix timestamp (in milliseconds) when the invoked workflow was started if this step is an invoke step.
string
The body passed to the invoked workflow if this step is an invoke step.
string
The HTTP headers passed to invoked workflow if this step is an invoke step.
Usage
import { Client } from "@upstash/workflow";
const client = new Client({ token: "<QSTASH_TOKEN>" })
const { runs, cursor } = await client.logs()
Paginate with cursor
const allRuns = [];
let cursor: string | undefined;
do {
const result = await client.logs({ cursor });
allRuns.push(...result.runs);
cursor = result.cursor;
} while (cursor);
Filter by state
const { runs } = await client.logs({
filter: {
state: "RUN_FAILED",
}
})
Filter by label and date range
const { runs } = await client.logs({
filter: {
label: "my-workflow",
fromDate: new Date("2024-01-01"),
toDate: new Date("2024-06-01"),
}
})
Filter by multiple labels
Passing an array matches runs that have any of the given labels (OR semantics). For example, with runs labelled["label-1", "label-2"] and ["label-2", "label-3"],
filtering by ["label-1", "label-2"] returns both.
const { runs } = await client.logs({
filter: {
label: ["label-1", "label-2"],
}
})