chop-dbhi / prometheus-sql

Service that exposes Prometheus metrics for a SQL result set.
BSD 2-Clause "Simplified" License
202 stars 55 forks source link

Simple Counter #3

Closed gimler closed 7 years ago

gimler commented 8 years ago

i try to get the exporter to work with grafana.

queries.yml

licenses:
    driver: mysql

    connection:
        host: db
        port: 3306
        user: root
        password: ...
        database: ...

    sql: >
        SELECT count(id) as number
        FROM user
        WHERE active = 'Y'

    identifier: number

    interval: 1h

Under /state/licenses i get [{"number":"34"}]

How can i access this value number in grafana?

bruth commented 8 years ago

Hi @gimler. This service was designed to determine the changes between result sets over time and emit metrics of the changes that occurred. You can see the four metrics here. Sorry if that was a bit confusing by the name of the project since it is general. That being said, support for other query types could be worth considering.

wangyanbn commented 7 years ago

@gimler , access http://localhost:8080/metrics to see the metrics for Prometheus. In Prometheus you may config a scrape job for this url, then you can access it from grafana using the your Prometheus as datasource. In your config example, the metric name should be query_result_licenses , and it's value is the number of licenses.