Skip to content

Latest commit

 

History

History
186 lines (153 loc) · 7.25 KB

File metadata and controls

186 lines (153 loc) · 7.25 KB
title tags metaDescription freshnessValidatedDate redirects
Collector for monitoring HCP Consul metrics
Integrations
Open source telemetry integrations
OpenTelemetry
Consul
HCP
Hashicorp
Networking
Server
Envoy
You can collect metrics from HCP managed Consul using the OpenTelemetry Collector.
2024-02-26
/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/collector/collector-configuration-examples/opentelemetry-collector-hcp-consul

This guide explains how to collect metrics from your HCP-managed Consul deployment using the OpenTelemetry Collector. The collector gathers, processes, and sends telemetry data (including metrics, logs, and traces) to various observability backends, including New Relic.

The setup example below leverages the Prometheus receiver within the collector. It retrieves service metrics directly from HCP Consul's service metrics API and exports them to New Relic's OpenTelemetry endpoint.

HCP Consul offers two types of observability metrics:

Follow the steps below to collect and export HCP Consul metrics to New Relic.

## Review the requirements [#requirements]
  Before you start, you'll need the following:

  * A running Docker daemon service
  * An installed [Docker Compose](https://docs.docker.com/compose/) tool
  * Your [HCP Consul ACL admin token](https://developer.hashicorp.com/hcp/docs/consul/hcp-managed/access#generate-admin-token)
  * Your New Relic <InlinePopover type="licenseKey" /> for the account you want to report data to

</Step>

<Step>
    ## Download or clone the example configuration [#download]

    1. [Download the example Configuration](https://github.com/newrelic/newrelic-opentelemetry-examples).
    2. Once downloaded, locate the directory named `hcp-consul` within the `other-examples/collector` folder of the repository. This directory contains the specific configuration for collecting HCP Consul metrics.
    3. (Optional) Refer to the [README](https://github.com/newrelic/newrelic-opentelemetry-examples/tree/main/other-examples/collector/hcp-consul#readme) for additional details and instructions related to the HCP Consul example.

</Step>

<Step>
  ##  Set environment variables and run the collector [#set-variables-run-collector]

  In the `.env` file:
    * Set the HCP Access Token and Access URL values
    * Set the New Relic API key variable to your New Relic license key
  # Open the HCP Consul example directory
  cd newrelic-opentelemetry-examples/other-examples/collector/hcp-consul

  # Set environment variables.

  # run the collector in docker
  docker compose up
  ### Environment variable information

  If you need more information on the environment variables set above, see the documentation in the following table.

    <table>
      <thead>
        <tr>
          <th style={{ width: "200px"}}>
            Variable
          </th>
          <th>
            Description
          </th>
          <th>
            Docs
          </th>
        </tr>
        </thead>
        <tbody>
          <tr>
            <td>
              `NEW_RELIC_API_KEY`
            </td>
            <td>
              New Relic Ingest API Key
            </td>
            <td>
              [Learn about API keys](/docs/apis/intro-apis/new-relic-api-keys/)
            </td>
          </tr>
          <tr>
            <td>
              `NEW_RELIC_OTLP_ENDPOINT`
            </td>
            <td>
              The default US New Relic OTLP endpoint is `https://otlp.nr-data.net:4318`.
            </td>
            <td>
              [Review OTLP endpoint configurations](/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/best-practices/opentelemetry-otlp)
            </td>
          </tr>
          <tr>
            <td>
              `HCP_ACCESS_TOKEN`
            </td>
            <td>
              ACL Admin token for HCP Consul
            </td>
            <td>
              [Create an ACL admin token](https://developer.hashicorp.com/hcp/docs/consul/hcp-managed/access#generate-admin-token)
            </td>
          </tr>
          <tr>
            <td>
              `HCP_ACCESS_URL`
            </td>
            <td>
              URL to access your specific Consul server
            </td>
            <td>
              [Locate your access URL](https://developer.hashicorp.com/hcp/docs/consul/hcp-managed/access#get-access-url)
            </td>
          </tr>
        </tbody>
    </table>

</Step>
<Step>
  ## Forward HCP Consul Envoy metrics to New Relic [#forward-envoy-metrics]

    To monitor HCP Consul Envoy metrics in New Relic, you can configure the OpenTelemetry collector built into your HCP Consul cluster to forward metrics to your own collector. This can include the collector running in this example.


    1. Add an HTTP receiver to the OpenTelemetry collector. You can add this into the `receivers` group in the example `collector.yaml` file:

      ```yaml
        receivers:
          otlp:
            protocols:
              http:
      ```
    This will add a receiver listening at `0.0.0.0:4318`.

    2. Configure your HCP Consul cluster to forward Envoy metrics to this receiver. This can be configured from the `telemetryCollector` stanza in your HCP Consul configuration file. For example:

      ```yaml
          telemetryCollector:
            enabled: true
            customExporterConfig: |-
              {
                "exporter_config": {
                  "otlphttp": {
                    "endpoint": "0.0.0.0:4318",
                    "headers": {
                      "authorization": "<auth>"
                    },
                    "timeout": "2s"
                  }
                }
              }

      ```

</Step>
<Step>

   ## View your data in New Relic [#view-data]

  In New Relic, you can view your HCP Consul data in a few different places:

  * Navigate to the [New Relic marketplace](https://one.newrelic.com/marketplace) and search for "consul". Click one of the dashboards to quickly install it for your account.
  * Navigate to the metrics explorer and filter for `consul`, or `envoy` for Envoy metrics. This data can be added to any custom alert or dashboard.

<Callout variant="tip">
  To view all metrics available with this HCP Consul server integration, reference the [documentation here](https://developer.hashicorp.com/consul/docs/agent/telemetry#metrics-reference).
</Callout>

</Step>