flexmetric 0.5.2__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {flexmetric-0.5.2 → flexmetric-0.5.3}/PKG-INFO +100 -40
  2. {flexmetric-0.5.2 → flexmetric-0.5.3}/README.md +99 -39
  3. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/PKG-INFO +100 -40
  4. {flexmetric-0.5.2 → flexmetric-0.5.3}/setup.py +1 -1
  5. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/__init__.py +0 -0
  6. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/config/__init__.py +0 -0
  7. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/config/configuration.py +0 -0
  8. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/file_recognition/__init__.py +0 -0
  9. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/file_recognition/exec_file.py +0 -0
  10. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/logging_module/__init__.py +0 -0
  11. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/logging_module/logger.py +0 -0
  12. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/__init__.py +0 -0
  13. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/database_connections.py +0 -0
  14. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/database_processing.py +0 -0
  15. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/expiring_queue.py +0 -0
  16. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/process_commands.py +0 -0
  17. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/prometheus_agent.py +0 -0
  18. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/queries_execution.py +0 -0
  19. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric/metric_process/views.py +0 -0
  20. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/SOURCES.txt +0 -0
  21. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/dependency_links.txt +0 -0
  22. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/entry_points.txt +0 -0
  23. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/requires.txt +0 -0
  24. {flexmetric-0.5.2 → flexmetric-0.5.3}/flexmetric.egg-info/top_level.txt +0 -0
  25. {flexmetric-0.5.2 → flexmetric-0.5.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexmetric
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: A secure flexible Prometheus exporter for commands, databases, functions.
5
5
  Home-page: https://github.com/nikhillingadhal1999/flexmetric
6
6
  Author: Nikhil Lingadhal
@@ -33,25 +33,38 @@ Dynamic: requires-dist
33
33
  Dynamic: requires-python
34
34
  Dynamic: summary
35
35
 
36
- # FlexMetric
36
+ FlexMetric is a lightweight, pluggable, and extensible Prometheus exporter that helps you collect, expose, and visualize custom metrics with minimal setup and maximum flexibility.
37
37
 
38
- FlexMetric is a lightweight, flexible, and extensible Prometheus exporter that allows you to securely expose system metrics, database query results, Python function outputs, and externally submitted metrics—via an optional Flask API with HTTPS support—as Prometheus-compatible metrics, all with minimal setup and maximum customization.
38
+ With FlexMetric, you can:
39
39
 
40
- ---
40
+ Run system commands and expose their output as metrics
41
+
42
+ Execute SQL queries against databases like SQLite, PostgreSQL, and ClickHouse
43
+
44
+ Call custom Python functions and export their results
41
45
 
42
- ## Features
46
+ Receive externally submitted metrics via a secure Flask-based API with optional HTTPS (TLS)
43
47
 
44
- - Run shell commands and expose the results as Prometheus metrics.
45
- ➔ **Harmful commands (e.g., file deletion, system shutdown) are blocked for safety.**
46
- - Execute SQL queries (e.g., SQLite) and monitor database statistics.
47
- ➔ **Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are not allowed.**
48
- - Automatically discover and expose Python function outputs as metrics.
49
- - Expose an optional **Flask API** (`/update_metric`) to receive external metrics dynamically.
50
- - Modular and easy to extend—add your own custom integrations.
51
- - Built-in Prometheus HTTP server (`/metrics`) with configurable port.
52
- - **Supports HTTPS** to securely expose both metrics and API endpoints.
53
- - **Input sanitization** is performed to ensure only safe commands and queries are executed.
48
+ All metrics are exposed in Prometheus-compatible format, making them ready for visualization in Grafana or any Prometheus-based monitoring stack.
49
+ ---
54
50
 
51
+ Paste your rich text content here. You can paste directly from Word or other rich text sources.
52
+
53
+ * Run **shell commands** and expose the results as **Prometheus metrics**.
54
+ ➔ _Harmful commands (e.g., file deletion, system shutdown) are blocked for safety._
55
+
56
+ * Execute **SQL queries** and monitor database statistics:
57
+
58
+ * **SQLite** (lightweight, file-based databases)
59
+ * **PostgreSQL** (robust, production-grade relational databases)
60
+ * **ClickHouse** (high-performance, analytical databases)
61
+ * Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are blocked by default.
62
+ * Automatically discover and expose **Python function outputs** as metrics.
63
+ * Expose an optional **Flask API** (`/update_metric`) to receive and update external metrics **dynamically**.
64
+ * Modular and **easy to extend**—add your own **custom integrations** with minimal effort.
65
+ * Built-in **Prometheus-compatible HTTP server** (`/metrics`) with configurable port.
66
+ * Supports **HTTPS** to securely expose both the metrics endpoint and API.
67
+ * Input **sanitization and validation** ensure only safe commands and queries are executed.
55
68
 
56
69
  ---
57
70
 
@@ -190,52 +203,99 @@ Filesystem Size Used Avail Use% Mounted on
190
203
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
191
204
 
192
205
  ## Database mode
206
+ ## 🔗 Supported Database Connections
207
+
208
+ FlexMetric supports fetching and exposing metrics from multiple databases using a simple YAML-based configuration. This allows you to monitor data directly from your existing data sources without writing custom code.
209
+
210
+ ### ✅ Currently Supported Databases:
211
+
212
+ | Database | Type Name | Description |
213
+ |--------------|---------------|--------------------------------------------------|
214
+ | **SQLite** | `sqlite` | Lightweight, file-based relational database |
215
+ | **PostgreSQL** | `postgres` | Robust, production-grade relational database |
216
+ | **ClickHouse** | `clickhouse` | High-performance, analytical columnar database |
217
+
218
+ ---
219
+
220
+ ### 📄 Example `database.yaml` Configuration:
193
221
  file - database.yaml
194
222
  ```yaml
195
223
  databases:
196
- - id: "active_user_count"
224
+ - id: "local_sqlite"
225
+ type: "sqlite"
226
+ db_connection: "/path/to/example.db"
227
+
228
+ - id: "analytics_pg"
229
+ type: "postgres"
230
+ host: "localhost"
231
+ port: 5432
232
+ database: "metricsdb"
233
+ username: "postgres"
234
+ password: "postgres_password"
235
+ sslmode: "disable"
236
+ client_cert: "/path/to/cert.pem"
237
+ client_key: "/path/to/key.pem"
238
+ ca_cert: "/path/to/ca.pem"
239
+
240
+ - id: "clickhouse_cluster"
197
241
  type: "clickhouse"
198
242
  host: "localhost"
199
- port: 8123
243
+ port: 8443
200
244
  username: "default"
201
- password: ""
202
- client_cert: ""
203
- client_key: ""
204
- ca_cert: ""
205
-
206
- - id: "userdb"
207
- type: "sqlite"
208
- db_connection: "/path/to/my.db"
245
+ password: "clickhouse_password"
246
+ secure: true
247
+ client_cert: "/path/to/cert.pem"
248
+ client_key: "/path/to/key.pem"
249
+ ca_cert: "/path/to/ca.pem"
209
250
  ```
210
- file - queries.yaml
251
+
252
+ ## Supported Query Configuration
253
+
254
+ FlexMetric allows you to define custom queries in a simple YAML format. Each query is linked to a database using the `database_id` and can expose the results as Prometheus metrics with flexible labeling and value extraction.
255
+
256
+ ### Example `queries.yaml` Configuration:
257
+
211
258
  ```yaml
212
259
  commands:
213
- - id: "active_user_count"
214
- type: "clickhouse"
215
- database_id: "active_user_count"
260
+ - id: "active_user_count_pg"
261
+ type: "postgres"
262
+ database_id: "analytics_pg"
216
263
  query: |
217
264
  SELECT
218
265
  country AS country_name,
219
- COUNT() AS active_user_count
266
+ COUNT(*) AS active_user_count
220
267
  FROM users
221
- WHERE is_active = 1
222
- GROUP BY country
268
+ WHERE is_active = true
269
+ GROUP BY country;
223
270
  main_label: "active_user_count"
224
271
  labels: ["country_name"]
225
272
  value_column: "active_user_count"
226
273
 
227
- - id: "list_all_users_sqlite"
274
+ - id: "total_user_count_sqlite"
228
275
  type: "sqlite"
229
- database_id: "userdb"
276
+ database_id: "local_sqlite"
277
+ query: |
278
+ SELECT
279
+ 'all' AS user_group,
280
+ COUNT(*) AS total_user_count
281
+ FROM users;
282
+ main_label: "total_user_count"
283
+ labels: ["user_group"]
284
+ value_column: "total_user_count"
285
+
286
+ - id: "clickhouse_user_summary"
287
+ type: "clickhouse"
288
+ database_id: "clickhouse_cluster"
230
289
  query: |
231
290
  SELECT
232
- id,
233
- name
291
+ region AS region_name,
292
+ COUNT() AS user_count
234
293
  FROM users
235
- main_label: "user_list"
236
- labels: ["id", "name"]
237
- value_column: "id"
238
-
294
+ WHERE status = 'active'
295
+ GROUP BY region;
296
+ main_label: "clickhouse_user_count"
297
+ labels: ["region_name"]
298
+ value_column: "user_count"
239
299
  ```
240
300
  ## Functions mode
241
301
 
@@ -1,22 +1,35 @@
1
- # FlexMetric
1
+ FlexMetric is a lightweight, pluggable, and extensible Prometheus exporter that helps you collect, expose, and visualize custom metrics with minimal setup and maximum flexibility.
2
2
 
3
- FlexMetric is a lightweight, flexible, and extensible Prometheus exporter that allows you to securely expose system metrics, database query results, Python function outputs, and externally submitted metrics—via an optional Flask API with HTTPS support—as Prometheus-compatible metrics, all with minimal setup and maximum customization.
3
+ With FlexMetric, you can:
4
4
 
5
- ---
5
+ Run system commands and expose their output as metrics
6
+
7
+ Execute SQL queries against databases like SQLite, PostgreSQL, and ClickHouse
8
+
9
+ Call custom Python functions and export their results
6
10
 
7
- ## Features
11
+ Receive externally submitted metrics via a secure Flask-based API with optional HTTPS (TLS)
8
12
 
9
- - Run shell commands and expose the results as Prometheus metrics.
10
- ➔ **Harmful commands (e.g., file deletion, system shutdown) are blocked for safety.**
11
- - Execute SQL queries (e.g., SQLite) and monitor database statistics.
12
- ➔ **Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are not allowed.**
13
- - Automatically discover and expose Python function outputs as metrics.
14
- - Expose an optional **Flask API** (`/update_metric`) to receive external metrics dynamically.
15
- - Modular and easy to extend—add your own custom integrations.
16
- - Built-in Prometheus HTTP server (`/metrics`) with configurable port.
17
- - **Supports HTTPS** to securely expose both metrics and API endpoints.
18
- - **Input sanitization** is performed to ensure only safe commands and queries are executed.
13
+ All metrics are exposed in Prometheus-compatible format, making them ready for visualization in Grafana or any Prometheus-based monitoring stack.
14
+ ---
19
15
 
16
+ Paste your rich text content here. You can paste directly from Word or other rich text sources.
17
+
18
+ * Run **shell commands** and expose the results as **Prometheus metrics**.
19
+ ➔ _Harmful commands (e.g., file deletion, system shutdown) are blocked for safety._
20
+
21
+ * Execute **SQL queries** and monitor database statistics:
22
+
23
+ * **SQLite** (lightweight, file-based databases)
24
+ * **PostgreSQL** (robust, production-grade relational databases)
25
+ * **ClickHouse** (high-performance, analytical databases)
26
+ * Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are blocked by default.
27
+ * Automatically discover and expose **Python function outputs** as metrics.
28
+ * Expose an optional **Flask API** (`/update_metric`) to receive and update external metrics **dynamically**.
29
+ * Modular and **easy to extend**—add your own **custom integrations** with minimal effort.
30
+ * Built-in **Prometheus-compatible HTTP server** (`/metrics`) with configurable port.
31
+ * Supports **HTTPS** to securely expose both the metrics endpoint and API.
32
+ * Input **sanitization and validation** ensure only safe commands and queries are executed.
20
33
 
21
34
  ---
22
35
 
@@ -155,52 +168,99 @@ Filesystem Size Used Avail Use% Mounted on
155
168
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
156
169
 
157
170
  ## Database mode
171
+ ## 🔗 Supported Database Connections
172
+
173
+ FlexMetric supports fetching and exposing metrics from multiple databases using a simple YAML-based configuration. This allows you to monitor data directly from your existing data sources without writing custom code.
174
+
175
+ ### ✅ Currently Supported Databases:
176
+
177
+ | Database | Type Name | Description |
178
+ |--------------|---------------|--------------------------------------------------|
179
+ | **SQLite** | `sqlite` | Lightweight, file-based relational database |
180
+ | **PostgreSQL** | `postgres` | Robust, production-grade relational database |
181
+ | **ClickHouse** | `clickhouse` | High-performance, analytical columnar database |
182
+
183
+ ---
184
+
185
+ ### 📄 Example `database.yaml` Configuration:
158
186
  file - database.yaml
159
187
  ```yaml
160
188
  databases:
161
- - id: "active_user_count"
189
+ - id: "local_sqlite"
190
+ type: "sqlite"
191
+ db_connection: "/path/to/example.db"
192
+
193
+ - id: "analytics_pg"
194
+ type: "postgres"
195
+ host: "localhost"
196
+ port: 5432
197
+ database: "metricsdb"
198
+ username: "postgres"
199
+ password: "postgres_password"
200
+ sslmode: "disable"
201
+ client_cert: "/path/to/cert.pem"
202
+ client_key: "/path/to/key.pem"
203
+ ca_cert: "/path/to/ca.pem"
204
+
205
+ - id: "clickhouse_cluster"
162
206
  type: "clickhouse"
163
207
  host: "localhost"
164
- port: 8123
208
+ port: 8443
165
209
  username: "default"
166
- password: ""
167
- client_cert: ""
168
- client_key: ""
169
- ca_cert: ""
170
-
171
- - id: "userdb"
172
- type: "sqlite"
173
- db_connection: "/path/to/my.db"
210
+ password: "clickhouse_password"
211
+ secure: true
212
+ client_cert: "/path/to/cert.pem"
213
+ client_key: "/path/to/key.pem"
214
+ ca_cert: "/path/to/ca.pem"
174
215
  ```
175
- file - queries.yaml
216
+
217
+ ## Supported Query Configuration
218
+
219
+ FlexMetric allows you to define custom queries in a simple YAML format. Each query is linked to a database using the `database_id` and can expose the results as Prometheus metrics with flexible labeling and value extraction.
220
+
221
+ ### Example `queries.yaml` Configuration:
222
+
176
223
  ```yaml
177
224
  commands:
178
- - id: "active_user_count"
179
- type: "clickhouse"
180
- database_id: "active_user_count"
225
+ - id: "active_user_count_pg"
226
+ type: "postgres"
227
+ database_id: "analytics_pg"
181
228
  query: |
182
229
  SELECT
183
230
  country AS country_name,
184
- COUNT() AS active_user_count
231
+ COUNT(*) AS active_user_count
185
232
  FROM users
186
- WHERE is_active = 1
187
- GROUP BY country
233
+ WHERE is_active = true
234
+ GROUP BY country;
188
235
  main_label: "active_user_count"
189
236
  labels: ["country_name"]
190
237
  value_column: "active_user_count"
191
238
 
192
- - id: "list_all_users_sqlite"
239
+ - id: "total_user_count_sqlite"
193
240
  type: "sqlite"
194
- database_id: "userdb"
241
+ database_id: "local_sqlite"
242
+ query: |
243
+ SELECT
244
+ 'all' AS user_group,
245
+ COUNT(*) AS total_user_count
246
+ FROM users;
247
+ main_label: "total_user_count"
248
+ labels: ["user_group"]
249
+ value_column: "total_user_count"
250
+
251
+ - id: "clickhouse_user_summary"
252
+ type: "clickhouse"
253
+ database_id: "clickhouse_cluster"
195
254
  query: |
196
255
  SELECT
197
- id,
198
- name
256
+ region AS region_name,
257
+ COUNT() AS user_count
199
258
  FROM users
200
- main_label: "user_list"
201
- labels: ["id", "name"]
202
- value_column: "id"
203
-
259
+ WHERE status = 'active'
260
+ GROUP BY region;
261
+ main_label: "clickhouse_user_count"
262
+ labels: ["region_name"]
263
+ value_column: "user_count"
204
264
  ```
205
265
  ## Functions mode
206
266
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexmetric
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: A secure flexible Prometheus exporter for commands, databases, functions.
5
5
  Home-page: https://github.com/nikhillingadhal1999/flexmetric
6
6
  Author: Nikhil Lingadhal
@@ -33,25 +33,38 @@ Dynamic: requires-dist
33
33
  Dynamic: requires-python
34
34
  Dynamic: summary
35
35
 
36
- # FlexMetric
36
+ FlexMetric is a lightweight, pluggable, and extensible Prometheus exporter that helps you collect, expose, and visualize custom metrics with minimal setup and maximum flexibility.
37
37
 
38
- FlexMetric is a lightweight, flexible, and extensible Prometheus exporter that allows you to securely expose system metrics, database query results, Python function outputs, and externally submitted metrics—via an optional Flask API with HTTPS support—as Prometheus-compatible metrics, all with minimal setup and maximum customization.
38
+ With FlexMetric, you can:
39
39
 
40
- ---
40
+ Run system commands and expose their output as metrics
41
+
42
+ Execute SQL queries against databases like SQLite, PostgreSQL, and ClickHouse
43
+
44
+ Call custom Python functions and export their results
41
45
 
42
- ## Features
46
+ Receive externally submitted metrics via a secure Flask-based API with optional HTTPS (TLS)
43
47
 
44
- - Run shell commands and expose the results as Prometheus metrics.
45
- ➔ **Harmful commands (e.g., file deletion, system shutdown) are blocked for safety.**
46
- - Execute SQL queries (e.g., SQLite) and monitor database statistics.
47
- ➔ **Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are not allowed.**
48
- - Automatically discover and expose Python function outputs as metrics.
49
- - Expose an optional **Flask API** (`/update_metric`) to receive external metrics dynamically.
50
- - Modular and easy to extend—add your own custom integrations.
51
- - Built-in Prometheus HTTP server (`/metrics`) with configurable port.
52
- - **Supports HTTPS** to securely expose both metrics and API endpoints.
53
- - **Input sanitization** is performed to ensure only safe commands and queries are executed.
48
+ All metrics are exposed in Prometheus-compatible format, making them ready for visualization in Grafana or any Prometheus-based monitoring stack.
49
+ ---
54
50
 
51
+ Paste your rich text content here. You can paste directly from Word or other rich text sources.
52
+
53
+ * Run **shell commands** and expose the results as **Prometheus metrics**.
54
+ ➔ _Harmful commands (e.g., file deletion, system shutdown) are blocked for safety._
55
+
56
+ * Execute **SQL queries** and monitor database statistics:
57
+
58
+ * **SQLite** (lightweight, file-based databases)
59
+ * **PostgreSQL** (robust, production-grade relational databases)
60
+ * **ClickHouse** (high-performance, analytical databases)
61
+ * Potentially dangerous queries (e.g., `DROP`, `DELETE`, `TRUNCATE`) are blocked by default.
62
+ * Automatically discover and expose **Python function outputs** as metrics.
63
+ * Expose an optional **Flask API** (`/update_metric`) to receive and update external metrics **dynamically**.
64
+ * Modular and **easy to extend**—add your own **custom integrations** with minimal effort.
65
+ * Built-in **Prometheus-compatible HTTP server** (`/metrics`) with configurable port.
66
+ * Supports **HTTPS** to securely expose both the metrics endpoint and API.
67
+ * Input **sanitization and validation** ensure only safe commands and queries are executed.
55
68
 
56
69
  ---
57
70
 
@@ -190,52 +203,99 @@ Filesystem Size Used Avail Use% Mounted on
190
203
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
191
204
 
192
205
  ## Database mode
206
+ ## 🔗 Supported Database Connections
207
+
208
+ FlexMetric supports fetching and exposing metrics from multiple databases using a simple YAML-based configuration. This allows you to monitor data directly from your existing data sources without writing custom code.
209
+
210
+ ### ✅ Currently Supported Databases:
211
+
212
+ | Database | Type Name | Description |
213
+ |--------------|---------------|--------------------------------------------------|
214
+ | **SQLite** | `sqlite` | Lightweight, file-based relational database |
215
+ | **PostgreSQL** | `postgres` | Robust, production-grade relational database |
216
+ | **ClickHouse** | `clickhouse` | High-performance, analytical columnar database |
217
+
218
+ ---
219
+
220
+ ### 📄 Example `database.yaml` Configuration:
193
221
  file - database.yaml
194
222
  ```yaml
195
223
  databases:
196
- - id: "active_user_count"
224
+ - id: "local_sqlite"
225
+ type: "sqlite"
226
+ db_connection: "/path/to/example.db"
227
+
228
+ - id: "analytics_pg"
229
+ type: "postgres"
230
+ host: "localhost"
231
+ port: 5432
232
+ database: "metricsdb"
233
+ username: "postgres"
234
+ password: "postgres_password"
235
+ sslmode: "disable"
236
+ client_cert: "/path/to/cert.pem"
237
+ client_key: "/path/to/key.pem"
238
+ ca_cert: "/path/to/ca.pem"
239
+
240
+ - id: "clickhouse_cluster"
197
241
  type: "clickhouse"
198
242
  host: "localhost"
199
- port: 8123
243
+ port: 8443
200
244
  username: "default"
201
- password: ""
202
- client_cert: ""
203
- client_key: ""
204
- ca_cert: ""
205
-
206
- - id: "userdb"
207
- type: "sqlite"
208
- db_connection: "/path/to/my.db"
245
+ password: "clickhouse_password"
246
+ secure: true
247
+ client_cert: "/path/to/cert.pem"
248
+ client_key: "/path/to/key.pem"
249
+ ca_cert: "/path/to/ca.pem"
209
250
  ```
210
- file - queries.yaml
251
+
252
+ ## Supported Query Configuration
253
+
254
+ FlexMetric allows you to define custom queries in a simple YAML format. Each query is linked to a database using the `database_id` and can expose the results as Prometheus metrics with flexible labeling and value extraction.
255
+
256
+ ### Example `queries.yaml` Configuration:
257
+
211
258
  ```yaml
212
259
  commands:
213
- - id: "active_user_count"
214
- type: "clickhouse"
215
- database_id: "active_user_count"
260
+ - id: "active_user_count_pg"
261
+ type: "postgres"
262
+ database_id: "analytics_pg"
216
263
  query: |
217
264
  SELECT
218
265
  country AS country_name,
219
- COUNT() AS active_user_count
266
+ COUNT(*) AS active_user_count
220
267
  FROM users
221
- WHERE is_active = 1
222
- GROUP BY country
268
+ WHERE is_active = true
269
+ GROUP BY country;
223
270
  main_label: "active_user_count"
224
271
  labels: ["country_name"]
225
272
  value_column: "active_user_count"
226
273
 
227
- - id: "list_all_users_sqlite"
274
+ - id: "total_user_count_sqlite"
228
275
  type: "sqlite"
229
- database_id: "userdb"
276
+ database_id: "local_sqlite"
277
+ query: |
278
+ SELECT
279
+ 'all' AS user_group,
280
+ COUNT(*) AS total_user_count
281
+ FROM users;
282
+ main_label: "total_user_count"
283
+ labels: ["user_group"]
284
+ value_column: "total_user_count"
285
+
286
+ - id: "clickhouse_user_summary"
287
+ type: "clickhouse"
288
+ database_id: "clickhouse_cluster"
230
289
  query: |
231
290
  SELECT
232
- id,
233
- name
291
+ region AS region_name,
292
+ COUNT() AS user_count
234
293
  FROM users
235
- main_label: "user_list"
236
- labels: ["id", "name"]
237
- value_column: "id"
238
-
294
+ WHERE status = 'active'
295
+ GROUP BY region;
296
+ main_label: "clickhouse_user_count"
297
+ labels: ["region_name"]
298
+ value_column: "user_count"
239
299
  ```
240
300
  ## Functions mode
241
301
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="flexmetric",
5
- version="0.5.2",
5
+ version="0.5.3",
6
6
  author="Nikhil Lingadhal",
7
7
  description="A secure flexible Prometheus exporter for commands, databases, functions.",
8
8
  long_description=open("README.md").read(),
File without changes