> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# Grafana: Get Trace

Retrieves a trace by ID from a Grafana Tempo datasource as a flat list of spans.


> **Availability:** See the [Incident Workflow Actions Overview table](/workflow-actions) for the plans this workflow is available on.

## Description

Retrieve a trace by ID from a Grafana Tempo datasource as a flat list of spans sorted by start time. Use this action to inspect the full path of a request, including which services it crossed and which spans failed.

## Instructions

1. If you have not done so, follow the instructions to [Create an Incident Workflow](/ai-automation/automation/incident-workflows#create-an-incident-workflow).
2. When the instructions prompt you to [add actions](/ai-automation/automation/incident-workflows#add-actions), select **this action**.
3. Enter the following **Inputs** and click **Save**.
4. Continue following instructions to **Publish** the Workflow.
5. When the action runs, you will see the **Outputs** listed below.

## Inputs

> **Field References:** Fields with the **\{+\}** icon accept [Field References](/ai-automation/automation/incident-workflows#field-references), which can be useful for referencing incident data or outputs created in prior workflow steps. To add Field References, click **\{+\}**, or enter `{{`, and select relevant fields. Refer to the [Field References](/ai-automation/automation/incident-workflows#field-references) article for more information.

| Name                            | Description                                                                         |
| :------------------------------ | :---------------------------------------------------------------------------------- |
| **Connection Input**            | The Grafana Connection to use.                                                      |
| **Datasource**                  | The Tempo datasource UID to read the trace from.                                    |
| **Trace ID**                    | The trace ID as a hex string, for example `2dde0cee77ae5dc9c17ade3689eb2e54`.       |
| **Max Spans**<br />_(Optional)_ | Maximum number of spans to return, earliest first, from 1 to 5000. Defaults to 500. |

## Outputs

| Name                    | Description                                                                                                                                                         |
| :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Spans**               | Array of spans sorted by start time, each with `traceId`, `spanId`, `parentSpanId`, `name`, `serviceName`, `kind`, `startTime`, `durationMs`, `status`, and `attributes`. |
| **Trace ID**            | The normalized trace ID that was requested.                                                                                                                         |
| **Span Count**          | Total number of spans in the trace.                                                                                                                                 |
| **Returned Span Count** | Number of spans returned after applying **Max Spans**.                                                                                                              |
| **Error Span Count**    | Number of spans with an error status.                                                                                                                               |
| **Service Names**       | Array of the service names in the trace.                                                                                                                            |
| **Trace Duration**      | Time between the first span start and the last span end, in milliseconds.                                                                                           |
| **Truncated**           | Whether the trace had more spans than **Max Spans**.                                                                                                                |
| **Result**              | Value that shows if the action was successful or not. Either `Success` or `Failed`.                                                                                 |
| **Result Summary**      | Brief description of what the action did or if it failed.                                                                                                           |
| **Error**               | Brief description that is populated if the action failed.                                                                                                           |

<br />
