# Monitoring with Open Telemetry (OTel)

This page describes how to use the OpenTelemetry (OTel) Collector to import monitoring data from an Aerospike Database cluster and export it to the infrastructure and application monitoring tools of your choice. You can also use the Aerospike Prometheus Exporter to scrape monitoring data from the cluster before processing by the OTel Collector.

Aerospike publishes Docker Compose configurations on [GitHub](https://github.com/aerospike/aerospike-monitoring/tree/master/examples/otel) that package the following Docker containers and configuration files:

::: note
These containers are assumed to run on the same host as a single-node Aerospike cluster.
:::

-   [opentelemetry-collector-contrib](https://hub.docker.com/r/otel/opentelemetry-collector-contrib) - OpenTelemetry Collector, a vendor-agnostic tool that can ingest and export telemetry data in a wide variety of formats. Includes OTel Collector configuration files, in YAML format, for sending data to specific monitoring tools.
-   [aerospike-prometheus-exporter](https://hub.docker.com/r/aerospike/aerospike-prometheus-exporter) - Aerospike Prometheus Exporter, a tool that exposes Aerospike database metrics so that they can be scraped by Prometheus. This is included in the Docker Compose stack, but is not required for all workflows.

The following image illustrates the use of Aerospike Prometheus Exporter with various cloud endpoints. Aerospike provides [example configuration files](#configure-the-otel-collector) for the OTel Collector. Use these files as a guide for connecting to other endpoints that support data in the same format.

 ![Exporter OTel collector](https://aerospike.com/docs/_astro/aerospike_exporter_otel_collector.BUHsY1eC_2uhoxh.png)

Figure 1: Exporter OTel collector

## Prerequisites

A single-node Aerospike Database cluster with the service port accessible from port 3000 of the host where the monitoring stack is deployed. If you need a cluster for testing, you can deploy one in a container using the following Docker command:

Terminal window

```bash
$ docker run -tid --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 aerospike/aerospike-server-enterprise:latest
```

Aerospike Prometheus Exporter can push data to OTel endpoints through a direct connection to an OTel endpoint or by using the [OTel Collector](https://opentelemetry.io/docs/collector/). The following sections describe these two approaches.

## Configure a direct connection to OTel endpoints

Modify the Aerospike Prometheus Exporter `ape.toml` config file with the OTel endpoints.

::: note
Currently Exporter supports only [gRPC endpoints](https://grpc.io/docs/what-is-grpc/introduction/).
:::

Change the OTel configuration parameters under `Agent.OpenTelemetry` in `ape.toml`.

```toml
service_name = # application service to appear in the observability site

endpoint = # endpoint of the OTel provider without any protocol or port number

endpoint_tls_enabled = # boolean

headers = # mention the auth api-key as key=value pair here, multiple key/values can be provided as comma-separated values
```

Example:

```toml
service_name = "aerospike-cluster-checkout-system"

endpoint = "otlp.nr-data.net"

endpoint_tls_enabled = false

headers = {api-key="newrelic-auth-key"}
```

## Configure the OTel Collector

The OTel collector passes data to a number of external endpoints defined in a configuration file.

Visit the [OTel Aerospike monitoring stack GitHub page](https://github.com/aerospike/aerospike-monitoring/tree/master/examples/otel) for example configuration files that you can use with the OTel Collector.

::: note
Update the API Key or Access Key in the respective configuration files.
:::

### New Relic

Modify `newrelic-otel-collector-config.yml` and update the following keys with the appropriate values for your deployment:

```yaml
otlp:

    endpoint: https://otlp.nr-data.net:4317

    headers:

      api-key: NEWRELIC-API-KEY
```

To start the stack, run `docker-compose -f newrelic-docker-compose.yml up`. To stop the stack, run `docker-compose -f newrelic-docker-compose.yml down`. Visit [New Relic cloud](https://one.newrelic.com/data-explorer) to see Aerospike metrics.

### Datadog

Modify `datadog-otel-collector-config.yml` and update the following keys with the appropriate values for your deployment:

```yaml
datadog:

    api:

        site: datadoghq.com

        key: DATADOG-APP-KEY
```

To start the stack, run `docker-compose -f datadog-docker-compose.yml up`. To stop the stack, run `docker-compose -f datadog-docker-compose.yml down`. Visit [Datadog cloud](https://app.datadoghq.com/metric/explorer) to see Aerospike metrics.

### DynaTrace

Modify `dynatrace-otel-collector-config.yml` and update the following keys with the appropriate values for your deployment:

```yaml
dynatrace:

    prefix: as_dynatrace_demo

    endpoint:  https://YOUR-ENVIRONMENT-ID.live.dynatrace.com/api/v2/metrics/ingest

    api_token: DYNATRACE-APP-TOKEN
```

To start the stack, run `docker-compose -f dynatrace-docker-compose.yml up`. To stop the stack, run `docker-compose -f dynatrace-docker-compose.yml down`. Visit [DynaTrace Cloud](https://docs.dynatrace.com/docs/observe-and-explore/metrics-classic/built-in-metrics) to see Aerospike metrics.

See [OTel-DynaTrace-documentation](https://aws-otel.github.io/docs/partners/dynatrace)

### Amazon CloudWatch

Modify `cloudwatch-docker-compose.yml` and update the following keys with the appropriate values for your deployment:

```yaml
AWS_REGION=AWS-REGION-LOCATION

AWS_ACCESS_KEY_ID=

AWS_SECRET_ACCESS_KEY=
```

To start the stack, run `docker-compose -f cloudwatch-docker-compose.yml up`. To stop the stack, run `docker-compose -f cloudwatch-docker-compose.yml down`. Visit [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html) to see Aerospike metrics.