DOCA Documentation v3.2.1 LTS

DOCA Telemetry Exporter

This guide provides an overview and configuration instructions for DOCA Telemetry Exporter API.

Info

The quality status of DOCA libraries is listed here.

DOCA Telemetry Exporter API offers a fast and convenient way to transfer user-defined data to DOCA Telemetry Service (DTS). In addition, the API provides several built-in outputs for user convenience, including saving data directly to storage, NetFlow, Fluent Bit forwarding, and Prometheus endpoint.

The following figure shows an overview of the telemetry exporter API. The telemetry exporter client side, based on the telemetry exporter API, collects user-defined telemetry and sends it to DTS which runs as a container on BlueField or host. DTS does further data routing, including export with filtering. DTS can process several user-defined telemetry exporter clients and can collect pre-defined counters by itself. Additionally, telemetry exporter API has built-in data outputs that can be used from telemetry exporter client applications.

image-2025-7-3_17-24-8-version-1-modificationdate-1764238793070-api-v2.png

The following scenarios are available:

  • Send data via IPC transport to DTS. For IPC, refer to Inter-process Communication.

  • Write data as binary files to storage (for debugging data format).

  • Export data directly from DOCA Telemetry Exporter API application using the following options:

    • Fluent Bit exports data through forwarding

    • NetFlow exports data from NetFlow API. Available from both API and DTS. See details in Data Outputs.

    • Prometheus

      • Server mode – Creates Prometheus endpoint and keeps the most recent data to be scraped by Prometheus.

      • Remote write mode – Pushes Prometheus time-series metrics to a remote Prometheus DB supporting remote-write import.

    • Open Telemetry export

Users can either enable or disable any of the data outputs mentioned above. See Data Outputs to see how to enable each output.

The library stores data in an internal buffer and flushes it to DTS/exporters in the following scenarios:

  • Once the buffer is full. Buffer size is configurable with different attributes.

  • When doca_telemetry_exporter_source_flush(void *doca_source) function is invoked.

  • When the telemetry exporter client terminates. If the buffer has data, it is processed before the library's context cleanup.

DOCA Telemetry Exporter API is fundamentally built around four major parts:

  • DOCA schema – defines a reusable structure (see doca_telemetry_exporter_type) of telemetry data which can be used by multiple sources

    doca-schema-version-1-modificationdate-1764238792027-api-v2.png

  • Source – the unique identifier of the telemetry exporter source that periodically reports telemetry data.

  • Report – exports the information to the DTS

  • Finalize – releases all the resources

    DOCA_Telemetry_API-version-1-modificationdate-1764238792750-api-v2.png

DOCA Telemetry Exporter API Walkthrough

The NVIDIA DOCA Telemetry Exporter API's definitions can be found in the doca_telemetry_exporter.h file.

The following is a basic walkthrough of the needed steps for using the DOCA Telemetry Exporter API.

  1. Create doca_schema.

    1. Initialize an empty schema with default attributes:

      Copy
      Copied!
                  

      struct doca_telemetry_exporter_schema *doca_schema; doca_telemetry_exporter_schema_init("example_doca_schema_name", &doca_schema);

    2. Set the following attributes if needed:

      • doca_telemetry_exporter_schema_set_buffer_attr_*(…)

      • doca_telemetry_exporter_schema_set_file_write_*(…)

      • doca_telemetry_exporter_schema_set_ipc_*(…)

    3. Add user event types:

      Event type (struct doca_telemetry_exporter_type) is the user-defined data structure that describes event fields. The user is allowed to add multiple fields to the event type. Each field has its own attributes that can be set (see example). Each event type is allocated an index (doca_telemetry_exporter_type_index_t) which can be used to refer to the event type in future API calls.

      Copy
      Copied!
                  

      struct doca_telemetry_exporter_type *doca_type; struct doca_telemetry_exporter_field *field1;   doca_telemetry_exporter_type_create(&doca_type); doca_telemetry_exporter_field_create(&field1);   doca_telemetry_exporter_field_set_name(field1, "sport"); doca_telemetry_exporter_field_set_description(field1, "Source port") doca_telemetry_exporter_field_set_type_name(field1, DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_UINT16); doca_telemetry_exporter_field_set_array_length(field1, 1);   /* The user loses ownership on field1 after a successful invocation of the function */ doca_telemetry_exporter_type_add_field(type, field1);   /* Add more fields if needed */   /* The user loses ownership on doca_type after a successful invocation of the function */ doca_telemetry_exporter_schema_add_type(doca_schema, "example_event", doca_type, &type_index);

    4. Apply attributes and types to start using the schema:

      Copy
      Copied!
                  

      doca_telemetry_exporter_schema_start(doca_schema)

  2. Create doca_source:

    1. Initialize:

      Copy
      Copied!
                  

      struct doca_telemetry_exporter_source *doca_source; doca_telemetry_exporter_source_create(doca_schema, &doca_source);

    2. Set source ID and tag:

      Copy
      Copied!
                  

      doca_telemetry_exporter_source_set_id(doca_source, "example id"); doca_telemetry_exporter_source_set_tag(doca_source, "example tag");

    3. Apply attributes to start using the source:

      Copy
      Copied!
                  

      doca_telemetry_exporter_source_start(doca_source)

    You may optionally add more doca_sources if needed.

  3. Collect the data per source and use:

    Copy
    Copied!
                

    doca_telemetry_exporter_source_report(source, type_index, &my_app_test_ev1, num_events)

  4. Finalize:

    1. For every source:

      Copy
      Copied!
                  

      doca_telemetry_exporter_source_destroy(source)

    2. Destroy:

      Copy
      Copied!
                  

      doca_telemetry_exporter_schema_destroy(doca_schema)

Example implementation may be found in the telemetry_export DOCA sample (telemetry_export_sample.c).

DOCA Telemetry Exporter NetFlow API Walkthrough

The DOCA telemetry exporter API also supports NetFlow using DOCA Telemetry Exporter NetFlow API. This API is designed to allow customers to easily support the NetFlow protocol at the endpoint side. Once an endpoint produces NetFlow data using the API, the corresponding exporter can be used to send the data to a NetFlow collector.

The NVIDIA DOCA Telemetry Exporter Netflow API's definitions can be found in the doca_telemetry_exporter_netflow.h file.

The following are the steps to use the NetFlow API:

  1. Initiate the API with an appropriate source ID:

    Copy
    Copied!
                

    doca_telemetry_exporter_netflow_init(source_id)

  2. Set the relevant attributes:

    • doca_telemetry_exporter_netflow_set_buffer_*(…)

    • doca_telemetry_exporter_netflow_set_file_write_*(…)

    • doca_telemetry_exporter_netflow_set_ipc_*(…)

    • doca_telemetry_exporter_netflow_source_set_*()

  3. Start the API to use the configured attribute:

    Copy
    Copied!
                

    doca_telemetry_exporter_netflow_start();

  4. Form a desired NetFlow template and the corresponding NetFlow records.

  5. Collect the NetFlow data.

    Copy
    Copied!
                

    doca_telemetry_exporter_netflow_send(…)

  6. (Optional) Flush the NetFlow data to send data immediately instead of waiting for the buffer to fill:

    Copy
    Copied!
                

    doca_telemetry_exporter_netflow_flush()

  7. Clean up the API:

    Copy
    Copied!
                

    doca_telemetry_exporter_netflow_destroy()

Example implementation may be found in the telemetry_export_netflow DOCA sample (telemetry_export_netflow_sample.c).

DOCA Telemetry Exporter Metrics API Walkthrough

The DOCA Telemetry Exporter provides a Metrics API for the programmatic collection and export of performance metrics from applications. This API enables applications to report counters, gauges, and histograms with multi-dimensional labels, supporting export to multiple backends including file storage, IPC, and Prometheus.

Supported Metric Types

  • Counter: Monotonically increasing values (e.g., total requests, bytes sent, operations completed).

  • Gauge: Current values that can increase or decrease (e.g., memory usage, queue depth, bandwidth).

  • Histogram: Distribution of values across configurable buckets (e.g., latency percentiles, message sizes).

Initialization

The Metrics API requires a DOCA Telemetry Exporter source to be initialized before metrics can be reported.

Prerequisites:

  1. Initialize the DOCA schema (doca_telemetry_exporter_schema_init).

  2. Configure and start the schema (doca_telemetry_exporter_schema_start).

  3. Create the source (doca_telemetry_exporter_source_create).

  4. Start the source (doca_telemetry_exporter_source_start).

Note

At least one export backend (file, IPC, or Prometheus) must be enabled on the schema before creating the metrics context.

Example initialization:

Copy
Copied!
            

struct doca_telemetry_exporter_schema *schema = NULL; struct doca_telemetry_exporter_source *source = NULL; doca_error_t result;   // 1. Initialize schema and source result = doca_telemetry_exporter_schema_init("my_app", &schema); if (result != DOCA_SUCCESS) { /* Handle error */ }   doca_telemetry_exporter_schema_start(schema); doca_telemetry_exporter_source_create(schema, &source); doca_telemetry_exporter_source_set_id(source, "my_source"); doca_telemetry_exporter_source_set_tag(source, ""); doca_telemetry_exporter_source_start(source);   // 2. Create metrics context result = doca_telemetry_exporter_metrics_create_context(source); if (result != DOCA_SUCCESS) { // Handle error }   // 3. Configure metrics (Optional) // Set periodic flush to every 1 second (1000 ms) doca_telemetry_exporter_metrics_set_flush_interval_ms(source, 1000); // Add a constant label applied to all metrics from this source doca_telemetry_exporter_metrics_add_constant_label(source, "application", "my_app");


Working with Labels

Label sets define the dimensional structure of metrics. A label set specifies the names of the labels (e.g., "interface", "direction"), while the metrics themselves provide the specific values (e.g., "eth0", "tx").

Creating Label Set

Copy
Copied!
            

// Define label names const char *label_names[] = {"interface", "direction"}; doca_telemetry_exporter_label_set_id_t label_set_id;   // Register the label set result = doca_telemetry_exporter_metrics_add_label_names( source, label_names, 2, // Number of labels &label_set_id );


Using Label Values

Copy
Copied!
            

// Define values matching the label names const char *eth0_tx_labels[] = {"eth0", "tx"}; const char *eth1_rx_labels[] = {"eth1", "rx"};   uint64_t timestamp; doca_telemetry_exporter_get_timestamp(×tamp);   // Report metrics using different label combinations doca_telemetry_exporter_metrics_add_counter(source, timestamp, "bytes_total", 1024000, label_set_id, eth0_tx_labels);   doca_telemetry_exporter_metrics_add_counter(source, timestamp, "bytes_total", 2048000, label_set_id, eth1_rx_labels);


Constant Labels

Constant labels are applied globally to all metrics reported from a specific source.

Copy
Copied!
            

doca_telemetry_exporter_metrics_add_constant_label(source, "hostname", "server01"); doca_telemetry_exporter_metrics_add_constant_label(source, "version", "1.0");

Counters

Counters represent cumulative totals. They are strictly monotonically increasing.

API functions:

  • doca_telemetry_exporter_metrics_add_counter(): Set counter to an absolute value.

  • doca_telemetry_exporter_metrics_add_counter_increment(): Increment counter by a specified amount.

Example:

Copy
Copied!
            

uint64_t timestamp; doca_telemetry_exporter_get_timestamp(×tamp); const char *label_values[] = {"requests"};   // Set absolute counter value doca_telemetry_exporter_metrics_add_counter(source, timestamp, "operations_total", 42, label_set_id, label_values);   // Increment counter doca_telemetry_exporter_metrics_add_counter_increment(source, timestamp, "operations_total", 1, label_set_id, label_values);


Gauges

Gauges represent instantaneous values that can go up or down, such as memory usage or bandwidth.

API functions:

  • doca_telemetry_exporter_metrics_add_gauge(): Report a gauge with a double precision value.

  • doca_telemetry_exporter_metrics_add_gauge_uint64(): Report a gauge with a uint64_t value.

Example:

Copy
Copied!
            

uint64_t timestamp; doca_telemetry_exporter_get_timestamp(×tamp); const char *label_values[] = {"bandwidth"};   // Double precision gauge double bandwidth_gbps = 10.5; doca_telemetry_exporter_metrics_add_gauge(source, timestamp, "bandwidth_gbps", bandwidth_gbps, label_set_id, label_values);   // Integer gauge uint64_t memory_bytes = 1073741824; doca_telemetry_exporter_metrics_add_gauge_uint64(source, timestamp, "memory_usage_bytes", memory_bytes, label_set_id, label_values);


Histograms

Histograms track the distribution of values (observations) across configurable buckets.

Creating and Observing a Histogram

Copy
Copied!
            

double latency_buckets[] = {1.0, 5.0, 10.0, 25.0, 50.0, 100.0, 500.0, 1000.0}; const char *label_values[] = {"tcp"}; doca_telemetry_exporter_histogram_id_t histogram_id;   // Create the histogram definition result = doca_telemetry_exporter_metrics_add_histogram( source, timestamp, "latency_ms", latency_buckets, 8, // 8 bucket boundaries label_set_id, label_values, &histogram_id );   // Record observations doca_telemetry_exporter_metrics_histogram_observe(source, histogram_id, 15.3); doca_telemetry_exporter_metrics_histogram_observe(source, histogram_id, 8.7); doca_telemetry_exporter_metrics_histogram_observe(source, histogram_id, 42.1);


Base Histogram (Templates)

For metrics that require multiple label combinations, use a base histogram as a template.

Copy
Copied!
            

doca_telemetry_exporter_base_histogram_id_t base_histogram_id;   // Create base histogram template result = doca_telemetry_exporter_metrics_add_base_histogram( source, "latency_ms", latency_buckets, 8, label_set_id, 1000, // flush_interval_ms &base_histogram_id );   // Observe with specific label values (creates instance automatically) const char *tcp_labels[] = {"tcp"}; doca_telemetry_exporter_histogram_id_t tcp_histogram_id;   doca_telemetry_exporter_metrics_base_histogram_observe( source, base_histogram_id, tcp_labels, 15.3, &tcp_histogram_id );

Best Practices

Flushing Metrics

Metrics are buffered internally. Configure periodic automatic flushing for frequent exports, and always flush before program exit.

Copy
Copied!
            

// Configure automatic flush (e.g., every 1 second) doca_telemetry_exporter_metrics_set_flush_interval_ms(source, 1000);   // Flush manually before destruction doca_telemetry_exporter_metrics_flush(source);


Label Cardinality

Keep the total number of unique label combinations reasonable to avoid high memory usage and backend strain.

  • Good: Low cardinality labels (e.g., interface names, status codes).

  • Bad: High cardinality labels (e.g., random flow IDs, unique request IDs).

  • Recommendation: Keep total unique label combinations under 10,000.

Metric Naming Conventions

For Prometheus compatibility, adhere to the following naming standards:

  • Format: snake_case (e.g., network_bandwidth_gbps).

  • Units: Suffix with the unit (e.g., _bytes, _seconds).

  • Counters: End with _total (e.g., requests_total).

  • Gauges: Reflect current state (e.g., memory_usage_bytes).

Error Handling

Always check return values (doca_error_t) for all metrics functions.

Copy
Copied!
            

if (result != DOCA_SUCCESS) { DOCA_LOG_ERR("Failed to add counter: %s", doca_error_get_descr(result)); }


Cleanup

Properly destroy resources in reverse order of creation.

Copy
Copied!
            

doca_telemetry_exporter_metrics_flush(source); doca_telemetry_exporter_metrics_destroy_context(source); doca_telemetry_exporter_source_destroy(source); doca_telemetry_exporter_schema_destroy(schema);

Refer to DOCA Library APIs, for more detailed information on DOCA Telemetry Exporter API.

Note

The pkg-config ( *.pc file) for the DOCA Telemetry Exporter library is doca-telemetry-exporter .

The following sections provide additional details about the library API.

Some attributes are optional as they are initialized with default values. Refer to the documentation of the setter functions of respective attributes for more information.

DOCA Telemetry Exporter Buffer Attributes

Buffer attributes are used to set the internal buffer size and data root used by all DOCA sources in the schema.

Configuring the attributes is optional as they are initialized with default values.

Copy
Copied!
            

doca_telemetry_exporter_schema_set_buffer_size(doca_schema, 16 * 1024); /* 16KB - arbitrary value */ doca_telemetry_exporter_schema_set_buffer_data_root(doca_schema, "/opt/mellanox/doca/services/telemetry/data/");

  • buffer_size [in] – the size of the internal buffer which accumulates the data before sending it to the outputs. Data is sent automatically once the internal buffer is full. Larger buffers mean fewer data transmissions and vice versa.

  • data_root [in] – the path to where data is stored (if file_write_enabled is set to true). See section "DOCA Telemetry Exporter File Write Attributes".

DOCA Telemetry Exporter File Write Attributes

File write attributes are used to enable and configure data storage to the file system in binary format.

Configuring the attributes is optional as they are initialized with default values.

Copy
Copied!
            

doca_telemetry_exporter_schema_set_file_write_enabled(doca_schema); doca_telemetry_exporter_schema_set_file_write_max_size(doca_schema, 1 * 1024 * 1024); /* 1 MB */ doca_telemetry_exporter_schema_set_file_write_max_age(doca_schema, 60 * 60 * 1000000L); /* 1 Hour */

  • file_write_enable [in] – use this function to enable storage. Storage/FileWrite is disabled by default.

  • file_write_max_size [in] – maximum file size (in bytes) before a new file is created.

  • file_write_max_age [in] – maximum file age (in microseconds) before a new file is created.

DOCA Telemetry Exporter IPC Attributes

IPC attributes are used to enable and configure IPC transport. IPC is disabled by default.

Configuring the attributes is optional as they are initialized with default values.

Note

It is important to make sure that the IPC location matches the IPC location used by DTS, otherwise IPC communication will fail.

Copy
Copied!
            

doca_telemetry_exporter_schema_set_ipc_enabled(doca_schema); doca_telemetry_exporter_schema_set_ipc_sockets_dir(doca_schema, "/path/to/sockets/"); doca_telemetry_exporter_schema_set_ipc_reconnect_time(doca_schema, 100); /* 100 milliseconds */ doca_telemetry_exporter_schema_set_ipc_reconnect_tries(doca_schema, 3); doca_telemetry_exporter_schema_set_ipc_socket_timeout(doca_schema, 3 * 1000) /* 3 seconds */

  • ipc_enabled [in] – use this function to enable communication. IPC is disabled by default.

  • ipc_sockets_dir [in] – a directory that contains UDS for IPC messages. Both the telemetry exporter program and DTS must use the same folder. DTS that runs on BlueField as a container has the default folder /opt/mellanox/doca/services/telemetry/ipc_sockets.

  • ipc_reconnect_time [in] – maximum reconnection time in milliseconds after which the client is considered disconnected.

  • ipc_reconnect_tries [in] – maximum reconnection attempts.

  • ipc_socket_timeout [in] – timeout for the IPC socket.

DOCA Telemetry Exporter Source Attributes

Source attributes are used to create proper folder structure. All the data collected from the same host is written to the source_id folder under data root.

Note

Sources attributes are mandatory and must be configured before invoking doca_telemetry_exporter_source_start().

Copy
Copied!
            

doca_telemetry_exporter_source_set_id(doca_source, "example_source"); doca_telemetry_exporter_source_set_tag(doca_source, "example_tag");

  • source_id [in] – describes the data's origin. It is recommended to set it to the hostname. In later dataflow steps, data is aggregated from multiple hosts/DPUs and source_id helps navigate in it.

  • source_tag [in] – a unique data identifier. It is recommended to set it to describe the data collected in the application. Several telemetry exporter apps can be deployed on a single node (host/DPU). In that case, each telemetry data would have a unique tag and all of them would share a single source_id.

DOCA Telemetry Exporter Netflow Collector Attributes

DOCA Telemetry Exporter NetFlow API attributes are optional and should only be used for debugging purposes. They represent the NetFlow collector's address while working locally, effectively enabling the local NetFlow exporter.

Copy
Copied!
            

doca_telemetry_exporter_netflow_set_collector_addr("127.0.0.1"); doca_telemetry_exporter_netflow_set_collector_port(6343);

  • collector_addr [in] – NetFlow collector's address (IP or name). Default value is NULL.

  • collector_port [in] – NetFlow collector's port. Default value is DOCA_NETFLOW_DEFAULT_PORT (2055).

doca_telemetry_exporter_source_report

The source report function is the heart of communication with the DTS. The report operation causes event data to be allocated to the internal buffer. Once the buffer is full, data is forwarded onward according to the set configuration.

Copy
Copied!
            

doca_error_t doca_telemetry_exporter_source_report(struct doca_telemetry_exporter_source *doca_source, doca_telemetry_exporter_type_index_t index, void *data, int count);

  • doca_source [in] – a pointer to the doca_telemetry_exporter_source which reports the event

  • index [in] – the event type index received when the schema was created

  • data [in] – a pointer to the data buffer that needs to be sent

  • count [in] – numbers of events to be written to the internal buffer

The function returns DOCA_SUCCESS if successful, or a doca_error_t if an error occurs. If a memory-related error occurs, try a larger buffer size that matches the event's size.

doca_telemetry_exporter_schema_add_type

This function allows adding a reusable telemetry data struct, also known as a schema. The schema allows sending a predefined data structure to the telemetry service. Note that it is mandatory to define a schema for proper functionality of the library. After adding the schemas, one needs to invoke the schema start function.

Copy
Copied!
            

doca_error_t doca_telemetry_exporter_schema_add_type(struct doca_telemetry_exporter_schema *doca_schema, const char *new_type_name, struct doca_telemetry_exporter_type *type, doca_telemetry_exporter_type_index_t *type_index);

  • doca_schema [in] – a pointer to the schema to which the type is added

  • new_type_name [in] – name of the new type

  • fields [in] – user-defined fields to be used for the schema. Multiple fields can (and should) be added.

  • type_index [out] – type index for the created type is written to this output variable

The function returns DOCA_SUCCESS if successful, or doca_error_t if an error occurs.

DOCA Telemetry Exporter Metrics

The Metrics API provides functions for programmatic metrics collection and export. These functions are used in conjunction with the core DOCA Telemetry Exporter API to report performance metrics.

Return Values:

All functions return doca_error_t with DOCA_SUCCESS on success or error codes on failure. Common error codes include:

  • DOCA_ERROR_INVALID_VALUE – NULL parameters or invalid arguments.

  • DOCA_ERROR_NO_MEMORY – Memory allocation failure.

See doca_telemetry_exporter.h for detailed function signatures and parameters.

The Metrics API functions are organized into the following five categories:

DOCA Telemetry Exporter Metrics Context Management

These functions manage the lifecycle and state of the metrics context.

Function Name

Description

doca_telemetry_exporter_metrics_create_context

Creates and initializes the metrics context.

doca_telemetry_exporter_metrics_destroy_context

Destroys the metrics context and frees resources.

doca_telemetry_exporter_metrics_flush

Flushes remaining buffered metrics to exporters.


DOCA Telemetry Exporter Metrics Configuration

These functions configure the behavior of the metrics collection, including flushing and labeling.

Function Name

Description

doca_telemetry_exporter_metrics_set_flush_interval_ms

Sets periodic automatic flush interval in milliseconds.

doca_telemetry_exporter_metrics_set_min_sample_interval_us

Sets minimum time between samples per time series.

doca_telemetry_exporter_metrics_add_constant_label

Adds a constant label to all metrics reported by the source.

doca_telemetry_exporter_metrics_add_label_names

Defines a label set (list of label names) and returns its ID.


DOCA Telemetry Exporter Metrics Counters

Functions for reporting monotonically increasing values.

Function Name

Description

doca_telemetry_exporter_metrics_add_counter

Reports a counter with an absolute value.

doca_telemetry_exporter_metrics_add_counter_increment

Increments a counter by a specified value.


DOCA Telemetry Exporter Metrics Gauges

Functions for reporting values that can arbitrarily increase or decrease.

Function Name

Description

doca_telemetry_exporter_metrics_add_gauge

Reports a gauge with a double precision value.

doca_telemetry_exporter_metrics_add_gauge_uint64

Reports a gauge with a uint64_t value.


DOCA Telemetry Exporter Metrics Histograms

Functions for creating, observing, and managing histograms.

Function Name

Description

doca_telemetry_exporter_metrics_add_histogram

Creates a histogram instance with specific label values.

doca_telemetry_exporter_metrics_add_base_histogram

Creates a base histogram template for use with multiple label sets.

doca_telemetry_exporter_metrics_histogram_observe

Records a value in a specific histogram instance.

doca_telemetry_exporter_metrics_base_histogram_observe

Records a value in a base histogram using specific label values.

doca_telemetry_exporter_metrics_histogram_flush

Flushes data for a specific histogram immediately.

doca_telemetry_exporter_metrics_histogram_remove

Removes a histogram instance from the context.

doca_telemetry_exporter_metrics_set_histogram_flush_interval_target

Sets the flush interval target for a specific histogram.

The internal data format consists of 2 parts: A schema containing metadata, and the actual binary data. When data is written to storage, the data schema is written in JSON format, and the data is written as binary files. In the case of IPC transport, both schema and binary data are sent to DTS. In the case of export, data is converted to the formats required by exporter.

Adding custom event types to the schema can be done using doca_telemetry_exporter_schema_add_type API call.

Note

See available DOCA_TELEMETRY_EXPORTER_FIELD_TYPEs in doca_telemetry_exporter.h. See example of usage in /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export/telemetry_export_sample.c.

Note

It is highly recommended to have the timestamp field as the first field since it is required by most databases. To get the current timestamp in the correct format use:

Copy
Copied!
            

doca_error_t doca_telemetry_exporter_get_timestamp(doca_telemetry_exporter_timestamp_t *timestamp);

This section describes available exporters:

  • IPC

  • NetFlow

  • Fluent Bit

  • Prometheus Endpoint

  • Prometheus Remote-Write

  • Open Telemetry

Fluent Bit and Prometheus exporters are presented in both API and DTS. Even though DTS export is preferable, the API has the same possibilities for development flexibility.

Inter-process Communication

IPC transport automatically transfers the data from the telemetry-exporter-based program to DTS service.

It is implemented as a UNIX domain socket (UDS) sockets for short messages and shared memory for data. DTS and the telemetry-exporter-based program must share the same ipc_sockets directory.

When IPC transport is enabled, the data is sent from the DOCA-telemetry-exporter-based application to the DTS process via shared memory.

To enable IPC, use the doca_telemetry_exporter_schema_set_ipc_enabled API function.

Note

IPC transport relies on system folders. For the host's usage, run the DOCA-telemetry-exporter-API-based application with sudo to be able to use IPC with system folders.

To check the IPC status for the current context, use:

Copy
Copied!
            

doca_error_t doca_telemetry_exporter_check_ipc_status(struct doca_telemetry_exporter_source *doca_source, doca_telemetry_exporter_ipc_status_t *status)

If IPC is enabled and for some reason connection is lost, it would try to automatically reconnect on every report's function call.

Using IPC with Non-container Application

When developing and testing a non-container DOCA Telemetry-Exporter-based program and its IPC interaction with DTS, some modifications are necessary in DTS's deployment for the program to interact with DTS over IPC:

  • Shared memory mapping should be removed: telemetry-ipc-shm

  • Host IPC should be enabled: hostIPC

File before the change:

Copy
Copied!
            

spec: hostNetwork: true volumes: - name: telemetry-service-config hostPath: path: /opt/mellanox/doca/services/telemetry/config type: DirectoryOrCreate ... - name: telemetry-ipc-shm hostPath: path: /dev/shm/telemetry type: DirectoryOrCreate containers: ... volumeMounts: - name: telemetry-service-config mountPath: /config ... - name: telemetry-ipc-shm mountPath: /dev/shm

File after the change:

Copy
Copied!
            

spec: hostNetwork: true hostIPC: true volumes: - name: telemetry-service-config hostPath: path: /opt/mellanox/doca/services/telemetry/config type: DirectoryOrCreate ... containers: ... volumeMounts: - name: telemetry-service-config mountPath: /config

These changes ensure that a DOCA-based program running outside of a container is able to communicate with DTS over IPC.

NetFlow

When the NetFlow exporter is enabled (NetFlow Collector Attributes are set), it sends the NetFlow data to the NetFlow collector specified by the attributes: Address and port. This exporter must be used when using DOCA Telemetry Exporter NetFlow API.

Fluent Bit

Fluent Bit export is based on fluent_bit_configs with .exp files for each destination. Every export file corresponds to one of Fluent Bit's destinations. All found and enabled .exp files are used as separate export destinations. Examples can be found after running DTS container under its configuration folder (/opt/mellanox/doca/services/telemetry/config/fluent_bit_configs/).

All .exp files are documented in-place.

Copy
Copied!
            

DPU# ls -l /opt/mellanox/doca/services/telemetry/config/fluent_bit_configs/ /opt/mellanox/doca/services/telemetry/config/fluent_bit_configs/: total 56 -rw-r--r-- 1 root root 528 Oct 11 07:52 es.exp -rw-r--r-- 1 root root 708 Oct 11 07:52 file.exp -rw-r--r-- 1 root root 1135 Oct 11 07:52 forward.exp -rw-r--r-- 1 root root 719 Oct 11 07:52 influx.exp -rw-r--r-- 1 root root 571 Oct 11 07:52 stdout.exp -rw-r--r-- 1 root root 578 Oct 11 07:52 stdout_raw.exp -rw-r--r-- 1 root root 2137 Oct 11 07:52 ufm_enterprise.fset

Fluent Bit .exp files have 2-level data routing:

  • source_tags in .exp files (documented in-place)

  • Token-based filtering governed by .fset files (documented in ufm_enterprise.fset)

To run with Fluent Bit exporter, set enable=1 in required .exp files and set the environment variables before running the application:

Copy
Copied!
            

export FLUENT_BIT_EXPORT_ENABLE=1 export FLUENT_BIT_CONFIG_DIR=/path/to/fluent_bit_configs export LD_LIBRARY_PATH=/opt/mellanox/collectx/lib


Prometheus Endpoint

Prometheus exporter sets up endpoint (HTTP server) which keeps the most recent events data as text records.

The Prometheus server can scrape the data from the endpoint while the DOCA-Telemetry-Exporter-API-based application stays active.

Check the generic example of Prometheus records:

Copy
Copied!
            

event_name_1{label_1="label_1_val", label_2="label_2_val", label_3="label_3_val", label_4="label_4_val"} counter_value_1 timestamp_1 event_name_2{label_1="label_1_val", label_2="label_2_val", label_3="label_3_val", label_4="label_4_val"} counter_value_2 timestamp_2 ...

Labels are customizable metadata which can be set from data file. Events names could be filtered by token-based name-match according to .fset files.

Set the following environment variables before running.

Copy
Copied!
            

# Set the endpoint host and port to enable export. export PROMETHEUS_ENDPOINT=http://0.0.0.0:9101   # Set indexes as a comma-separated list to keep data for every index field. In # this example most recent data will be kept for every record with unique # `port_num`. If not set, only one data per source will be kept as the most # recent. export PROMETHEUS_INDEXES=Port_num   # Set path to a file with Prometheus custom labels. Use labels to store # information about data source and indexes. If not set, the default labels # will be used. export CLX_METADATA_FILE=/path/to/labels.txt   # Set the folder which contains fset-files. If set, Prometheus will scrape # only filtered data according to fieldsets. export PROMETHEUS_CSET_DIR=/path/to/prometheus_cset

Note

To scrape the data without the Prometheus server, use:

Copy
Copied!
            

curl -s http://0.0.0.0:9101/metrics

Or:

Copy
Copied!
            

curl -s http://0.0.0.0:9101/{fset_name}


Prometheus Remote Write

The Prometheus remote write exporter sends time-series metrics to a remote Prometheus receiver using the Prometheus remote-write protocol.

To use the Prometheus Remote-Write exporter, set the CLX_REMOTE_WRITE_RECEIVER environment variable to the receiver's address before running:

Copy
Copied!
            

export CLX_REMOTE_WRITE_RECEIVER=http://$IP:$PORT/api/v1/write

Replace $IP and $PORT with the receiver's IP address and port (default port is 9090).

Open Telemetry

Open Telemetry exporter streams telemetry to remote OTLP receiver. The supported transport is http.

To run with Open Telemetry exporter, set the following environment variables before running.

Copy
Copied!
            

export CLX_OPEN_TELEMETRY_RECEIVER=http://$IP:$PORT/api/v1/write # set the IP and PORT with the receiver address (default port is 9502)


This section provides DOCA Telemetry Exporter sample implementations on top of the BlueField DPU.

The telemetry exporter samples in this document demonstrate an initial recommended configuration that covers two use cases:

  • Standard DOCA Telemetry Exporter data

  • DOCA Telemetry Exporter for NetFlow data

The telemetry exporter samples run on the BlueField. If write-to-file is enabled, telemetry data is stored to BlueField's storage. If inter-process communication (IPC) is enabled, data is sent to the DOCA Telemetry Service (DTS) running on the same BlueField.

For information on initializing and configuring DTS, refer to DOCA Telemetry Service Guide.

Info

All the DOCA samples described in this section are governed under the BSD-3 software license agreement.

Running the Sample

  1. Refer to the following documents:

  2. To build a given sample, run the following command. If you downloaded the sample from GitHub, update the path in the first line to reflect the location of the sample file:

    Copy
    Copied!
                

    cd /opt/mellanox/doca/samples/doca_telemetry_exporter/<sample_name> meson /tmp/build ninja -C /tmp/build

    Info

    The binary doca_<sample_name> will be created under /tmp/build/.

  3. Sample (e.g., telemetry_export) usage:

    Copy
    Copied!
                

    Usage: doca_telemetry_export [DOCA Flags]   DOCA Flags: -h, --help Print a help synopsis -v, --version Print program version information -l, --log-level Set the (numeric) log level for the program <10=DISABLE, 20=CRITICAL, 30=ERROR, 40=WARNING, 50=INFO, 60=DEBUG, 70=TRACE> --sdk-log-level Set the SDK (numeric) log level for the program <10=DISABLE, 20=CRITICAL, 30=ERROR, 40=WARNING, 50=INFO, 60=DEBUG, 70=TRACE> -j, --json <path>                 Parse command line flags from an input json file

  4. For additional information per sample, use the -h option:

    Copy
    Copied!
                

    /tmp/build/doca_<sample_name> -h

Samples

Tip

These samples are also available on GitHub.

Telemetry Export

This sample illustrates how to use the telemetry exporter API. The sample uses a custom schema for telemetry exporter.

The sample logic includes:

  1. Configuring schema attributes.

  2. Initializing schema.

  3. Creating telemetry exporter source.

  4. Creating example events.

  5. Reporting example events via DOCA Telemetry Exporter.

  6. Destroying source and schema.

Reference:

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export/telemetry_export_sample.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export/telemetry_export_main.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export/meson.build

Telemetry Export NetFlow

This sample illustrates how to use the NetFlow functionality of the telemetry exporter API.

The sample logic includes:

  1. Configuring NetFlow attributes.

  2. Initializing NetFlow.

  3. Creating telemetry exporter source.

  4. Starting NetFlow.

  5. Creating example events.

  6. Reporting example events via DOCA Telemetry Exporter.

  7. Destroying NetFlow.

Reference:

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_netflow/telemetry_export_netflow_sample.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_netflow/telemetry_export_netflow_main.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_netflowt/meson.build

Telemetry Export Metrics

This sample illustrates how to use the Metrics API of the telemetry exporter to collect and export performance metrics (counters, gauges) with multi-dimensional labels.

The sample logic includes:

  1. Initializing the telemetry exporter schema and source.

  2. Creating and configuring the metrics context.

  3. Setting flush intervals and adding constant labels.

  4. Defining dynamic label sets (e.g., for network interfaces).

  5. Reporting counter (absolute and incremental) and gauge metrics.

  6. Flushing and destroying the metrics context, source, and schema.

Reference:

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_metrics/telemetry_export_metrics_sample.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_metrics/telemetry_export_metrics_main.c

  • /opt/mellanox/doca/samples/doca_telemetry_exporter/telemetry_export_metrics/meson.build

© Copyright 2025, NVIDIA. Last updated on Dec 18, 2025