flexmetric 0.4.3__tar.gz → 0.4.4__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.4.3 → flexmetric-0.4.4}/PKG-INFO +43 -12
  2. {flexmetric-0.4.3 → flexmetric-0.4.4}/README.md +42 -11
  3. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/queries_execution.py +5 -9
  4. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/PKG-INFO +43 -12
  5. {flexmetric-0.4.3 → flexmetric-0.4.4}/setup.py +1 -1
  6. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/__init__.py +0 -0
  7. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/config/__init__.py +0 -0
  8. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/config/configuration.py +0 -0
  9. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/file_recognition/__init__.py +0 -0
  10. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/file_recognition/exec_file.py +0 -0
  11. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/logging_module/__init__.py +0 -0
  12. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/logging_module/logger.py +0 -0
  13. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/__init__.py +0 -0
  14. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/database_connections.py +0 -0
  15. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/database_processing.py +0 -0
  16. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/expiring_queue.py +0 -0
  17. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/process_commands.py +0 -0
  18. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/prometheus_agent.py +0 -0
  19. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric/metric_process/views.py +0 -0
  20. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/SOURCES.txt +0 -0
  21. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/dependency_links.txt +0 -0
  22. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/entry_points.txt +0 -0
  23. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/requires.txt +0 -0
  24. {flexmetric-0.4.3 → flexmetric-0.4.4}/flexmetric.egg-info/top_level.txt +0 -0
  25. {flexmetric-0.4.3 → flexmetric-0.4.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexmetric
3
- Version: 0.4.3
3
+ Version: 0.4.4
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
@@ -189,21 +189,52 @@ Filesystem Size Used Avail Use% Mounted on
189
189
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
190
190
 
191
191
  ## Database mode
192
-
192
+ file - database.yaml
193
193
  ```yaml
194
194
  databases:
195
- - name: mydb
196
- db_type: sqlite
197
- db_connection: /path/to/my.db
198
- ````
195
+ - id: "active_user_count"
196
+ type: "clickhouse"
197
+ host: "localhost"
198
+ port: 8123
199
+ username: "default"
200
+ password: ""
201
+ client_cert: ""
202
+ client_key: ""
203
+ ca_cert: ""
204
+
205
+ - id: "userdb"
206
+ type: "sqlite"
207
+ db_connection: "/path/to/my.db"
208
+ ```
209
+ file - queries.yaml
199
210
  ```yaml
200
211
  commands:
201
- - name: user_count
202
- database: userdb
203
- query: "SELECT COUNT(*) FROM users;"
204
- main_label: database_user_count
205
- labels: ["database_name", "table_name"]
206
- label_values: ["userdb", "users"]
212
+ - id: "active_user_count"
213
+ type: "clickhouse"
214
+ database_id: "active_user_count"
215
+ query: |
216
+ SELECT
217
+ country AS country_name,
218
+ COUNT() AS active_user_count
219
+ FROM users
220
+ WHERE is_active = 1
221
+ GROUP BY country
222
+ main_label: "active_user_count"
223
+ labels: ["country_name"]
224
+ value_column: "active_user_count"
225
+
226
+ - id: "list_all_users_sqlite"
227
+ type: "sqlite"
228
+ database_id: "userdb"
229
+ query: |
230
+ SELECT
231
+ id,
232
+ name
233
+ FROM users
234
+ main_label: "user_list"
235
+ labels: ["id", "name"]
236
+ value_column: "id"
237
+
207
238
  ```
208
239
  ## Functions mode
209
240
 
@@ -155,21 +155,52 @@ Filesystem Size Used Avail Use% Mounted on
155
155
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
156
156
 
157
157
  ## Database mode
158
-
158
+ file - database.yaml
159
159
  ```yaml
160
160
  databases:
161
- - name: mydb
162
- db_type: sqlite
163
- db_connection: /path/to/my.db
164
- ````
161
+ - id: "active_user_count"
162
+ type: "clickhouse"
163
+ host: "localhost"
164
+ port: 8123
165
+ 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"
174
+ ```
175
+ file - queries.yaml
165
176
  ```yaml
166
177
  commands:
167
- - name: user_count
168
- database: userdb
169
- query: "SELECT COUNT(*) FROM users;"
170
- main_label: database_user_count
171
- labels: ["database_name", "table_name"]
172
- label_values: ["userdb", "users"]
178
+ - id: "active_user_count"
179
+ type: "clickhouse"
180
+ database_id: "active_user_count"
181
+ query: |
182
+ SELECT
183
+ country AS country_name,
184
+ COUNT() AS active_user_count
185
+ FROM users
186
+ WHERE is_active = 1
187
+ GROUP BY country
188
+ main_label: "active_user_count"
189
+ labels: ["country_name"]
190
+ value_column: "active_user_count"
191
+
192
+ - id: "list_all_users_sqlite"
193
+ type: "sqlite"
194
+ database_id: "userdb"
195
+ query: |
196
+ SELECT
197
+ id,
198
+ name
199
+ FROM users
200
+ main_label: "user_list"
201
+ labels: ["id", "name"]
202
+ value_column: "id"
203
+
173
204
  ```
174
205
  ## Functions mode
175
206
 
@@ -12,17 +12,13 @@ def execute_clickhouse_command(client, command: str):
12
12
  except Exception as e:
13
13
  logger.error(f"Error executing command: {e}")
14
14
  return None
15
- def execute_sqlite_query(conn,query):
15
+ def execute_sqlite_query(conn, query):
16
16
  try:
17
17
  cursor = conn.cursor()
18
18
  cursor.execute(query)
19
- result = cursor.fetchone()
19
+ rows = cursor.fetchall()
20
20
  column_names = [desc[0] for desc in cursor.description]
21
- conn.close()
22
- return float(result[0]) if result and result[0] is not None else None , column_names
21
+ return rows, column_names
23
22
  except Exception as ex:
24
- logger.error(f"Exception : {ex}")
25
- return None
26
-
27
-
28
-
23
+ logger.error(f"Exception during SQLite query: {ex}")
24
+ return [], []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexmetric
3
- Version: 0.4.3
3
+ Version: 0.4.4
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
@@ -189,21 +189,52 @@ Filesystem Size Used Avail Use% Mounted on
189
189
  | `timeout_seconds` | Maximum time (in seconds) to wait for the command to complete. If it exceeds this time, the command is aborted. |
190
190
 
191
191
  ## Database mode
192
-
192
+ file - database.yaml
193
193
  ```yaml
194
194
  databases:
195
- - name: mydb
196
- db_type: sqlite
197
- db_connection: /path/to/my.db
198
- ````
195
+ - id: "active_user_count"
196
+ type: "clickhouse"
197
+ host: "localhost"
198
+ port: 8123
199
+ username: "default"
200
+ password: ""
201
+ client_cert: ""
202
+ client_key: ""
203
+ ca_cert: ""
204
+
205
+ - id: "userdb"
206
+ type: "sqlite"
207
+ db_connection: "/path/to/my.db"
208
+ ```
209
+ file - queries.yaml
199
210
  ```yaml
200
211
  commands:
201
- - name: user_count
202
- database: userdb
203
- query: "SELECT COUNT(*) FROM users;"
204
- main_label: database_user_count
205
- labels: ["database_name", "table_name"]
206
- label_values: ["userdb", "users"]
212
+ - id: "active_user_count"
213
+ type: "clickhouse"
214
+ database_id: "active_user_count"
215
+ query: |
216
+ SELECT
217
+ country AS country_name,
218
+ COUNT() AS active_user_count
219
+ FROM users
220
+ WHERE is_active = 1
221
+ GROUP BY country
222
+ main_label: "active_user_count"
223
+ labels: ["country_name"]
224
+ value_column: "active_user_count"
225
+
226
+ - id: "list_all_users_sqlite"
227
+ type: "sqlite"
228
+ database_id: "userdb"
229
+ query: |
230
+ SELECT
231
+ id,
232
+ name
233
+ FROM users
234
+ main_label: "user_list"
235
+ labels: ["id", "name"]
236
+ value_column: "id"
237
+
207
238
  ```
208
239
  ## Functions mode
209
240
 
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="flexmetric",
5
- version="0.4.3",
5
+ version="0.4.4",
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