All Projects → yolossn → query2metric

yolossn / query2metric

Licence: MIT license
A tool to run queries in defined frequency and expose the count as prometheus metrics. Supports MongoDB and SQL

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to query2metric

Rats
Movie Ratings Synchronization with Python
Stars: ✭ 156 (+642.86%)
Mutual labels:  exporter
Github Exporter
Prometheus exporter for github metrics
Stars: ✭ 231 (+1000%)
Mutual labels:  exporter
mongoid includes
🌿 Improves eager loading support for Mongoid
Stars: ✭ 43 (+104.76%)
Mutual labels:  queries
Github Csv Tools
Import and export GitHub issues via CSV
Stars: ✭ 182 (+766.67%)
Mutual labels:  exporter
Maya2gltf
Maya to glTF 2.0 exporter
Stars: ✭ 203 (+866.67%)
Mutual labels:  exporter
Queries
SQLite queries
Stars: ✭ 57 (+171.43%)
Mutual labels:  queries
Laravel Translatable String Exporter
Translatable String Exporter for Laravel
Stars: ✭ 149 (+609.52%)
Mutual labels:  exporter
nuxt-storyblok-queries
Nuxt.js module to simplify queries to the Storyblok API
Stars: ✭ 17 (-19.05%)
Mutual labels:  queries
Awesome Prometheus Alerts
🚨 Collection of Prometheus alerting rules
Stars: ✭ 3,323 (+15723.81%)
Mutual labels:  exporter
WP-Query-Console
⚡ Handy WordPress plugin to test various WordPress queries -
Stars: ✭ 25 (+19.05%)
Mutual labels:  queries
Blender niftools addon
The Blender Niftools Addon is a Blender add-on to enable import and export of NetImmese File Formats including .nif, .kf, .egm.
Stars: ✭ 191 (+809.52%)
Mutual labels:  exporter
Krita Batch Exporter
A Free Krita plugin to batch export layers and groups with maximum flexibility. Scale, trim, export multiple copies of your layers...
Stars: ✭ 201 (+857.14%)
Mutual labels:  exporter
GB-html5-respond
移动端响应式布局解决方案(JavaScript + REM)
Stars: ✭ 34 (+61.9%)
Mutual labels:  queries
Event exporter
Exporter for kubernetes events
Stars: ✭ 179 (+752.38%)
Mutual labels:  exporter
relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (+223.81%)
Mutual labels:  queries
Jenkins exporter
Prometheus Metrics exporter for Jenkins
Stars: ✭ 152 (+623.81%)
Mutual labels:  exporter
Objectexporter
Object Exporter lets you export out an object while debugging in Visual Studio, the object can be serialized in either C#, JSON or XML.
Stars: ✭ 240 (+1042.86%)
Mutual labels:  exporter
mac-notes-exporter
Your last straw to save your data from Notes.app.
Stars: ✭ 32 (+52.38%)
Mutual labels:  exporter
LSQ
Linked SPARQL Queries (LSQ): Framework for RDFizing triple store (web) logs and performing SPARQL query extraction, analysis and benchmarking in order to produce datasets of Linked SPARQL Queries
Stars: ✭ 23 (+9.52%)
Mutual labels:  queries
miniql
A tiny JSON-based query language inspired by GraphQL
Stars: ✭ 121 (+476.19%)
Mutual labels:  queries

query2metric

A tool to run db queries in defined frequency and expose the count as prometheus metrics.

Why ?

Product metrics play an important role in understanding product adoption and historic metrics helps answer many questions about a product (for eg: which day of the week do I get the most signups). One common thing is that most of these metrics are extracted by querying the databases. The tool takes queries and time frequency as configuration and runs the queries in the specified intervals and exposes the output as prometheus metrics.

Example

Create a config.yaml file.

config.yaml

connections:
  - name: mongodb1
    type: MONGO
    connectionStringFromEnv: MONGO_CONN
    metrics:
      - name: active_user_count
        helpString: users in the product
        database: test
        collection: test
        query: '{"is_active":true}'
        time: 10
      - name: total_user_count
        helpString: users in the product
        database: test
        collection: test
        query: ""
        time: 120
  - name: postgres1
    type: SQL
    connectionStringFromEnv: POSTGRES_CONN
    metrics:
      - name: template_count
        helpString: products in the db
        query: select * from templates
        time: 2
      - name: active_template_count
        helpString: products in the db
        query: error
        time: 4

Along with the metrics defined, the success and failure count of queries are also exposed as prometheus metrics.

query2metric_success_count - No of successful queries coverted to metrics.

query2metric_error_count - No of errors when converting query to metric.

Note: Errors can occur due to invalid queries or connection issues to the db, one can use the logs to debug the issues.

How to use ?

At present the tool supports mongo and sql queries. Just create a config.yaml file and run the code.

Mongo

set type as MONGO and metrics as given in example with query,time (in seconds) etc.

connections:
- name: mongodb1
    type: MONGO
    connectionStringFromEnv: MONGO_CONN
    metrics:
      - name: active_user_count
        helpString: users in the product
        database: test
        collection: test
        query: '{"is_active":true}'
        time: 10

SQL

set type as SQL and metrics as give in example.

connections:
  - name: postgres1
    type: SQL
    connectionStringFromEnv: POSTGRES_CONN
    metrics:
      - name: template_count
        helpString: products in the db
        query: select * from templates
        time: 2

Run example using docker

You can run the example along with prometheus and grafana using docker.

docker-compose.yaml

docker-compose up

metrics output: localhost:8090/metrics.

prometheus dashboard: localhost:9090/graph.

grafana dashboard: localhost:3000/d/qqTN2unMk/example?orgId=1.

Example Output:

Credits

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].