Skip to content

Commit c04de2c

Browse files
committed
feature: add query stats for admins
1 parent 42a839b commit c04de2c

10 files changed

Lines changed: 23391 additions & 20596 deletions

File tree

generated/schema.graphql

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ directive @cached(
1313
refresh: Boolean! = false
1414
) on QUERY
1515

16+
type ActiveConnection {
17+
application_name: String
18+
client_addr: String
19+
pid: Int!
20+
query: String!
21+
query_start: timestamp
22+
state: String
23+
usename: String
24+
}
25+
26+
type ActiveQuery {
27+
application_name: String
28+
client_addr: String
29+
duration_seconds: Float!
30+
pid: Int!
31+
query: String!
32+
query_start: timestamp!
33+
state: String!
34+
usename: String!
35+
wait_event: String
36+
wait_event_type: String
37+
}
38+
1639
type ApiKeyResponse {
1740
key: String!
1841
}
@@ -32,13 +55,61 @@ input Boolean_comparison_exp {
3255
_nin: [Boolean!]
3356
}
3457

58+
type ConnectionByState {
59+
count: Int!
60+
state: String!
61+
wait_event_type: String
62+
waiting_count: Int!
63+
}
64+
65+
type ConnectionStats {
66+
active: Int!
67+
by_state: [ConnectionByState]!
68+
idle: Int!
69+
idle_in_transaction: Int!
70+
total: Int!
71+
waiting: Int!
72+
}
73+
3574
type CpuStat {
3675
time: timestamp
3776
total: bigint
3877
used: bigint
3978
window: Float
4079
}
4180

81+
type DatabaseStats {
82+
blks_hit: Int!
83+
blks_read: Int!
84+
cache_hit_ratio: Float!
85+
conflicts: Int!
86+
datname: String!
87+
deadlocks: Int!
88+
numbackends: Int!
89+
tup_deleted: Int!
90+
tup_fetched: Int!
91+
tup_inserted: Int!
92+
tup_returned: Int!
93+
tup_updated: Int!
94+
xact_commit: Int!
95+
xact_rollback: Int!
96+
}
97+
98+
type DbStats {
99+
calls: Int!
100+
local_blks_hit: Int!
101+
local_blks_read: Int!
102+
max_exec_time: Float!
103+
mean_exec_time: Float!
104+
min_exec_time: Float!
105+
query: String!
106+
queryid: String!
107+
shared_blks_hit: Int!
108+
shared_blks_read: Int!
109+
total_exec_time: Float!
110+
total_rows: Int!
111+
}
112+
42113
type DedicatedSeverInfo {
43114
id: String!
44115
lastPing: String!
@@ -85,6 +156,31 @@ type GetTestUploadResponse {
85156
link: String
86157
}
87158

159+
type HypertableInfo {
160+
compression_enabled: Boolean!
161+
hypertable_name: String!
162+
num_chunks: Int!
163+
}
164+
165+
type IndexIOStat {
166+
idx_blks_hit: Int!
167+
idx_blks_read: Int!
168+
indexname: String!
169+
schemaname: String!
170+
tablename: String!
171+
}
172+
173+
type IndexStat {
174+
idx_scan: Int!
175+
idx_tup_fetch: Int!
176+
idx_tup_read: Int!
177+
index_size: Int!
178+
indexname: String!
179+
schemaname: String!
180+
table_size: Int!
181+
tablename: String!
182+
}
183+
88184
"""
89185
Boolean expression to compare columns of type "Int". All fields are combined with logical 'AND'.
90186
"""
@@ -100,6 +196,16 @@ input Int_comparison_exp {
100196
_nin: [Int!]
101197
}
102198

199+
type LockInfo {
200+
granted: Boolean!
201+
locktype: String!
202+
mode: String!
203+
pid: Int!
204+
query: String
205+
relation: String
206+
usename: String
207+
}
208+
103209
type MeResponse {
104210
avatar_url: String!
105211
country: String
@@ -144,11 +250,48 @@ type PodStats {
144250
node: String!
145251
}
146252

253+
type QueryDetail {
254+
explain_plan: String
255+
query: String!
256+
queryid: String!
257+
stats: QueryStat!
258+
}
259+
260+
type QueryStat {
261+
cache_hit_ratio: Float
262+
calls: Int!
263+
local_blks_hit: Int!
264+
local_blks_read: Int!
265+
max_exec_time: Float!
266+
mean_exec_time: Float!
267+
min_exec_time: Float!
268+
query: String!
269+
queryid: String!
270+
shared_blks_hit: Int!
271+
shared_blks_read: Int!
272+
stddev_exec_time: Float
273+
temp_blks_written: Int!
274+
total_exec_time: Float!
275+
total_rows: Int!
276+
}
277+
147278
type SetupGameServeOutput {
148279
gameServerId: String!
149280
link: String!
150281
}
151282

283+
type StorageStats {
284+
summary: StorageSummary!
285+
tables: [TableSizeInfo!]!
286+
}
287+
288+
type StorageSummary {
289+
estimated_reclaimable_space: Float!
290+
total_database_size: Float!
291+
total_indexes_size: Float!
292+
total_table_size: Float!
293+
}
294+
152295
"""
153296
Boolean expression to compare columns of type "String". All fields are combined with logical 'AND'.
154297
"""
@@ -226,6 +369,46 @@ type SuccessOutput {
226369
success: Boolean!
227370
}
228371

372+
type TableIOStat {
373+
cache_hit_ratio: Float
374+
heap_blks_hit: Int!
375+
heap_blks_read: Int!
376+
idx_blks_hit: Int!
377+
idx_blks_read: Int!
378+
relname: String!
379+
schemaname: String!
380+
}
381+
382+
type TableSizeInfo {
383+
estimated_dead_tuple_bytes: Float!
384+
indexes_size: Float!
385+
n_dead_tup: Int!
386+
n_live_tup: Int!
387+
schemaname: String!
388+
table_size: Float!
389+
tablename: String!
390+
total_size: Float!
391+
}
392+
393+
type TableStat {
394+
idx_scan: Int
395+
idx_tup_fetch: Int
396+
last_analyze: timestamp
397+
last_autoanalyze: timestamp
398+
last_autovacuum: timestamp
399+
last_vacuum: timestamp
400+
n_dead_tup: Int!
401+
n_live_tup: Int!
402+
n_tup_del: Int!
403+
n_tup_hot_upd: Int!
404+
n_tup_ins: Int!
405+
n_tup_upd: Int!
406+
relname: String!
407+
schemaname: String!
408+
seq_scan: Int!
409+
seq_tup_read: Int!
410+
}
411+
229412
type TelemetryStats {
230413
online: Int!
231414
}
@@ -234,6 +417,20 @@ type TestUploadResponse {
234417
error: String
235418
}
236419

420+
type TimescaleJob {
421+
hypertable_name: String
422+
job_id: Int!
423+
job_type: String!
424+
last_run_status: String
425+
next_start: timestamp
426+
}
427+
428+
type TimescaleStats {
429+
chunks_count: Int!
430+
hypertables: [HypertableInfo]!
431+
jobs: [TimescaleJob]!
432+
}
433+
237434
"""
238435
columns and relationships of "_map_pool"
239436
"""
@@ -30467,6 +30664,7 @@ type query_root {
3046730664

3046830665
"""fetch data from the table: "api_keys" using primary key columns"""
3046930666
api_keys_by_pk(id: uuid!): api_keys
30667+
dbStats: [DbStats]
3047030668

3047130669
"""
3047230670
fetch data from the table: "db_backups"
@@ -31744,10 +31942,52 @@ type query_root {
3174431942

3174531943
"""fetch data from the table: "game_versions" using primary key columns"""
3174631944
game_versions_by_pk(build_id: Int!): game_versions
31945+
31946+
"""Get list of active connections"""
31947+
getActiveConnections: [ActiveConnection]!
31948+
31949+
"""Get currently executing queries"""
31950+
getActiveQueries: [ActiveQuery]!
31951+
31952+
"""Get connection statistics"""
31953+
getConnectionStats: ConnectionStats!
31954+
31955+
"""Get current database locks"""
31956+
getCurrentLocks: [LockInfo]!
31957+
31958+
"""Get database-wide statistics"""
31959+
getDatabaseStats: DatabaseStats!
3174731960
getDedicatedServerInfo: [DedicatedSeverInfo]!
31961+
31962+
"""Get index I/O statistics"""
31963+
getIndexIOStats: [IndexIOStat]!
31964+
31965+
"""Get index usage statistics"""
31966+
getIndexStats: [IndexStat]!
3174831967
getNodeStats(node: String!): NodeStats!
31968+
31969+
"""Get detailed query analysis with EXPLAIN plan"""
31970+
getQueryDetail(queryid: String!): QueryDetail
31971+
31972+
"""Get enhanced query performance statistics"""
31973+
getQueryStats: [QueryStat]!
31974+
31975+
"""Get available database schemas"""
31976+
getSchemas: String!
3174931977
getServiceStats: [PodStats]!
3175031978

31979+
"""Get database storage statistics and reclaimable space"""
31980+
getStorageStats: StorageStats!
31981+
31982+
"""Get table I/O statistics"""
31983+
getTableIOStats: [TableIOStat]!
31984+
31985+
"""Get table access statistics"""
31986+
getTableStats: [TableStat]!
31987+
31988+
"""Get TimescaleDB statistics"""
31989+
getTimescaleStats: TimescaleStats!
31990+
3175131991
"""List files in game server directory"""
3175231992
listServerFiles(node_id: String!, path: String, server_id: String): FileListResponse!
3175331993

0 commit comments

Comments
 (0)