# Elastic

Elastic Observability is a search-powered analytics platform that unifies logs, metrics, traces, and uptime data for actionable insights. This guide explains how to integrate ThousandEyes metrics with Elastic using OpenTelemetry.

For more information about sending metrics to Elastic using OpenTelemetry, see [Elastic Observability: Upstream OpenTelemetry Collectors and language SDKs](https://www.elastic.co/guide/en/observability/current/apm-open-telemetry-direct.html).

## Prerequisites

* You have [created a ThousandEyes test](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms#create-a-test).
* You have obtained the **Managed OTLP endpoint** for your Elastic project:
  1. In the **Elastic project dashboard**, go to **Connection alias**.
  2. Click **Edit**.
  3. Copy the **Managed OTLP endpoint**.

     Example: `https://my-observability-project-e49e89.ingest.us-central1.gcp.elastic.cloud`
* You have generated an Elastic API key:
  1. In your Elastic dashboard, go to **Cloud > Projects**.
  2. Select a project.
  3. In the project dashboard, under **API keys**, click **Manage project API keys**.
  4. Click **+Create API key**.
  5. Enter a **Name**.
  6. Click **Create API key**.

     Copy the API key to use it to send telemetry data to Elastic.

## Stream OpenTelemetry Metrics to Elastic

### Step 1: Create a Metrics Integration

#### Using the ThousandEyes UI

1. In ThousandEyes, go to **Manage > Integration 1.0**.
2. Click **+New Integration** and select **OpenTelemetry Integration**.
3. Enter a **Name** for the integration.
4. Set the **Target** to **GRPC**.
5. For the **Endpoint URL**, enter the **Managed OTLP endpoint** for your Elastic project (see [Prerequisites](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms/elastic#prerequisites)).
6. For **Preset Configurations**, select **Elastic**.
7. For **Auth Type**, select **Custom**.
8. Add the following **Custom Headers**: `"Authorization": "ApiKey {TOKEN}"`.

   Use your Elastic API key. Make sure to prefix it with `ApiKey`. For example: `ApiKey {TOKEN}`.
9. For the OpenTelemetry **Signal**, select **Metric**.
10. For the **Data Model Version**, select **v2**.
11. Select a **test**.

    For more information on creating a test, see [General Setup Instructions](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms#general-setup-instructions).
12. Click **Save**.

#### Using the ThousandEyes API

Create the HTTP stream programmatically:

```curl
curl -v -XPOST https://api.thousandeyes.com/v7/stream \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $BEARER_TOKEN" \
  -d '{
    "type": "opentelemetry",
    "testMatch": [{
      "id": "281474976717575",
      "domain": "cea"
    }],
    "endpointType": "grpc",
    "signal": "metric",
    "streamEndpointUrl": "{STREAM_ENDPOINT_URL}",
    "customHeaders": {
      "Authorization": "ApiKey {TOKEN}"
    }
  }'
```

Replace `{TOKEN}` and `{STREAM_ENDPOINT_URL}` with your Elastic API key and APM endpoint.

### ThousandEyes Dashboard in Elastic

1. In Elastic, go to **Observability > Metrics**.
2. Use **Metrics Explorer** to search for ThousandEyes metrics and apply filters.

![ThousandEyes Dashboard in Elastic](https://1112912342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4QARF6s57qxMrOHDTZ%2Fuploads%2Fgit-blob-29e562a6b1eb75ebd09ac09591ba55db2c99547f%2Felastic-thousandeyes-dashboard.png?alt=media)

## Stream OpenTelemetry Traces to Elastic

### Step 1: Create a Traces Integration

#### Using the ThousandEyes UI

1. In ThousandEyes, go to **Manage > Integration 1.0**.
2. Click **+New Integration** and select **OpenTelemetry Integration**.
3. Enter a **Name** for the integration.
4. Set the **Target** to **GRPC**.
5. For the **Endpoint URL**, enter the **Managed OTLP endpoint** for your Elastic project (see [Prerequisites](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms/elastic#prerequisites)).
6. For **Preset Configurations**, select **Elastic**.
7. For **Auth Type**, select **Custom**.
8. Add the following **Custom Headers**: `"Authorization": "ApiKey {TOKEN}"`

   Use your Elastic API key. Make sure to prefix it with `ApiKey`.

   For example: `ApiKey {TOKEN}`.
9. For the OpenTelemetry **Signal**, select **Trace**.
10. Select a **test**.

    For more information on creating a test, see [General Setup Instructions](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms#general-setup-instructions).
11. Click **Save**.

#### Using the ThousandEyes API

Create the HTTP stream programmatically:

```curl
curl -v -XPOST https://api.thousandeyes.com/v7/stream \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $BEARER_TOKEN" \
  -d '{
    "type": "opentelemetry",
    "testMatch": [{
      "id": "281474976717575",
      "domain": "cea"
    }],
    "endpointType": "grpc",
    "signal": "trace",
    "streamEndpointUrl": "{STREAM_ENDPOINT_URL}",
    "customHeaders": {
      "Authorization": "ApiKey {TOKEN}"
    }
  }'
```

Replace `{TOKEN}` and `{STREAM_ENDPOINT_URL}` with your Elastic API key and APM endpoint.

### Step 2: Visualize Traces in Elastic

1. In Elastic, navigate to **Observability > Applications > Traces**.
2. Select the relevant service.
3. Open the **Traces** view and apply filters.

![ThousandEyes Traces in Elastic](https://1112912342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4QARF6s57qxMrOHDTZ%2Fuploads%2Fgit-blob-6660a392da75c6685076412dd32b16431ea26b2e%2Felastic-traces.png?alt=media)

## Stream OpenTelemetry Logs to Elastic

### Step 1: Create a Logs Integration

#### Using the ThousandEyes UI

1. In ThousandEyes, go to **Manage > Integration 1.0**.
2. Click **+New Integration** and select **OpenTelemetry Integration**.
3. Enter a **Name** for the integration.
4. Set the **Target** to **GRPC**.
5. For the **Endpoint URL**, enter the **Managed OTLP endpoint** for your Elastic project (see [Prerequisites](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms/elastic#prerequisites)).
6. For **Preset Configurations**, select **Elastic**.
7. For **Auth Type**, select **Custom**.
8. Add the following **Custom Headers**: `"Authorization": "ApiKey {TOKEN}"`

   Use your Elastic API key. Make sure to prefix it with `ApiKey`.

   For example: `ApiKey {TOKEN}`.
9. For the OpenTelemetry **Signal**, select **Log**.
10. Select a **test**.

    For more information on creating a test, see [General Setup Instructions](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms#general-setup-instructions).
11. Click **Save**.

#### Using the ThousandEyes API

Create the HTTP stream programmatically:

```curl
curl -v -XPOST https://api.thousandeyes.com/v7/stream \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $BEARER_TOKEN" \
  -d '{
    "type": "opentelemetry",
    "endpointType": "grpc",
    "signal": "log",
    "streamEndpointUrl": "{STREAM_ENDPOINT_URL}",
    "customHeaders": {
      "Authorization": "ApiKey {TOKEN}"
    }
  }'
```

Replace `{TOKEN}` and `{STREAM_ENDPOINT_URL}` with your Elastic API key and APM endpoint.

### Step 2: Visualize Logs in Elastic

1. In Elastic, navigate to **Observability > Discover**.
2. Use the **Logs Explorer** to search for ThousandEyes log entries and apply filters.

   For example: `resource.attributes.thousandeyes.account.id : *`

![ThousandEyes Logs in Elastic](https://1112912342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4QARF6s57qxMrOHDTZ%2Fuploads%2Fgit-blob-830354dd990611646c68dc773b2f874327b00894%2Felastic-logs.png?alt=media)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry/observability-platforms/elastic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
