forked from chop-dbhi/prometheus-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-queries.yml
67 lines (56 loc) · 2.4 KB
/
example-queries.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File that defines endpoints for exposing Prometheus metrics for SQL result sets.
# It talks to a [SQL Agent](https://github.com/chop-dbhi/sql-agent) service that
# performs the query against the target database and returns the result set.
# The `driver`, `connection`, `sql`, and `params` options defined for each endpoint
# are passed to the service to execute the query. The other options are specific
# to this service.
# Name of the metric. Will be exposed as query_result_num_products
- num_products:
# Name of the driver to use.
driver: postgresql
# Connection information.
connection:
host: example.org
port: 5432
user: postgres
password: s3cre7
database: products
# SQL string. Parameters are name-based (not positional) and must be
# prefixed with a colon. See `:category_id` in the query below for an example.
# Must return single row, single column
sql: >
select count(product_id)
from product
inner join product_category
on (product.category_id = product_category.id)
inner join product_category_idx
on (product_category.id = product_category_idx.category_id)
where product_category_idx.category_id = :category_id
or product_category_idx.ancestor_category_id = :category_id
# Parameter values by name.
params:
category_id: 5
# The time between query execution. This should be set relative to the frequency
# of expected updates and the required granularity of changes.
interval: 1h
# value on error, default is null
# if not null, when query has error, will use this value to indicate an error has occured
#value-on-error: '-1'
# For faceted metrics provide the name of the metric-column in config, and return a resultset of multiple columns and rows
- sales_by_country:
# Name of the driver to use.
driver: postgresql
# Connection information.
connection:
host: example.org
port: 5432
user: postgres
password: s3cre7
database: products
sql: >
select country, count(1) as cnt from sales
# The time between query execution. This should be set relative to the frequency
# of expected updates and the required granularity of changes.
interval: 1h
# The value for our metric is in "cnt", other columns are facets (exposed as labels)
data-field: cnt