Table: prometheus_target - Query Prometheus Targets using SQL
Prometheus Target is a resource within Prometheus that represents an individual node or endpoint that Prometheus instances are scraping. It provides a detailed view of the target's state, health, and scrape pool, which can be used to monitor the operational status and performance of the target. By querying Prometheus Targets, users can gain insights into the metrics being scraped from each target and the health of the scraping process.
Table Usage Guide
The prometheus_target
table provides insights into individual nodes or endpoints within Prometheus. As a system administrator or a DevOps engineer, this table can be used to explore target-specific details, including its state, health, and scrape pool. Utilize it to uncover information about the performance of each target, the success or failure of the scraping process, and the metrics being collected from each target.
Examples
List all targets
Discover all the monitoring targets in your Prometheus setup, helping you gain a comprehensive view of what metrics are being tracked across your systems. This can be particularly useful for auditing or troubleshooting purposes.
select *from prometheus_target;
select *from prometheus_target;
Targets that are not up
Explore which targets in your Prometheus monitoring system are not currently operational. This can help you quickly identify and address any potential issues, improving system performance and reliability.
select scrape_pool, scrape_url, health, last_scrape, last_errorfrom prometheus_targetwhere health != 'up';
select scrape_pool, scrape_url, health, last_scrape, last_errorfrom prometheus_targetwhere health != 'up';
Targets whose last scrape was more than 24 hrs ago
Identify instances where targets haven't been scanned in the last 24 hours. This is useful for maintaining up-to-date data and ensuring the health of your system.
select scrape_pool, scrape_url, health, last_scrape, last_errorfrom prometheus_targetwhere last_scrape < now() - interval '24 hrs';
select scrape_pool, scrape_url, health, last_scrape, last_errorfrom prometheus_targetwhere datetime(last_scrape) < datetime('now', '-24 hours');
Schema for prometheus_target
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form, e.g. connection_name. | |
discovered_labels | jsonb | Unmodified labels retrieved during service discovery before relabelling has occurred. | |
global_url | text | Global URL to be scraped. | |
health | text | Health of the target, e.g. up. | |
labels | jsonb | Label set after relabelling has occurred. | |
last_error | text | Last error message, if any. | |
last_scrape | timestamp with time zone | Time when the last scrape occurred. | |
last_scrape_duration | double precision | Time in seconds the last scrape took to run. | |
scrape_pool | text | Name of the scrape pool this target belongs to. | |
scrape_url | text | URL to be scraped. | |
state | text | State of the target, e.g. active, dropped. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- prometheus
You can pass the configuration to the command with the --config
argument:
steampipe_export_prometheus --config '<your_config>' prometheus_target