Application Observability .NET quickstart
Quickly get started with Application Observability for .Net with these easy three steps.
- Download the instrumentation agent
- Instrument an application
- Observe the service in Application Observability
Install the agent
Install the Grafana OpenTelemetry Distribution for .Net.
To install the distribution with the full set of dependencies, add a reference to the Grafana.OpenTelemetry
package to a project.
dotnet add package --prerelease Grafana.OpenTelemetry
Instrument an application
The UseGrafana
extension method on the TracerProviderBuilder
or the MetricProviderBuilder
can be used to set up the Grafana distribution. By default, telemetry data is sent to a Grafana agent or an OTel collector that runs locally and listens to default OTLP ports:
using OpenTelemetry;
using OpenTelemetry.Trace;
using Grafana.OpenTelemetry;
public class Program
{
public static void Main(string[] args)
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.UseGrafana()
.Build();
}
}
Login to Grafana Cloud and follow the following instructions to obtain the necessary information to send telemetry data to Grafana Cloud:
- Click Details in the Grafana section on https://grafana.com/profile/org
- Copy Instance ID and Zone into the command below.
- On the left menu, click on Security and then on API Keys
- Click on Create API Key (MetricsPublisher role) and copy the key into the command below
- Choose a Service Name to identify the service (e.g.
cart
) - Optionally, add attributes to filter data:
- deployment.environment: Name of the deployment environment (
staging
orproduction
) - service.namespace: A namespace to group similar services
(e.g.
shop
would createshop/cart
in Application Observability) - service.version: The application version, to see if a new version has introduced a bug
- service.instance.id: The unique instance, for example the Pod name (a UUID is generated by default)
- deployment.environment: Name of the deployment environment (
Make the following environment variables available to the .NET application:
export GRAFANA_CLOUD_INSTANCE_ID=<Instance ID>
export GRAFANA_CLOUD_ZONE=<Zone>
export GRAFANA_CLOUD_API_KEY=<Copied API Key>
export OTEL_SERVICE_NAME=<Service Name>
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=<Environment>,service.namespace=<Namespace>,service.version=<Version>
Finally, make some requests to the service to validate data is sent to Grafana Cloud. It might take up to five minutes for data to appear.
Observe the service
In Grafana Cloud, replace the path of the URL with /a/grafana-app-observability-app/services
or:
- Click on the menu icon in the top left corner
- Open the Observability menu
- Click on Application
Important: refer to the troubleshooting guide if there is no data in Application Observability.
For a detailed description of all supported installation and configuration options, refer to the project documentation.
Was this page helpful?
Related resources from Grafana Labs


