Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/platform/workflows/reference/blueprints/assign-commander-from-schedule.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/platform/workflows/reference/blueprints/assign-commander-from-schedule/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Assign commander from schedule
Note
Grafana Workflows is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.
When an incident is declared without a commander, assign whoever is on call in your incident commander schedule.
This Grafana Workflows blueprint is in the Incidents category of the Blueprints library.
Before you begin
To use this blueprint, you need:
- Grafana IRM set up on your stack.
Steps
Steps run in order from first to last. A step inside a switch branch runs only when Workflows chooses that branch.
| Step | ID | Type | Description |
|---|---|---|---|
| No commander yet? | no-commander-yet | filter | Stops the run when the incident already has a commander, for example when the person who declared it took the role. No changes needed. |
| Find the on-call commander | get-on-call | irm.schedule-current-oncall | Looks up who is currently on call in your incident commander rotation. Set scheduleIdentifier to the exact name of the IRM schedule, or switch identifierType to id and paste the schedule ID. |
| Assign commander if someone is on call | assign-commander | switch | Assigns the first on-call user as commander, or leaves a note when nobody is on call. No changes needed. |
Make on-call user the commander (branch 1 of assign-commander) | add-commander | incident.add-participant | Gives the on-call user the commander role on the incident. No changes needed. |
Note who was assigned (branch 1 of assign-commander) | note-assigned | incident.add-note | Adds a timeline note saying this workflow assigned the commander. No changes needed. |
Note that nobody was on call (default branch of assign-commander) | note-no-commander | incident.add-note | Records that nobody was on call so the team knows to pick a commander. No changes needed. |
For the inputs and outputs of each step type, refer to Step and trigger types reference.
Before you turn on the workflow, customize any steps that need input from you, such as a channel ID or a schedule name. Each step’s description says what to set.
Workflow definition
Save this definition as a YAML file to create the workflow with gcx, the Workflows API, or Terraform, or give it to a coding agent as an example.
Replace FOLDER_UID with the UID of the folder for the workflow.
Blueprints start disabled, so finish customizing the steps before you set enabled to true.
For details, refer to Manage workflows as code.
apiVersion: workflows.ext.grafana.app/v1alpha1
kind: Definition
metadata:
name: assign-commander-from-schedule
annotations:
grafana.app/folder: <FOLDER_UID>
spec:
name: Assign commander from schedule
enabled: false
startWhen:
matchingRules:
- eventNameRegex: 'grafana_irm_app\.incident\.updated'
filter: "inputs.data.eventKind == 'incident_created'"
schedules: []
steps:
- id: no-commander-yet
type: filter
name: No commander yet?
description: Stops the run when the incident already has a commander, for example when the person who declared it took the role. No changes needed.
inputs:
condition: "resources.incident.event.incidentMembership.assignments == null || !resources.incident.event.incidentMembership.assignments.exists(a, a.role == 'commander')"
- id: get-on-call
type: irm.schedule-current-oncall
name: Find the on-call commander
description: >-
Looks up who is currently on call in your incident commander rotation. Set
scheduleIdentifier to the exact name of the IRM schedule, or switch identifierType to id
and paste the schedule ID.
inputs:
scheduleIdentifier: ''
identifierType: 'name'
- id: assign-commander
type: switch
name: Assign commander if someone is on call
description: Assigns the first on-call user as commander, or leaves a note when nobody is on call. No changes needed.
branches:
- condition: "steps['get-on-call'].outputs.count > 0"
steps:
- id: add-commander
type: incident.add-participant
name: Make on-call user the commander
description: Gives the on-call user the commander role on the incident. No changes needed.
inputs:
incidentID: '${inputs.data.incidentID}'
userID: "${steps['get-on-call'].outputs.users[0].email}"
role: 'commander'
- id: note-assigned
type: incident.add-note
name: Note who was assigned
description: Adds a timeline note saying this workflow assigned the commander. No changes needed.
inputs:
incidentID: '${inputs.data.incidentID}'
message: "The **Assign commander from schedule** workflow made ${steps['get-on-call'].outputs.users[0].username} the incident commander because they are on call."
- steps:
- id: note-no-commander
type: incident.add-note
name: Note that nobody was on call
description: Records that nobody was on call so the team knows to pick a commander. No changes needed.
inputs:
incidentID: '${inputs.data.incidentID}'
message: 'Nobody was on call in the incident commander schedule, so no commander was assigned automatically. Assign one from the incident page.'How it works
This section explains when the workflow runs and how its steps work together.
When it runs
This blueprint starts on the grafana_irm_app.incident.updated event.
Its trigger filter starts a run only when this CEL expression is true:
inputs.data.eventKind == 'incident_created'How the steps fit together
These notes cover how the steps connect and which Workflows behaviors the blueprint relies on.
- Triggers once per incident on
eventKindincident_created. - A filter step reads the auto-loaded incident’s role assignments at
resources.incident.event.incidentMembership.assignments, where each entry has a role (for example commander) and a user, and stops the run when someone already holds the commander role, for example when the person declaring the incident took it. - assignments is null when nobody holds a role, so the condition checks for null before calling
exists(). irm.schedule-current-oncalllooks up who is on call in the commander schedule.- A switch assigns the first on-call user with
incident.add-participantand records it on the timeline, and its default branch leaves a note when nobody is on call. - Major incident kickoff also assigns a commander, as part of a larger flow for Critical incidents.
- Customize the schedule name and, to limit it by severity, add a condition on
resources.incident.event.severityto the trigger filter.
Next steps
Was this page helpful?
Related resources from Grafana Labs


