Skip to main content

OpenTelemetry Support

Enabling OpenTelemetry in RavenDB

  • To enable the OpenTelemetry metrics in RavenDB,
    you must first set the Monitoring.OpenTelemetry.Enabled configuration key to true.

  • Learn how to customize configuration keys in the Configuration Overview article,
    which outlines all available options.

  • Please remember that it is necessary to restart the RavenDB process for changes to take effect.

RavenDB OpenTelemetry meters

Each meter listed below groups similar or related metric instruments.
Each metric instrument observes some metric value.

Only the most commonly used meters are enabled by default.
This can be customized through the specified configuration keys.

RavenDB exposes the following meters:

Server identification in metrics

  • OpenTelemetry monitoring requires a service instance ID for initialization.

  • The identification of the server that originated each exposed metric will be listed in the serviceInstanceId property within the metric data.

  • The server instance identification is determined by the following sequence:

    1. Configuration Key
      First, attempt to retrieve the Monitoring.OpenTelemetry.ServiceInstanceId configuration key.
    2. Public URL Hostname
      If the configuration key is Not defined, use the server's public URL hostname, provided it is available.
    3. Node Tag
      If the public URL hostname is unavailable, attempt to use the node tag.
    4. Initialization Failure
      If none of the above options are available, OpenTelemetry will Not be initialized.

The metric instruments

ravendb.server.cpucredits

Instrument nameDescriptionInstrument type
ravendb.server.cpucredits.alert_raisedCPU Credits Any Alert RaisedGauge
ravendb.server.cpucredits.background.tasks.alert_raisedCPU Credits Background Tasks Alert RaisedGauge
ravendb.server.cpucredits.baseCPU Credits BaseUpDownCounter
ravendb.server.cpucredits.consumption_currentCPU Credits Gained Per SecondUpDownCounter
ravendb.server.cpucredits.failover.alert_raisedCPU Credits Failover Alert RaisedGauge
ravendb.server.cpucredits.maxCPU Credits MaxUpDownCounter
ravendb.server.cpucredits.remainingCPU Credits RemainingGauge

ravendb.server.gc

Instrument nameDescriptionInstrument type
ravendb.server.gc.compactedSpecifies if this is a compacting GC or not.Gauge
ravendb.server.gc.concurrentSpecifies if this is a concurrent GC or not.Gauge
ravendb.server.gc.finalizationpendingcountGets the number of objects ready for finalization this GC observed.Gauge
ravendb.server.gc.fragmentedGets the total fragmentation (in MB) when the last garbage collection occurred.Gauge
ravendb.server.gc.gclohsizeGets the large object heap size (in MB) after the last garbage collection of given kind occurred.Gauge
ravendb.server.gc.generationGets the generation this GC collected.Gauge
ravendb.server.gc.heapsizeGets the total heap size (in MB) when the last garbage collection occurred.Gauge
ravendb.server.gc.highmemoryloadthresholdGets the high memory load threshold (in MB) when the last garbage collection occurred.Gauge
ravendb.server.gc.indexThe index of this GC.Gauge
ravendb.server.gc.memoryloadGets the memory load (in MB) when the last garbage collection occurred.Gauge
ravendb.server.gc.pausedurations1Gets the pause durations. First item in the array.Gauge
ravendb.server.gc.pausedurations2Gets the pause durations. Second item in the array.Gauge
ravendb.server.gc.pinnedobjectscountGets the number of pinned objects this GC observed.Gauge
ravendb.server.gc.promotedGets the promoted MB for this GC.Gauge
ravendb.server.gc.timepercentageGets the pause time percentage in the GC so far.Gauge
ravendb.server.gc.totalavailablememoryGets the total available memory (in MB) for the garbage collector to use when the last garbage collection occurred.Gauge
ravendb.server.gc.totalcommittedGets the total committed MB of the managed heap.Gauge

ravendb.server.general

Instrument nameDescriptionInstrument type
ravendb.server.general.certificate_server_certificate_expiration_left_secondsServer certificate expiration leftGauge
ravendb.server.general.cluster.indexCluster indexUpDownCounter
ravendb.server.general.cluster.node.stateCurrent node stateUpDownCounter
ravendb.server.general.cluster.termCluster termUpDownCounter
ravendb.server.general.license.cores.maxServer license max CPU coresGauge
ravendb.server.general.license.cpu.utilizedServer license utilized CPU coresGauge
ravendb.server.general.license.expiration_left_secondsServer license expiration leftGauge
ravendb.server.general.license.typeServer license typeGauge

ravendb.server.resources

Instrument nameDescriptionInstrument type
ravendb.server.resources.available_memory_for_processingAvailable memory for processing (in MB)Gauge
ravendb.server.resources.cpu.machineMachine CPU usage in %Gauge
ravendb.server.resources.cpu.processProcess CPU usage in %Gauge
ravendb.server.resources.dirty_memoryDirty Memory that is used by the scratch buffers in MBGauge
ravendb.server.resources.encryption_buffers.memory_in_poolServer encryption buffers memory being in pool in MBGauge
ravendb.server.resources.encryption_buffers.memory_in_useServer encryption buffers memory being in use in MBGauge
ravendb.server.resources.io_waitIO wait in %Gauge
ravendb.server.resources.low_memory_flagServer low memory flag valueGauge
ravendb.server.resources.machine.assigned_processor_countNumber of assigned processors on the machineUpDownCounter
ravendb.server.resources.machine.processor_countNumber of processor on the machineUpDownCounter
ravendb.server.resources.managed_memoryServer managed memory size in MBGauge
ravendb.server.resources.thread_pool.available_completion_port_threadsNumber of available completion port threads in the thread poolGauge
ravendb.server.resources.thread_pool.available_worker_threadsNumber of available worker threads in the thread poolGauge
ravendb.server.resources.total_memoryServer allocated memory in MBGauge
ravendb.server.resources.total.swap_usageServer total swap usage in MBGauge
ravendb.server.resources.total.swap.sizeServer total swap size in MBGauge
ravendb.server.resources.unmanaged_memoryServer unmanaged memory size in MBGauge
ravendb.server.resources.working_set_swap_usageServer working set swap usage in MBGauge

ravendb.server.requests

Instrument nameDescriptionInstrument type
ravendb.server.requests.requests.average_durationAverage request time in millisecondsGauge
ravendb.server.requests.requests.concurrent_requestsNumber of concurrent requestsUpDownCounter
ravendb.server.requests.requests.per_secondNumber of requests per second.Gauge
ravendb.server.requests.tcp.active.connectionsNumber of active TCP connectionsGauge
ravendb.server.requests.total.requestsTotal number of requests since server startupUpDownCounter

ravendb.server.storage

Instrument nameDescriptionInstrument type
ravendb.server.storage.storage.disk.ios.read_operationsIO read operations per secondGauge
ravendb.server.storage.storage.disk.ios.write_operationsIO write operations per secondGauge
ravendb.server.storage.storage.disk.queue_lengthQueue lengthGauge
ravendb.server.storage.storage.disk.read_throughputRead throughput in kilobytes per secondGauge
ravendb.server.storage.storage.disk.remaining.spaceRemaining server storage disk space in MBGauge
ravendb.server.storage.storage.disk.remaining.space_percentageRemaining server storage disk space in %Gauge
ravendb.server.storage.storage.disk.write_throughputWrite throughput in kilobytes per secondGauge
ravendb.server.storage.storage.total_sizeServer storage total size in MBGauge
ravendb.server.storage.storage.used_sizeServer storage used size in MBGauge

ravendb.server.totaldatabases

Instrument nameDescriptionInstrument type
ravendb.server.totaldatabases.count_stale_indexesNumber of stale indexes in all loaded databasesUpDownCounter
ravendb.server.totaldatabases.data.written.per_secondNumber of bytes written (documents, attachments, counters, timeseries) in all loaded databasesGauge
ravendb.server.totaldatabases.database.disabled_countNumber of disabled databasesUpDownCounter
ravendb.server.totaldatabases.database.encrypted_countNumber of encrypted databasesUpDownCounter
ravendb.server.totaldatabases.database.faulted_countNumber of faulted databasesUpDownCounter
ravendb.server.totaldatabases.database.loaded_countNumber of loaded databasesUpDownCounter
ravendb.server.totaldatabases.database.node_countNumber of databases for current nodeUpDownCounter
ravendb.server.totaldatabases.database.total_countNumber of all databasesUpDownCounter
ravendb.server.totaldatabases.map_reduce.index.mapped_per_secondNumber of maps per second for map-reduce indexes (one minute rate) in all loaded databasesGauge
ravendb.server.totaldatabases.map_reduce.index.reduced_per_secondNumber of reduces per second for map-reduce indexes (one minute rate) in all loaded databasesGauge
ravendb.server.totaldatabases.map.index.indexed_per_secondNumber of indexed documents per second for map indexes (one minute rate) in all loaded databasesGauge
ravendb.server.totaldatabases.number_error_indexesNumber of error indexes in all loaded databasesUpDownCounter
ravendb.server.totaldatabases.number_of_indexesNumber of indexes in all loaded databasesUpDownCounter
ravendb.server.totaldatabases.number.faulty_indexesNumber of faulty indexes in all loaded databasesUpDownCounter
ravendb.server.totaldatabases.writes_per_secondNumber of writes (documents, attachments, counters, timeseries) in all loaded databasesGauge

Metrics export options

RavenDB offers two options for exporting metrics:

  • Export data to the console for immediate metrics insight.
  • Export data via the OpenTelemetry Protocol (OTLP) for integration with other observability platforms.

Console:

  • RavenDB can output telemetry data directly to the console,
    providing real-time, local visibility of the OpenTelemetry metrics.

  • This is particularly useful for local development and debugging,
    as it eliminates the need for integration with external monitoring systems or observability platforms.

  • To enable output to the console -
    set the Monitoring.OpenTelemetry.ConsoleExporter configuration key to true.

OpenTelemetry Protocol:

  • OpenTelemetry supports the OpenTelemetry Protocol (OTLP),
    a standard wire protocol used by all OpenTelemetry SDKs.

  • This protocol allows data to be sent from metrics producers (e.g. RavenDB) to any software that supports OTLP.
    The recommended software, as suggested by OpenTelemetry, is called OpenTelemetry Collector.
    The Collector can be further configured to forward and export this data to various analysis tools.
    Learn about the OpenTelemetry Collector on the official documentation site: OTel Collector.

  • RavenDB supports the official OTLP by default, allowing you to export RavenDB metrics to the OpenTelemetry Collector.

  • To enable exporting metrics via the OpenTelemetry Protocol -
    set the Monitoring.OpenTelemetry.OpenTelemetryProtocol.Enabled configuration key to true.

  • By default, RavenDB does not override the OpenTelemetry Protocol exporter default values.
    However, customization is available via the following configuration options:

Configuration keyDescriptionAccepted values
Monitoring.OpenTelemetry.OpenTelemetryProtocol
.ExportProcessorType
Export processor typeSimple / Batch
Monitoring.OpenTelemetry.OpenTelemetryProtocol
.Headers
Custom headersstring
Monitoring.OpenTelemetry.OpenTelemetryProtocol
.Protocol
Defines the transport protocol that OpenTelemetry Protocol should use to send data.gRPC / HttpProtobuf
Monitoring.OpenTelemetry.OpenTelemetryProtocol
.Endpoint
Endpoint where OpenTelemetry Protocol should send data.
See configuration details below.
string
Monitoring.OpenTelemetry.OpenTelemetryProtocol
.Timeout
Timeoutint

Configuring the OpenTelemetry Protocol endpoint: The defined endpoint must correspond to the endpoint configured on the collector for receiving metrics data. The endpoint format should match the transport protocol you are using:


  • HttpProtobuf protocol:

    • HttpProtobuf is a transport protocol used for efficiently serializing structured data over HTTP
      using Protocol Buffers (Protobuf).

    • The current official .NET implementation adheres to the OpenTelemetry specification,
      which requires specifying the complete path to the collector endpoint when exporting metrics.
      By default, the endpoint path for the OpenTelemetry Collector is /v1/metrics.

    • So, for example, if you are using the default settings for the OpenTelemetry Collector
      and utilizing HttpProtobuf as the transport protocol, the endpoint used would be http://localhost:4318/v1/metrics (replace the default port 4318 with whatever port you are using).

  • gRPC protocol:

    • When using the default settings for the OpenTelemetry Collector with the gRPC transport protocol,
      the endpoint should be specified in the format grpc://localhost:4317
      (replace the default port 4317 with whatever port you are using).

    • The gRPC endpoint does not include a path like /v1/metrics.

Configuring the OpenTelemetry Collector

  • The OpenTelemetry Collector is a vendor-agnostic proxy that can receive, process, and export telemetry data (traces, metrics, logs) from multiple sources to different backends. It acts as a centralized point for collecting and processing telemetry data.

  • In the OpenTelemetry Collector configuration, a receiver is a component that listens for incoming telemetry data.

  • Configure the receiver to either:

    • Receive data via OTLP from RavenDB
    • Retrieve data from RavenDB's Prometheus endpoint

Receive data via OTLP:

  • The otlp receiver is used for receiving telemetry data in the OpenTelemetry Protocol (OTLP) format.

  • Specify the endpoints where the OpenTelemetry Collector should listen for incoming telemetry data,
    whether via gRPC or HTTP, and on which ports.
    (4317 is the default port for gRPC, and 4318 is the default port for HTTP protocol).

  • For example, define your controller like so:

receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318

Retrieve data from Prometheus:

  • The OpenTelemetry Collector includes support for retrieving metrics from a Prometheus endpoint.

  • RavenDB provides a Prometheus endpoint that can be used as a data source for the OpenTelemetry Collector. This endpoint provides metrics in a standardized format and integrates seamlessly without requiring you to enable OpenTelemetry in RavenDB.

  • Use the prometheus_simple receiver in your OpenTelemetry Collector configuration.
    This setup instructs the collector to scrape metrics from a Prometheus endpoint.

  • Specify the address of your RavenDB server in the endpoint key.
    Specify RavenDB's Prometheus endpoint path in the metrics_path key.

  • A sample configuration may look like this:

receivers:
prometheus_simple:
endpoint: "http://localhost:8080" # Replace with your RavenDB instance address
metrics_path: "/admin/monitoring/v1/prometheus" # RavenDB's prometheus endpoint path
collection_interval: 10s
tls:
cert_file: "D:\\cert.crt"
key_file: "D:\\key.key"
insecure: false
insecure_skip_verify: false
  • The configuration above sets up the OpenTelemetry Collector to scrape Prometheus-formatted metrics from a RavenDB server.
    The collector will access http://localhost:8080/admin/monitoring/v1/prometheus to retrieve the metrics.