Collecting Prometheus metrics with the OpenTelemetry collector
The first step in integrating the OpenTelemetry collector with Prometheus is to get metric data. There are myriad ways to get metric data into the OpenTelemetry collector, but we’ll operate based on the assumption that we’re collecting data from things that already expose Prometheus metrics. In order to collect data from those applications, we can use the prometheus
receiver from the OpenTelemetry collector contrib repository.
The prometheus
receiver supports all of the same configuration settings that Prometheus itself supports within its scrape_configs
section (including service discovery!). Consequently, if you’ve made it this far, it should be easy to configure.
To keep things simple, we’ll just configure the OpenTelemetry collector to scrape itself. Rather than sending data to Prometheus just yet, we’ll use the debug
exporter to output data directly to our terminal instead.