All Projects → weaveworks → Prometheus_sql_exporter

weaveworks / Prometheus_sql_exporter

Licence: apache-2.0
A service that exposes user-specified SQL queries on a prometheus metrics endpoint

Programming Languages

go
31211 projects - #10 most used programming language

CircleCI Go Report Card Coverage Status

prometheus_sql_exporter

The Prometheus SQL Exporter (PROSE) is a tool that converts user-specified SQL queries into Prometheus metrics. It has the following features

  • Create any number of Prometheus gauges
  • Attach any number of raw SQL queries to a Prometheus gauge
  • Support PostgreSQL and MySQL

Caveats:

  • Only gauges are supported
  • All SQL queries must return a single integer metric (e.g. count())

Getting started

It is intended that this tool is used as a Docker container.

To use with Kubernetes, use a manifest that looks like the provided example

CLI Arguments

$ docker run -it quay.io/weaveworks/prometheus_sql_exporter --help
This service will monitor a database for specified queries and expose them to prometheus

Usage:
prose [flags]
prose [command]

Available Commands:
version     Output the version of prose

Flags:
    --dbsource string   Database source name; includes the DB driver as the scheme. E.g. postgres://user:[email protected]:5432/database?sslmode=disable or mysql://user:[email protected](localhost:3306)/database?tls=skip-verify
    --listen string     Listen address for API clients (default ":80")
    --queries string    Path to yaml file which describes metrics and queries (default "queries.yaml")

Use "prose [command] --help" for more information about a command.

Queries configuration

Below is an example queries yaml file:

gauges:
- gauge:
  namespace: "mynamespace"
  subsystem: "mysubsystem"
  name: "some_name"
  label: "state"
  queries:
  - name: "number"
    query: "SELECT count(1) FROM database WHERE id > 10"
  - name: "ok"
    query: "SELECT count(1) FROM database"
...
  • gauges is a list of Prometheus gauges
  • gauge is a single instance
  • namespace, subsystem, and name form the name of the Prometheus object
  • label is the Prometheus label corresponding to the queries
  • queries is a list of queries to perform
  • queries.name is a name applied to the label.
  • queries.query is the SQL query to perform on the DB.

This configuration will produce two Prometheus metrics, in the form:

# HELP mynamespace_mysubsystem_some_name Prose Guage for some_name
# TYPE mynamespace_mysubsystem_some_name gauge
mynamespace_mysubsystem_some_name{state="number"} 90
mynamespace_mysubsystem_some_name{state="ok"} 100

Development

The build lifecycle is controlled by the Makefile. See the Makefile for details

Release

To perform a release, create a new GH release.

Getting Help

If you have any questions about, feedback for or problems with prometheus_sql_exporter:

Weaveworks follows the CNCF Code of Conduct. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a Weaveworks project maintainer, or Alexis Richardson ([email protected]).

Your feedback is always welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].