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).
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.
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 exporter and Prometheus receiver
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_ENDPOINT_PATH(optional, default is /metrics)
- 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_EXAMPLEmetrics_path: PROMETHEUS_ENDPOINT_PATHexporters:otlp:endpoint: https://otlp.nr-data.net:4317headers:api-key: NEW_RELIC_LICENSE_KEYprocessors:service:telemetry:logs:pipelines:metrics:receivers: [prometheus]processors: [batch, memory_limiter]exporters: [otlp]
For further configuration options, please review:
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
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 MetricWHERE instrumentation.provider='opentelemetry' and otel.library.name='otelcol/prometheusreceiver'FACET metricName
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:
$otelcol-contrib --config ./config.yaml --feature-gates=-pkg.translator.prometheus.NormalizeName