• English日本語한국어
  • Log inStart now

Collector for Prometheus

You can collect metrics from any software that exposes Prometheus metrics with the OpenTelemetry collector by using the community Prometheus receiver. The collector is a component of OpenTelemetry that collects, processes, and exports telemetry data to New Relic (or any observability backend).

Tip

If you're looking for help with other collector use cases, see the newrelic-opentelemetry-examples repository.

Complete the steps below to collect Prometheus metrics.

Check for these prerequisites

If you haven't already:

  • Sign up for a New Relic account.
  • In your target app, make sure you're exposing the Prometheus metrics endpoint so it is accessible to the Prometheus receiver component in the OpenTelemetry collector.
    • The Prometheus metrics endpoint could be enabled by default or you may need do do additional configuration to enable it.
    • Some software may require a third-party Prometheus exporter to expose metrics.
  • Install the OpenTelemetry collector by following the steps in the OpenTelemetry docs.
  • You can use any distribution so long as they have these two components: OTLP/HTTP exporter and Prometheus receiver

Configure Opentelemetry collector

Update or create a new file called config.yaml and replace the following keys in the file with your own values:

  • Prometheus scrape config:
    • PROMETHEUS_JOBNAME
    • PROMETHEUS_HOSTNAME
    • PROMETHEUS_ENDPOINT_PORT
    • PROMETHEUS_ENDPOINT_PATH (optional, default is /metrics)
  • New Relic License key:
    • NEW_RELIC_LICENSE_KEY
receivers:
prometheus:
config:
scrape_configs:
- job_name: "PROMETHEUS_JOBNAME"
static_configs:
- targets: [ "PROMETHEUS_HOSTNAME:PROMETHEUS_ENDPOINT_PORT" ]
labels:
label_example: VALUE_EXAMPLE
metrics_path: PROMETHEUS_ENDPOINT_PATH
exporters:
otlphttp:
endpoint: https://otlp.nr-data.net
headers:
api-key: NEW_RELIC_LICENSE_KEY
processors:
service:
telemetry:
logs:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch, memory_limiter]
exporters: [otlphttp]

For further configuration options, please review:

Run the collector

Run the Opentelemetry collector. The way to run it may vary depending on the chosen installation method. For example:

/usr/bin/otelcol --config ./config.yaml

Find and use your data

You may use the metrics explorer to check the metrics being ingested. All metrics reported by the OTEL Prometheus receiver are detected by running the following query.

SELECT count(*)
FROM Metric
WHERE instrumentation.provider='opentelemetry' and otel.library.name='otelcol/prometheusreceiver'
FACET metricName

Troubleshooting: metrics names don't match

Prometheus metrics based dashboards and entities use Prometheus metrics naming conventions to match the metrics being reported by the Prometheus endpoints. However, the OpenTelemetry Prometheus receiver uses OpenTelemetry naming conventions by default after v076.3.

To use Prometheus metrics naming conventions, disable the feature-gate pkg.translator.prometheus.NormalizeName when running the OpenTelemetry collector:

bash
$
otelcol-contrib --config ./config.yaml --feature-gates=-pkg.translator.prometheus.NormalizeName
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.