Verify traces in Grafana Cloud

In this milestone, you verify that traces are being received in Grafana Cloud from your Grafana Alloy configuration. You’ll use the TraceQL Query Editor with a simple query to confirm your trace data flows correctly.

Send sample trace

Using the example curl command, you can send a sample trace to your Alloy instance to verify that traces are being collected and forwarded to Grafana Cloud.

Before you can use this example, you need to update the start and end time.

The startTimeUnixNano and endTimeUnixNano fields are in nanoseconds, where 100000000 nanoseconds is 100 milliseconds. The nanosecond value can be obtained by any tool that provides the epoch date in nanoseconds. For example, under Linux, you can use date +%s%N. You can also use an online tool such as Epoch Converter to get the current time in nanoseconds.

To send a sample trace, complete the following steps:

  1. Copy and paste the curl command into a text editor.

    Bash
    curl -X POST -H 'Content-Type: application/json' http://localhost:4318/v1/traces -d '
    {
    	"resourceSpans": [{
        	"resource": {
            	"attributes": [{
                	"key": "service.name",
                	"value": {
                    	"stringValue": "my.service"
                	}
            	}]
        	},
        	"scopeSpans": [{
            	"scope": {
                	"name": "my.library",
                	"version": "1.0.0",
                	"attributes": [{
                    	"key": "my.scope.attribute",
                    	"value": {
                        	"stringValue": "some scope attribute"
                    	}
                	}]
            	},
            	"spans": [
            	{
                	"traceId": "5B8EFFF798038103D269B633813FC700",
                	"spanId": "EEE19B7EC3C1B100",
                	"name": "I am a span!",
                	"startTimeUnixNano": 1689969302000000000,
                	"endTimeUnixNano": 1689970000000000000,
                	"kind": 2,
                	"attributes": [
                	{
                    	"key": "my.span.attr",
                    	"value": {
                        	"stringValue": "some value"
                    	}
                	}]
            	}]
        	}]
    	}]
    }'
  2. Replace startTimeUnixNano and endTimeUnixNano with current values for the last 24 hours to allow you to search for them using a 24 hour relative time range.

    You can get this in seconds and milliseconds from the Unix Epoch Clock.

    For startTimeUnixNano, use the current time minus 24 hours. Use the link above to figure out the value.

    For endTimeUnixNano, use the current time.

    Multiply the milliseconds value by 1,000,000 to turn it into nanoseconds. You can do this from a bash terminal with the following command. Replace <epochTimeMilliseconds> with the milliseconds value.

    Bash
    echo $((<epochTimeMilliseconds> * 1000000))
  3. Copy the updated curl command to a terminal window and run it.

    You should receive a message that the request was successful.

View traces in Grafana Cloud

To verify traces are being received using the TraceQL Query Editor, complete the following steps:

  1. Sign in to your Grafana Cloud environment, for example mystack.grafana.net.

  2. On the Grafana Cloud home page, open the navigation menu on the left side of the screen and click Explore.

  3. From the data source drop-down at the top of the page, select your traces data source.

    For example, select grafanacloud-traces.

  4. In the TraceQL query editor, select the Search tab and click Run query.

    The { } query searches for all traces without any filters, making it the simplest way to verify Grafana Cloud received the trace data.

    TraceQL Query Editor showing the Search tab with the query set to {} and the Run query button.

  5. Verify traces appear in the results. If your configuration works correctly, the query returns a list of all received traces.

In your final milestone, you reach the destination and explore next steps for expanding your observability capabilities.

Were you successful?

More to explore (optional)

At this point in your journey, you can explore the following paths:

Push spans with HTTP

Use traces in Grafana

Trace analysis and performance monitoring


page 8 of 9