Prometheus exporters typically reside on ports over 9100, apart from a few exceptions (full list of allocations). When configuring your firewall, you should choose the target ports accordingly to only grant access to your designated exporters, and nothing else.
Explore documentation
Better Stack Prometheus metrics scraping
Start scraping metrics in 5 minutes
Better Stack can scrape metrics directly from your Prometheus exporters.
1. Setup
To get started, first you'll need to allow access to your exporters, through your firewall, from our scrape servers. The list of IP addresses we scrape from are:
Global
167.235.220.49,167.235.220.50,167.235.220.51,2a01:4f8:1060:15a8::/64,2a01:4f8:1060:15a9::/64,2a01:4f8:1060:15aa::/64
This list is also available as a text file from https://telemetry.betterstack.com/prometheus-scrape-ips.txt.
All requests made when scraping your metrics will use our standard User-Agent header.
If you currently block on user-agent you will need to allow the scraping user-agent as well.
2. Define your exporter URLs
When creating your source, you can add multiple URLs to scrap:
- Direct metrics endpoints, E.g.,
http://app1.example.com:9100/metrics. - Prometheus HTTP Service Discovery (SD) URLs, we'll automatically discover and scrape services pointed to by the SD URL.
You can use IP addresses or hostnames for connecting to your targets, each on their own line.
To organize your URLs, you can add comments by starting a line with #.
Special labels for HTTP SD targets
When using HTTP Service Discovery, you can use special Prometheus labels on your targets to customize how they are scraped:
| Label | Description |
|---|---|
__scheme__ |
Sets the scheme (http or https) used to scrape the target. |
__metrics_path__ |
Sets the path to scrape metrics from. Defaults to /metrics. |
__param_<name> |
Sets the URL parameter <name> to include in the scrape request. |
For example, an HTTP SD response might look like this:
In this case, the target would be scraped at https://app1.example.com:9100/custom/metrics?module=http_2xx.
Authentication
If your metrics or SD endpoint requires authentication, expand Advanced settings to provide custom headers for your scrape requests.
- For bearer token authentication, add an
Authorizationheader withBearer <token>. - For basic HTTP authentication, provide the username and password directly.
3. Using your metrics
As soon as you save a set of metrics URLs, we will start scraping for metrics. If we're able to connect successfully to your exporters, metrics should be available within about a minute for new sources.
You can use the Prometheus dashboard to immediately see the results for a Prometheus Node Exporter, or create your own dashboard to analyze your metrics.
We automatically add a host metric label for all scraped metrics, set to the host portion of the exporter URL. For example, if the exporter URL is http://app1.example.com:9100/metrics, we will add a host: app1.example.com label to those metrics. This lets you filter/group by host in your charts without having to configure additional Prometheus labels. If a host label is already present on a metric, that value takes precedence.
Does the Prometheus dashboard show unexpected results?
Install Node exporter to use our Prometheus dashboard. The dashboard requires metrics provided by the Node Exporter.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏