forked from justwatchcom/sql_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml.dist
127 lines (127 loc) · 3.41 KB
/
config.yml.dist
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
jobs:
- name: "global"
interval: '5m'
connections:
- 'postgres://postgres@localhost/postgres?sslmode=disable'
startup_sql:
- 'SET lock_timeout = 1000'
- 'SET idle_in_transaction_session_timeout = 100'
queries:
- name: "running_queries"
help: "Number of running queries"
labels:
- "datname"
- "usename"
values:
- "count"
query: |
SELECT datname::text, usename::text, COUNT(*)::float AS count
FROM pg_stat_activity GROUP BY datname, usename;
- name: "db_sizes"
help: "Database Sizes"
labels:
- "dbname"
values:
- "dbsize"
query: |
SELECT datname::text AS dbname, pg_database_size(datname)::float AS dbsize
FROM pg_database;
- name: "replication_lag"
help: "Replication Lag"
labels:
- "hostname"
values:
- "replication_lag"
query: |
WITH lag AS (
SELECT
CASE
WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0
ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp())
END
AS lag
)
SELECT
split_part(inet_server_addr()::text, '/', 1) AS hostname,
lag::float AS replication_lag
FROM lag
- name: "mydb"
interval: '5m'
connections:
- 'postgres://postgres@localhost/mydb?sslmode=disable'
queries:
- name: "pg_stat_user_tables"
help: "Table stats"
labels:
- "schemaname"
- "relname"
values:
- "seq_scan"
- "seq_tup_read"
- "idx_scan"
- "idx_tup_fetch"
- "n_tup_ins"
- "n_tup_upd"
- "n_tup_del"
- "n_tup_hot_upd"
- "n_live_tup"
- "n_dead_tup"
- "vacuum_count"
- "autovacuum_count"
- "analyze_count"
- "autoanalyze_count"
query: |
SELECT
schemaname::text
, relname::text
, seq_scan::float
, seq_tup_read::float
, idx_scan::float
, idx_tup_fetch::float
, n_tup_ins::float
, n_tup_upd::float
, n_tup_del::float
, n_tup_hot_upd::float
, n_live_tup::float
, n_dead_tup::float
, vacuum_count::float
, autovacuum_count::float
, analyze_count::float
, autoanalyze_count::float
FROM pg_stat_user_tables;
- name: "pg_statio_user_tables"
help: "IO Stats"
labels:
- "schemaname"
- "relname"
values:
- "heap_blks_read"
- "heap_blks_hit"
- "idx_blks_read"
- "idx_blks_hit"
query: |
SELECT
schemaname::text
, relname::text
, heap_blks_read::float
, heap_blks_hit::float
, idx_blks_read::float
, idx_blks_hit::float
FROM pg_statio_user_tables;
- name: "athena"
interval: '5m'
connections:
# see https://godoc.org/github.com/segmentio/go-athena#Driver.Open
- 'athena://HOST_VALUE_IGNORED/<DB_NAME>?db=<DB_NAME>®ion=<AWS_REGION>&output_location=s3://aws-athena-query-results-<ACCOUNT_ID>-<REGION>'
queries:
- name: "athena_query_rows"
help: "Number of rows..."
values:
- "count"
query: |
SELECT COUNT(*) AS count
FROM my_athena_db.some_table
WHERE partition IN
(SELECT max(partition)
FROM my_athena_db.some_table);