flexmetric 0.4.3__py3-none-any.whl → 0.5.0__py3-none-any.whl

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.
@@ -15,7 +15,7 @@ def create_clickhouse_client(db_conf):
15
15
  password = db_conf.get('password', '')
16
16
 
17
17
  client_cert = db_conf.get('client_cert')
18
- client_cert_key = db_conf.get('client_cert_key')
18
+ client_cert_key = db_conf.get('client_key')
19
19
  ca_cert = db_conf.get('ca_cert')
20
20
 
21
21
  secure = bool(client_cert and client_cert_key and ca_cert)
@@ -26,13 +26,14 @@ def create_clickhouse_client(db_conf):
26
26
  'username': username,
27
27
  'password': password,
28
28
  'secure': secure,
29
+ 'verify': True
29
30
  }
30
31
 
31
32
  if secure:
32
33
  settings.update({
33
34
  'client_cert': client_cert,
34
35
  'client_cert_key': client_cert_key,
35
- 'secure_ca': ca_cert,
36
+ 'ca_cert': ca_cert,
36
37
  })
37
38
 
38
39
  client = clickhouse_connect.get_client(**settings)
@@ -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.5.0
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
 
@@ -6,15 +6,15 @@ flexmetric/file_recognition/exec_file.py,sha256=9wBbnqPConxtLhqWTgigEr8VQG-fa9K_
6
6
  flexmetric/logging_module/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  flexmetric/logging_module/logger.py,sha256=hXj9m2Q_KxJVI5YRHRoK6PXV5tO6NmvuVjq2Ipx_1tE,447
8
8
  flexmetric/metric_process/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- flexmetric/metric_process/database_connections.py,sha256=CqYrzXkwoB7yq4SpIu7_jDDNHSemaPsfDJj5DLwHSXM,1574
9
+ flexmetric/metric_process/database_connections.py,sha256=G76qZgKp61gEbejpWL956SM9okUzMavC6nSIrOPnD_k,1590
10
10
  flexmetric/metric_process/database_processing.py,sha256=_7C1DyC9jtgiTUti4_YYFpQlE0BlJwbaEx3OPpDCGSs,4633
11
11
  flexmetric/metric_process/expiring_queue.py,sha256=1oC0MjloitPiRo7yDgVarz81ETEQavKI_W-GFUvp5_Y,1920
12
12
  flexmetric/metric_process/process_commands.py,sha256=clGMQhLNcuJUO1gElpAS9Dyk0KU5w41DIguczjo7ceA,4089
13
13
  flexmetric/metric_process/prometheus_agent.py,sha256=pDPqiPtHLv1cfF6dPRNg2LtAhVF1UKf8MNZ_S9xuRQY,7712
14
- flexmetric/metric_process/queries_execution.py,sha256=uTGcbB8hWVVYX_PsR-sBMrZIByP50bL4KOsdDq2XtKU,858
14
+ flexmetric/metric_process/queries_execution.py,sha256=NdnQ9Flbc8_6VOSY3aHxSmhcCsZf2zIxKTnc0hCp1oU,790
15
15
  flexmetric/metric_process/views.py,sha256=BY695dCpTkJRc1KLC9RNpFTieFdHeHvyqyefmHhMauE,3297
16
- flexmetric-0.4.3.dist-info/METADATA,sha256=Uv0kdl7bM3lEkXwBjQcewIv9ph3APOqtyoCqk8sVFck,10672
17
- flexmetric-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- flexmetric-0.4.3.dist-info/entry_points.txt,sha256=urVePn5EWr3JqNvkYP7OsB_h2_Bqvv-Wq1MJRBexm8A,79
19
- flexmetric-0.4.3.dist-info/top_level.txt,sha256=zBlrNwKhXUNhgu9RRZnXxYwYnmE-eocRe6wKSmQROA4,11
20
- flexmetric-0.4.3.dist-info/RECORD,,
16
+ flexmetric-0.5.0.dist-info/METADATA,sha256=oKYei2gWS8fHPBhlNhUCpdJLeWWb5QiKOwzf1p6PYfU,11276
17
+ flexmetric-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ flexmetric-0.5.0.dist-info/entry_points.txt,sha256=urVePn5EWr3JqNvkYP7OsB_h2_Bqvv-Wq1MJRBexm8A,79
19
+ flexmetric-0.5.0.dist-info/top_level.txt,sha256=zBlrNwKhXUNhgu9RRZnXxYwYnmE-eocRe6wKSmQROA4,11
20
+ flexmetric-0.5.0.dist-info/RECORD,,