turbot/prometheus
steampipe plugin install prometheus

Prometheus + Steampipe

Prometheus is an open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.

Query all the labels in your prometheus metrics:

select
name,
values
from
prometheus_label
> select name, values from prometheus_label
+---------------+----------------------------------------------+
| name | values |
+---------------+----------------------------------------------+
| alertname | ["TotalRequests"] |
| alertstate | ["firing"] |
| reason | ["refused","resolution","timeout","unknown"] |
| interval | ["10s"] |
| version | ["2.30.3","go1.17.1"] |
| code | ["200","302","400","500","503"] |
+---------------+----------------------------------------------+

Query data for a given metric (tables are dynamically created):

select
code,
handler,
value
from
prometheus_http_requests_total
+------+----------------------------+-------+
| code | handler | value |
+------+----------------------------+-------+
| 302 | / | 1 |
| 200 | /-/ready | 1 |
| 200 | /api/v1/alerts | 1 |
| 200 | /api/v1/label/:name/values | 421 |
| 200 | /api/v1/labels | 16 |
| 200 | /graph | 1 |
| 200 | /static/*filepath | 4 |
+------+----------------------------+-------+

Documentation

Get started

Install

Download and install the latest Prometheus plugin:

steampipe plugin install prometheus

Configuration

Installing the latest prometheus plugin will create a config file (~/.steampipe/config/prometheus.spc) with a single connection named prometheus:

connection "prometheus" {
plugin = "prometheus"
# The address of your Prometheus.
# Can also be set with the PROMETHEUS_URL environment variable
address = "http://localhost:9090"
metrics = ["prometheus_http_requests_.*", ".*error.*"]
}
  • address - HTTP address of your prometheus server. Can also be set with the PROMETHEUS_URL environment variable.
  • metrics - List of metric expressions to be matched against while creating dynamic metric tables.

Postgres FDW

This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- prometheus

The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.

To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.

CREATE EXTENSION IF NOT EXISTS steampipe_postgres_prometheus;
CREATE SERVER steampipe_prometheus FOREIGN DATA WRAPPER steampipe_postgres_prometheus OPTIONS (config '<your_config>');
CREATE SCHEMA prometheus;
IMPORT FOREIGN SCHEMA prometheus FROM SERVER steampipe_prometheus INTO prometheus;

SQLite Extension

This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- prometheus

The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.

To configure the SQLite extension, load the extension module and then run the steampipe_configure_prometheus function to configure it with plugin-specific options.

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_prometheus.so
sqlite> select steampipe_configure_prometheus('<your_config>');

Export

This plugin is available as a standalone Export 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>' <table_name>