Type to search.

Set up Elasticsearch instrumentation

Serverless Observability

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

APM Agent .NET

The Elastic APM .NET agent enables you to trace the execution of operations in your .NET applications, sending performance metrics and errors to the Elastic APM server.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Package Supported versions
Elastic.Clients.{{product.elasticsearch}} (current) ≥8.0.0 <10.0.0
{{product.elasticsearch}}.Net (legacy) ≥7.6.0 <8.0.0
NEST (legacy) ≥7.6.0 <8.0.0

For the full compatibility matrix including supported installation methods, refer to Data access technologies.

This page assumes the core agent is already set up. If not, see Set up the APM .NET Agent first.

The currently supported Elasticsearch client for .NET ships in the Elastic.Clients.Elasticsearch NuGet package. This package and the underlying transport are instrumented with OpenTelemetry native APIs built into .NET. These will be picked up automatically when the OpenTelemetry Bridge feature is enabled. No additional Elastic APM .NET Agent package is required.

Add the Elastic.Apm.Elasticsearch NuGet package to your project:

Shell
dotnet add package Elastic.Apm.{{product.elasticsearch}}

Pass {{product.elasticsearch}}DiagnosticsSubscriber to the AddElasticApm method in case of ASP.NET Core as follows:

C#
using Elastic.Apm.Elasticsearch

app.Services.AddElasticApm(new {{product.elasticsearch}}DiagnosticsSubscriber());

or passing {{product.elasticsearch}}DiagnosticsSubscriber to the Subscribe method

C#
using Elastic.Apm;
using Elastic.Apm.Elasticsearch

Agent.Subscribe(new {{product.elasticsearch}}DiagnosticsSubscriber());

Instrumentation listens for activities raised by {{product.elasticsearch}}.Net and Nest, creating spans for executed requests.

Important

If you’re using {{product.elasticsearch}}.Net and Nest 7.10.1 or 7.11.0, upgrade to at least 7.11.1 which fixes a bug in span capturing.