Giter Site home page Giter Site logo

prometheus-jdbc-exporter's Introduction

Prometheus JDBC Exporter

Exporter inspired in sql_exporter and jmx_exporter

It uses JDBC libraries to execute a SQL query that returns a Float result and a set of labels.

Getting Started

A YAML configuration file is required.

Here is a sample:

jobs:
- name: "global"
  connections:
  - url: 'jdbc:oracle:thin:@db:1521/ORCLPDB1'
    username: 'system'
    password: 'welcome1'
  queries:
  - name: "db_users"
    help: "Database Users"
    values:
      - "count"
    query:  |
            select count(1) count from dba_users

This configuration contains a list of Jobs and a list of Queries.

The first important part here is the connections object. It has the JDBC URL, username, password.

These are used to create connections to execute the queries defined inside the Job.

This query will create a metric sql_db_users, where sql_ is the exporter prefix.

Configuration

This is a list of all possible options:

1. jobs

Represents a list of jobs that will be executed by the collector.

Values:

name: Name of the job. Required.

connections: List of connection details. At least one.

queries: List of queries to execute. At least one.

jobs:
  - name: "job1"
    connections: ...
    queries: ...

1.1. connection

Represents connection details to connect to a database instance and execute queries.

Values:

url: JDBC URL to connect to database instances. Required.

username: database user's name. Required.

password: database user's password. Required.

connections:
  - url: 'jdbc:oracle:thin:@db:1521/ORCLPDB1'
    username: 'system'
    password: 'welcome1'

1.2. query

Represents query definition to collect metrics from database.

Values:

name: Query name, that will be part of the metric name: jdbc_<query_name>. Required.

help: Query description, that will be used as metric description also. Optional.

values: List of values, that has to match a column value, that must be float. At least one.

query: SQL query to select rows that will represent a metric sample.

query_ref: Reference to common queries shared between jobs.

query and query_ref are mutually exclusive. At least one of those has to be defined.

  queries:
  - name: "db_users"
    help: "Database Users"
    values:
      - "count"
    query:  |
            select count(1) count from dba_users

or with query_ref

  queries:
  - name: "db_users"
    help: "Database Users"
    values:
      - "count"
    query_ref: "query1"

2. queries

Represents common queries that can be referenced from different jobs.

queries:
  query1: |
    SELECT count(1) "COUNT" FROM users

Where query1 is the key that will be used from query definition.

Examples

Go to the examples directory.

Licence

MIT Licenced.

prometheus-jdbc-exporter's People

Contributors

jeqo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.