wazuh-indexer mkdocs
Taylor committed
Jul 11, 2023 at 17:17 UTC
f09f5254f8f36db19aee0c4ce785a5b5e06634cf
4 files changed
+1508
-145
backend/docs/wazuhindexer.md
+196
@@ -1,25 +1,221 @@
1
## Wazuh-Indexer Overview
2
3
+### <span style="color:blue">Wazuh-Indexer Metrics Models</span>
4
+
5
+# wazuh_indexer.py Overview
6
+
7
+This script contains two primary components: a SQLAlchemy model class `WazuhIndexerAllocation` and a Marshmallow schema class `WazuhIndexerAllocationSchema`.
8
+
9
+## WazuhIndexerAllocation Class
10
+
11
+This class is a SQLAlchemy model that represents a table in a database. Each instance of this class corresponds to a row in the table. The class contains the following fields:
12
+
13
+- `id`: A unique integer ID for the allocation (primary key).
14
+- `node`: The node or host for the allocation (string, max length 100).
15
+- `disk_used`: The amount of disk used (floating-point number).
16
+- `disk_available`: The amount of disk available (floating-point number).
17
+- `disk_total`: The total amount of disk (floating-point number).
18
+- `disk_percent`: The percent of disk used (floating-point number).
19
+- `timestamp`: The timestamp when the allocation was created (DateTime). By default, it is the time when the entry is created.
20
+
21
+It also includes an `__init__` method for initialization and a `__repr__` method that returns a string representation of an instance.
22
+
23
+## WazuhIndexerAllocationSchema Class
24
+
25
+This class is a Marshmallow schema that defines how instances of the `WazuhIndexerAllocation` class are serialized to and deserialized from JSON.
26
+
27
+It includes a nested `Meta` class that specifies the fields to be included in the serialized/deserialized data: "id", "node", "disk_used", "disk_available", "disk_total", "disk_percent", "timestamp".
28
+
29
+At the end of the script, it creates two schema instances: `wazuh_indexer_allocation_schema` for a single `WazuhIndexerAllocation` object, and `wazuh_indexer_allocations_schema` for multiple `WazuhIndexerAllocation` objects (specified by `many=True`).
30
+
31
+## Purpose
32
+
33
+This script is used to interact with a database table that tracks the disk usage on different nodes or hosts. It provides a way to create, read, update, and delete rows in this table, as well as to convert these rows to and from JSON. This can be useful, for instance, in a web service that monitors disk usage.
34
+
35
+::: app.models.wazuh_indexer
36
+<br>
37
+
38
### <span style="color:green">Alert Routes</span>
39
40
+# alerts.py
41
+
42
+This file is part of a Flask application and is responsible for defining an API endpoint related to alerts. The alerts are retrieved using the `AlertsService` and are returned in a JSON format.
43
+
44
+## Dependencies
45
+
46
+The file imports the following modules:
47
+
48
+- `Blueprint` and `jsonify` from the `flask` module.
49
+- `AlertsService` from the `app.services.WazuhIndexer.alerts` module.
50
+
51
+## Blueprint
52
+
53
+A Blueprint, `bp`, is created with the name "alerts". This Blueprint is used to register the routes and their corresponding view functions to the Flask application.
54
+
55
+## Route: "/alerts"
56
+
57
+This route is associated with the `get_alerts()` view function. The route listens for HTTP GET requests. When a GET request is made to the "/alerts" URL, the `get_alerts()` function is invoked.
58
+
59
+## View Function: get_alerts()
60
+
61
+The `get_alerts()` function retrieves all alerts from the `AlertsService`.
62
+
63
+The process is as follows:
64
+
65
+1. An instance of the `AlertsService` class is created.
66
+2. The `collect_alerts()` method of the `AlertsService` instance is called to fetch all alerts.
67
+3. The fetched alerts are returned as a JSON response.
68
+
69
+The function is documented with a docstring that provides a brief description of its purpose, the process it follows to retrieve alerts, and the data it returns.
70
+
71
::: app.routes.alerts
72
<br>
73
74
### <span style="color:green">Wazuh-Indexer Routes</span>
75
76
+# wazuhindexer.py
77
+
78
+The `wazuhindexer.py` file is a Flask Blueprint file that sets up HTTP endpoints for interacting with the Wazuh-Indexer. Wazuh-Indexer is a security detection and response tool that indexes and correlates security data. The endpoints provide information about the indices, allocation of indices, cluster health, and shards in the Wazuh-Indexer.
79
+
80
+The following endpoints are defined:
81
+
82
+## GET /wazuh_indexer/indices
83
+
84
+This endpoint lists all available indices and collects relevant information for each, including:
85
+
86
+- Index name
87
+- Index health status
88
+- Document count in the index
89
+- Size of the index
90
+- Number of replicas for the index
91
+
92
+The returned JSON object contains a list of all available indices along with their respective details.
93
+
94
+## GET /wazuh_indexer/allocation
95
+
96
+This endpoint lists all available indices allocation, including:
97
+
98
+- Disk space used by the index
99
+- Available disk space
100
+- Total disk space
101
+- Disk usage percentage
102
+- Node on which the index resides
103
+
104
+The returned JSON object contains a list of all available indices along with their respective allocation details.
105
+
106
+## GET /wazuh_indexer/health
107
+
108
+This endpoint collects Wazuh-Indexer cluster health information. The returned JSON object contains health information for the Wazuh-Indexer cluster.
109
+
110
+## GET /wazuh_indexer/shards
111
+
112
+This endpoint collects information about Wazuh-Indexer shards. The returned JSON object contains information about the shards in the Wazuh-Indexer.
113
+
114
+The file uses services defined in `ClusterService` and `IndexService` to interact with the Wazuh-Indexer and collect the required information.
115
+
116
::: app.routes.wazuhindexer
117
<br>
118
119
### <span style="color:red">Alert Services</span>
120
121
+# alerts.py
122
+
123
+This Python module contains the `AlertsService` class, which is responsible for handling alert data from the Wazuh-Indexer.
124
+
125
+## `AlertsService` Class
126
+
127
+The `AlertsService` class is a service class that handles the logic of pulling alerts from the Wazuh-Indexer. It manages the connection details to the Wazuh-Indexer and provides methods to collect alerts.
128
+
129
+### Attributes
130
+
131
+- `connector_url`: The URL of the Wazuh-Indexer.
132
+- `connector_username`: The username to authenticate with the Wazuh-Indexer.
133
+- `connector_password`: The password to authenticate with the Wazuh-Indexer.
134
+
135
+The class uses the `UniversalService` class to collect connection details for the Wazuh-Indexer.
136
+
137
+### Methods
138
+
139
+The `AlertsService` class defines various methods for interacting with the Wazuh-Indexer. These methods include:
140
+
141
+- `__init__`: Initializes the `AlertsService` instance and collects Wazuh-Indexer details.
142
+- `_collect_alerts`: Collects alerts from the Wazuh-Indexer.
143
+- `_collect_alerts_details`: Collects detailed information about alerts from the Wazuh-Indexer.
144
+- `_handle_request_error`: Handles errors during HTTP requests to the Wazuh-Indexer.
145
+- `collect_alerts`: Provides a public interface for collecting alerts from the Wazuh-Indexer.
146
+
147
+### Dependencies
148
+
149
+The `alerts.py` file imports the following libraries and modules:
150
+
151
+- `typing`: For supporting type hints.
152
+- `elasticsearch7`: The Python client for Elasticsearch 7.
153
+- `loguru`: A simple and powerful logging utility.
154
+- `app.services.WazuhIndexer.universal`: The `UniversalService` class from the `universal` module in the `WazuhIndexer` package under `app.services`.
155
+
156
::: app.services.WazuhIndexer.alerts
157
158
### <span style="color:red">Cluster Services</span>
159
160
+# cluster.py
161
+
162
+This Python script defines the `ClusterService` class which provides methods for interacting with a Wazuh-Indexer's Elasticsearch cluster. The class includes methods for collecting details about the Wazuh-Indexer, initializing an Elasticsearch client, and fetching various pieces of information about the state of the cluster.
163
+
164
+## Class: ClusterService
165
+
166
+### Initialization
167
+
168
+The `ClusterService` class is initialized by calling the `_collect_wazuhindexer_details()` method to collect details about the Wazuh-Indexer and then initializing the Elasticsearch client with these details.
169
+
170
+### Methods
171
+
172
+The class includes the following methods:
173
+
174
+- `_collect_wazuhindexer_details()`: Collects the details (URL, username, password) of the Wazuh-Indexer.
175
+- `_initialize_es_client()`: Initializes the Elasticsearch client with the collected Wazuh-Indexer details.
176
+- `_are_details_collected()`: Checks if all the required details for the Wazuh-Indexer have been collected.
177
+- `collect_node_allocation()`: Fetches the node allocation details from the Elasticsearch cluster. It returns a dictionary containing the success status, a message, and potentially the node allocation details.
178
+- `_collect_node_allocation()`: Handles the actual request to Elasticsearch to fetch the node allocation details. It returns a dictionary containing the success status, a message, and potentially the node allocation details.
179
+- `_format_node_allocation()`: Formats the node allocation details into a list of dictionaries. Each dictionary contains disk used, disk available, total disk, disk usage percentage, and node name.
180
+- `collect_cluster_health()`: Fetches the cluster health details from Elasticsearch. It returns a dictionary containing the success status, a message, and potentially the cluster health details.
181
+- `_collect_cluster_health()`: Handles the actual request to Elasticsearch to fetch the cluster health details. It returns a dictionary containing the success status, a message, and potentially the cluster health details.
182
+- `collect_shards()`: Fetches the shard details from the Elasticsearch cluster. It returns a dictionary containing the success status, a message, and potentially the shard details.
183
+- `_collect_shards()`: Handles the actual request to Elasticsearch to fetch the shard details. It returns a dictionary containing the success status, a message, and potentially the shard details.
184
+- `_format_shards()`: Formats the shard details into a list of dictionaries. Each dictionary contains index name, shard number, shard state, shard size, and node name.
185
+
186
+In general, the `ClusterService` class provides an interface to query various details about the state of a Wazuh-Indexer's Elasticsearch cluster. It includes methods for collecting details about the cluster's health, node allocation, and shard distribution.
187
+
188
::: app.services.WazuhIndexer.cluster
189
190
### <span style="color:red">Index Services</span>
191
192
+# index.py
193
+
194
+The file `index.py` is a Python module that primarily contains the `IndexService` class. This class encapsulates the logic for interacting with a Wazuh-Indexer's Elasticsearch cluster to collect information about the indices in the cluster.
195
+
196
+Here is a detailed breakdown of the module:
197
+
198
+## IndexService class
199
+
200
+This class is designed to interact with an Elasticsearch cluster, specifically a Wazuh-Indexer.
201
+
202
+### Initialization
203
+
204
+During the initialization of an `IndexService` object, the details of the Wazuh-Indexer are collected, and the Elasticsearch client is initialized.
205
+
206
+### Methods
207
+
208
+The class provides the following methods:
209
+
210
+- `_collect_wazuhindexer_details`: This private method collects the details of the Wazuh-Indexer, which include the connector URL, username, and password.
211
+- `_initialize_es_client`: This private method initializes the Elasticsearch client with the details of the Wazuh-Indexer.
212
+- `_are_details_collected`: This private method checks whether the details of the Wazuh-Indexer have been collected.
213
+- `collect_indices_summary`: This method collects summary information for each index from the Wazuh-Indexer's Elasticsearch cluster.
214
+- `_format_indices_summary`: This private method formats the indices summary into a list of dictionaries. Each dictionary contains the index name, health status, document count, store size, and replica count.
215
+- `_collect_indices`: This private method collects indices from the Wazuh-Indexer's Elasticsearch cluster. It returns a dictionary containing success status, a message, and potentially the indices.
216
+
217
+Overall, this module is used to facilitate the interaction between the application and a Wazuh-Indexer's Elasticsearch cluster, allowing the application to collect and format summary information about the indices in the cluster.
218
+
219
::: app.services.WazuhIndexer.index
220
221
### <span style="color:red">Universal Services</span>
backend/site/objects.inv
Binary files a/backend/site/objects.inv and b/backend/site/objects.inv differ
backend/site/sitemap.xml.gz
Binary files a/backend/site/sitemap.xml.gz and b/backend/site/sitemap.xml.gz differ
backend/site/wazuhindexer/index.html
+1312
-145
@@ -241,8 +241,11 @@
241
<nav class="md-nav" aria-label="Wazuh-Indexer Overview">
242
<ul class="md-nav__list">
243
<li class="md-nav__item">
244
- <a href="#alert-routes" class="md-nav__link">
245
- Alert Routes
244
+ <a
245
+ href="#wazuh-indexer-metrics-models"
246
+ class="md-nav__link"
247
+ >
248
+ Wazuh-Indexer Metrics Models
249
</a>
250
</li>
251
</ul>
@@ -250,280 +253,616 @@
253
</li>
254
255
<li class="md-nav__item">
253
- <a href="#app.routes.alerts" class="md-nav__link">
254
- app.routes.alerts
255
- </a>
256
- </li>
257
-
258
- <li class="md-nav__item">
259
- <a href="#app.routes.alerts.get_alerts" class="md-nav__link">
260
- get_alerts()
256
+ <a href="#wazuh_indexerpy-overview" class="md-nav__link">
257
+ wazuh_indexer.py Overview
258
</a>
259
263
- <nav class="md-nav" aria-label="get_alerts()">
260
+ <nav class="md-nav" aria-label="wazuh_indexer.py Overview">
261
<ul class="md-nav__list">
262
<li class="md-nav__item">
263
<a
267
- href="#wazuh-indexer-routes"
264
+ href="#wazuhindexerallocation-class"
265
+ class="md-nav__link"
266
+ >
267
+ WazuhIndexerAllocation Class
268
+ </a>
269
+ </li>
270
+
271
+ <li class="md-nav__item">
272
+ <a
273
+ href="#wazuhindexerallocationschema-class"
274
+ class="md-nav__link"
275
+ >
276
+ WazuhIndexerAllocationSchema Class
277
+ </a>
278
+ </li>
279
+
280
+ <li class="md-nav__item">
281
+ <a href="#purpose" class="md-nav__link">
282
+ Purpose
283
+ </a>
284
+ </li>
285
+
286
+ <li class="md-nav__item">
287
+ <a
288
+ href="#app.models.wazuh_indexer"
289
+ class="md-nav__link"
290
+ >
291
+ app.models.wazuh_indexer
292
+ </a>
293
+ </li>
294
+
295
+ <li class="md-nav__item">
296
+ <a
297
+ href="#app.models.wazuh_indexer.WazuhIndexerAllocation"
298
class="md-nav__link"
299
>
270
- Wazuh-Indexer Routes
300
+ WazuhIndexerAllocation
301
</a>
302
+
303
+ <nav
304
+ class="md-nav"
305
+ aria-label="WazuhIndexerAllocation"
306
+ >
307
+ <ul class="md-nav__list">
308
+ <li class="md-nav__item">
309
+ <a
310
+ href="#app.models.wazuh_indexer.WazuhIndexerAllocation.__init__"
311
+ class="md-nav__link"
312
+ >
313
+ __init__()
314
+ </a>
315
+ </li>
316
+
317
+ <li class="md-nav__item">
318
+ <a
319
+ href="#app.models.wazuh_indexer.WazuhIndexerAllocation.__repr__"
320
+ class="md-nav__link"
321
+ >
322
+ __repr__()
323
+ </a>
324
+ </li>
325
+ </ul>
326
+ </nav>
327
+ </li>
328
+
329
+ <li class="md-nav__item">
330
+ <a
331
+ href="#app.models.wazuh_indexer.WazuhIndexerAllocationSchema"
332
+ class="md-nav__link"
333
+ >
334
+ WazuhIndexerAllocationSchema
335
+ </a>
336
+
337
+ <nav
338
+ class="md-nav"
339
+ aria-label="WazuhIndexerAllocationSchema"
340
+ >
341
+ <ul class="md-nav__list">
342
+ <li class="md-nav__item">
343
+ <a
344
+ href="#app.models.wazuh_indexer.WazuhIndexerAllocationSchema.Meta"
345
+ class="md-nav__link"
346
+ >
347
+ Meta
348
+ </a>
349
+ </li>
350
+
351
+ <li class="md-nav__item">
352
+ <a
353
+ href="#alert-routes"
354
+ class="md-nav__link"
355
+ >
356
+ Alert Routes
357
+ </a>
358
+ </li>
359
+ </ul>
360
+ </nav>
361
</li>
362
</ul>
363
</nav>
364
</li>
365
366
<li class="md-nav__item">
278
- <a href="#app.routes.wazuhindexer" class="md-nav__link">
279
- app.routes.wazuhindexer
280
- </a>
281
- </li>
367
+ <a href="#alertspy" class="md-nav__link"> alerts.py </a>
368
283
- <li class="md-nav__item">
284
- <a
285
- href="#app.routes.wazuhindexer.get_cluster_health"
286
- class="md-nav__link"
287
- >
288
- get_cluster_health()
289
- </a>
290
- </li>
369
+ <nav class="md-nav" aria-label="alerts.py">
370
+ <ul class="md-nav__list">
371
+ <li class="md-nav__item">
372
+ <a href="#dependencies" class="md-nav__link">
373
+ Dependencies
374
+ </a>
375
+ </li>
376
292
- <li class="md-nav__item">
293
- <a
294
- href="#app.routes.wazuhindexer.get_indices_summary"
295
- class="md-nav__link"
296
- >
297
- get_indices_summary()
298
- </a>
299
- </li>
377
+ <li class="md-nav__item">
378
+ <a href="#blueprint" class="md-nav__link">
379
+ Blueprint
380
+ </a>
381
+ </li>
382
301
- <li class="md-nav__item">
302
- <a
303
- href="#app.routes.wazuhindexer.get_node_allocation"
304
- class="md-nav__link"
305
- >
306
- get_node_allocation()
307
- </a>
308
- </li>
383
+ <li class="md-nav__item">
384
+ <a href="#route-alerts" class="md-nav__link">
385
+ Route: "/alerts"
386
+ </a>
387
+ </li>
388
310
- <li class="md-nav__item">
311
- <a
312
- href="#app.routes.wazuhindexer.get_shards"
313
- class="md-nav__link"
314
- >
315
- get_shards()
316
- </a>
389
+ <li class="md-nav__item">
390
+ <a
391
+ href="#view-function-get_alerts"
392
+ class="md-nav__link"
393
+ >
394
+ View Function: get_alerts()
395
+ </a>
396
+ </li>
397
318
- <nav class="md-nav" aria-label="get_shards()">
319
- <ul class="md-nav__list">
398
<li class="md-nav__item">
321
- <a href="#alert-services" class="md-nav__link">
322
- Alert Services
399
+ <a href="#app.routes.alerts" class="md-nav__link">
400
+ app.routes.alerts
401
</a>
402
</li>
403
+
404
+ <li class="md-nav__item">
405
+ <a
406
+ href="#app.routes.alerts.get_alerts"
407
+ class="md-nav__link"
408
+ >
409
+ get_alerts()
410
+ </a>
411
+
412
+ <nav class="md-nav" aria-label="get_alerts()">
413
+ <ul class="md-nav__list">
414
+ <li class="md-nav__item">
415
+ <a
416
+ href="#wazuh-indexer-routes"
417
+ class="md-nav__link"
418
+ >
419
+ Wazuh-Indexer Routes
420
+ </a>
421
+ </li>
422
+ </ul>
423
+ </nav>
424
+ </li>
425
</ul>
426
</nav>
427
</li>
428
429
<li class="md-nav__item">
330
- <a
331
- href="#app.services.WazuhIndexer.alerts"
332
- class="md-nav__link"
333
- >
334
- app.services.WazuhIndexer.alerts
430
+ <a href="#wazuhindexerpy" class="md-nav__link">
431
+ wazuhindexer.py
432
</a>
336
- </li>
433
338
- <li class="md-nav__item">
339
- <a
340
- href="#app.services.WazuhIndexer.alerts.AlertsService"
341
- class="md-nav__link"
342
- >
343
- AlertsService
344
- </a>
345
-
346
- <nav class="md-nav" aria-label="AlertsService">
434
+ <nav class="md-nav" aria-label="wazuhindexer.py">
435
<ul class="md-nav__list">
436
<li class="md-nav__item">
437
<a
350
- href="#app.services.WazuhIndexer.alerts.AlertsService.__init__"
438
+ href="#get-wazuh_indexerindices"
439
class="md-nav__link"
440
>
353
- __init__()
441
+ GET /wazuh_indexer/indices
442
</a>
443
</li>
444
445
<li class="md-nav__item">
446
<a
359
- href="#app.services.WazuhIndexer.alerts.AlertsService.collect_alerts"
447
+ href="#get-wazuh_indexerallocation"
448
class="md-nav__link"
449
>
362
- collect_alerts()
450
+ GET /wazuh_indexer/allocation
451
</a>
452
</li>
453
454
<li class="md-nav__item">
455
<a
368
- href="#app.services.WazuhIndexer.alerts.AlertsService.is_index_skipped"
456
+ href="#get-wazuh_indexerhealth"
457
class="md-nav__link"
458
>
371
- is_index_skipped()
459
+ GET /wazuh_indexer/health
460
</a>
461
</li>
462
463
<li class="md-nav__item">
376
- <a href="#cluster-services" class="md-nav__link">
377
- Cluster Services
464
+ <a
465
+ href="#get-wazuh_indexershards"
466
+ class="md-nav__link"
467
+ >
468
+ GET /wazuh_indexer/shards
469
</a>
470
</li>
380
- </ul>
381
- </nav>
382
- </li>
471
384
- <li class="md-nav__item">
385
- <a
386
- href="#app.services.WazuhIndexer.cluster"
387
- class="md-nav__link"
388
- >
389
- app.services.WazuhIndexer.cluster
390
- </a>
391
- </li>
392
-
393
- <li class="md-nav__item">
394
- <a
395
- href="#app.services.WazuhIndexer.cluster.ClusterService"
396
- class="md-nav__link"
397
- >
398
- ClusterService
399
- </a>
400
-
401
- <nav class="md-nav" aria-label="ClusterService">
402
- <ul class="md-nav__list">
472
<li class="md-nav__item">
473
<a
405
- href="#app.services.WazuhIndexer.cluster.ClusterService.__init__"
474
+ href="#app.routes.wazuhindexer"
475
class="md-nav__link"
476
>
408
- __init__()
477
+ app.routes.wazuhindexer
478
</a>
479
</li>
480
481
<li class="md-nav__item">
482
<a
414
- href="#app.services.WazuhIndexer.cluster.ClusterService.collect_cluster_health"
483
+ href="#app.routes.wazuhindexer.get_cluster_health"
484
class="md-nav__link"
485
>
417
- collect_cluster_health()
486
+ get_cluster_health()
487
</a>
488
</li>
489
490
<li class="md-nav__item">
491
<a
423
- href="#app.services.WazuhIndexer.cluster.ClusterService.collect_node_allocation"
492
+ href="#app.routes.wazuhindexer.get_indices_summary"
493
class="md-nav__link"
494
>
426
- collect_node_allocation()
495
+ get_indices_summary()
496
</a>
497
</li>
498
499
<li class="md-nav__item">
500
<a
432
- href="#app.services.WazuhIndexer.cluster.ClusterService.collect_shards"
501
+ href="#app.routes.wazuhindexer.get_node_allocation"
502
class="md-nav__link"
503
>
435
- collect_shards()
504
+ get_node_allocation()
505
</a>
506
</li>
507
508
<li class="md-nav__item">
440
- <a href="#index-services" class="md-nav__link">
441
- Index Services
509
+ <a
510
+ href="#app.routes.wazuhindexer.get_shards"
511
+ class="md-nav__link"
512
+ >
513
+ get_shards()
514
</a>
515
+
516
+ <nav class="md-nav" aria-label="get_shards()">
517
+ <ul class="md-nav__list">
518
+ <li class="md-nav__item">
519
+ <a
520
+ href="#alert-services"
521
+ class="md-nav__link"
522
+ >
523
+ Alert Services
524
+ </a>
525
+ </li>
526
+ </ul>
527
+ </nav>
528
</li>
529
</ul>
530
</nav>
531
</li>
532
533
<li class="md-nav__item">
449
- <a href="#app.services.WazuhIndexer.index" class="md-nav__link">
450
- app.services.WazuhIndexer.index
451
- </a>
534
+ <a href="#alertspy_1" class="md-nav__link"> alerts.py </a>
535
+
536
+ <nav class="md-nav" aria-label="alerts.py">
537
+ <ul class="md-nav__list">
538
+ <li class="md-nav__item">
539
+ <a href="#alertsservice-class" class="md-nav__link">
540
+ AlertsService Class
541
+ </a>
542
+
543
+ <nav
544
+ class="md-nav"
545
+ aria-label="AlertsService Class"
546
+ >
547
+ <ul class="md-nav__list">
548
+ <li class="md-nav__item">
549
+ <a
550
+ href="#attributes"
551
+ class="md-nav__link"
552
+ >
553
+ Attributes
554
+ </a>
555
+ </li>
556
+
557
+ <li class="md-nav__item">
558
+ <a href="#methods" class="md-nav__link">
559
+ Methods
560
+ </a>
561
+ </li>
562
+
563
+ <li class="md-nav__item">
564
+ <a
565
+ href="#dependencies_1"
566
+ class="md-nav__link"
567
+ >
568
+ Dependencies
569
+ </a>
570
+ </li>
571
+ </ul>
572
+ </nav>
573
+ </li>
574
+
575
+ <li class="md-nav__item">
576
+ <a
577
+ href="#app.services.WazuhIndexer.alerts"
578
+ class="md-nav__link"
579
+ >
580
+ app.services.WazuhIndexer.alerts
581
+ </a>
582
+ </li>
583
+
584
+ <li class="md-nav__item">
585
+ <a
586
+ href="#app.services.WazuhIndexer.alerts.AlertsService"
587
+ class="md-nav__link"
588
+ >
589
+ AlertsService
590
+ </a>
591
+
592
+ <nav class="md-nav" aria-label="AlertsService">
593
+ <ul class="md-nav__list">
594
+ <li class="md-nav__item">
595
+ <a
596
+ href="#app.services.WazuhIndexer.alerts.AlertsService.__init__"
597
+ class="md-nav__link"
598
+ >
599
+ __init__()
600
+ </a>
601
+ </li>
602
+
603
+ <li class="md-nav__item">
604
+ <a
605
+ href="#app.services.WazuhIndexer.alerts.AlertsService.collect_alerts"
606
+ class="md-nav__link"
607
+ >
608
+ collect_alerts()
609
+ </a>
610
+ </li>
611
+
612
+ <li class="md-nav__item">
613
+ <a
614
+ href="#app.services.WazuhIndexer.alerts.AlertsService.is_index_skipped"
615
+ class="md-nav__link"
616
+ >
617
+ is_index_skipped()
618
+ </a>
619
+ </li>
620
+
621
+ <li class="md-nav__item">
622
+ <a
623
+ href="#cluster-services"
624
+ class="md-nav__link"
625
+ >
626
+ Cluster Services
627
+ </a>
628
+ </li>
629
+ </ul>
630
+ </nav>
631
+ </li>
632
+ </ul>
633
+ </nav>
634
</li>
635
636
<li class="md-nav__item">
455
- <a
456
- href="#app.services.WazuhIndexer.index.IndexService"
457
- class="md-nav__link"
458
- >
459
- IndexService
460
- </a>
637
+ <a href="#clusterpy" class="md-nav__link"> cluster.py </a>
638
462
- <nav class="md-nav" aria-label="IndexService">
639
+ <nav class="md-nav" aria-label="cluster.py">
640
<ul class="md-nav__list">
641
<li class="md-nav__item">
642
<a
466
- href="#app.services.WazuhIndexer.index.IndexService.__init__"
643
+ href="#class-clusterservice"
644
class="md-nav__link"
645
>
469
- __init__()
646
+ Class: ClusterService
647
</a>
648
+
649
+ <nav
650
+ class="md-nav"
651
+ aria-label="Class: ClusterService"
652
+ >
653
+ <ul class="md-nav__list">
654
+ <li class="md-nav__item">
655
+ <a
656
+ href="#initialization"
657
+ class="md-nav__link"
658
+ >
659
+ Initialization
660
+ </a>
661
+ </li>
662
+
663
+ <li class="md-nav__item">
664
+ <a
665
+ href="#methods_1"
666
+ class="md-nav__link"
667
+ >
668
+ Methods
669
+ </a>
670
+ </li>
671
+ </ul>
672
+ </nav>
673
</li>
674
675
<li class="md-nav__item">
676
<a
475
- href="#app.services.WazuhIndexer.index.IndexService.collect_indices_summary"
677
+ href="#app.services.WazuhIndexer.cluster"
678
class="md-nav__link"
679
>
478
- collect_indices_summary()
680
+ app.services.WazuhIndexer.cluster
681
</a>
682
</li>
683
684
<li class="md-nav__item">
483
- <a href="#universal-services" class="md-nav__link">
484
- Universal Services
685
+ <a
686
+ href="#app.services.WazuhIndexer.cluster.ClusterService"
687
+ class="md-nav__link"
688
+ >
689
+ ClusterService
690
</a>
691
+
692
+ <nav class="md-nav" aria-label="ClusterService">
693
+ <ul class="md-nav__list">
694
+ <li class="md-nav__item">
695
+ <a
696
+ href="#app.services.WazuhIndexer.cluster.ClusterService.__init__"
697
+ class="md-nav__link"
698
+ >
699
+ __init__()
700
+ </a>
701
+ </li>
702
+
703
+ <li class="md-nav__item">
704
+ <a
705
+ href="#app.services.WazuhIndexer.cluster.ClusterService.collect_cluster_health"
706
+ class="md-nav__link"
707
+ >
708
+ collect_cluster_health()
709
+ </a>
710
+ </li>
711
+
712
+ <li class="md-nav__item">
713
+ <a
714
+ href="#app.services.WazuhIndexer.cluster.ClusterService.collect_node_allocation"
715
+ class="md-nav__link"
716
+ >
717
+ collect_node_allocation()
718
+ </a>
719
+ </li>
720
+
721
+ <li class="md-nav__item">
722
+ <a
723
+ href="#app.services.WazuhIndexer.cluster.ClusterService.collect_shards"
724
+ class="md-nav__link"
725
+ >
726
+ collect_shards()
727
+ </a>
728
+ </li>
729
+
730
+ <li class="md-nav__item">
731
+ <a
732
+ href="#index-services"
733
+ class="md-nav__link"
734
+ >
735
+ Index Services
736
+ </a>
737
+ </li>
738
+ </ul>
739
+ </nav>
740
</li>
741
</ul>
742
</nav>
743
</li>
744
745
<li class="md-nav__item">
492
- <a
493
- href="#app.services.WazuhIndexer.universal"
494
- class="md-nav__link"
495
- >
496
- app.services.WazuhIndexer.universal
497
- </a>
498
- </li>
746
+ <a href="#indexpy" class="md-nav__link"> index.py </a>
747
500
- <li class="md-nav__item">
501
- <a
502
- href="#app.services.WazuhIndexer.universal.UniversalService"
503
- class="md-nav__link"
504
- >
505
- UniversalService
506
- </a>
507
-
508
- <nav class="md-nav" aria-label="UniversalService">
748
+ <nav class="md-nav" aria-label="index.py">
749
<ul class="md-nav__list">
750
+ <li class="md-nav__item">
751
+ <a href="#indexservice-class" class="md-nav__link">
752
+ IndexService class
753
+ </a>
754
+
755
+ <nav class="md-nav" aria-label="IndexService class">
756
+ <ul class="md-nav__list">
757
+ <li class="md-nav__item">
758
+ <a
759
+ href="#initialization_1"
760
+ class="md-nav__link"
761
+ >
762
+ Initialization
763
+ </a>
764
+ </li>
765
+
766
+ <li class="md-nav__item">
767
+ <a
768
+ href="#methods_2"
769
+ class="md-nav__link"
770
+ >
771
+ Methods
772
+ </a>
773
+ </li>
774
+ </ul>
775
+ </nav>
776
+ </li>
777
+
778
<li class="md-nav__item">
779
<a
512
- href="#app.services.WazuhIndexer.universal.UniversalService.collect_indices"
780
+ href="#app.services.WazuhIndexer.index"
781
class="md-nav__link"
782
>
515
- collect_indices()
783
+ app.services.WazuhIndexer.index
784
</a>
785
</li>
786
787
<li class="md-nav__item">
788
<a
521
- href="#app.services.WazuhIndexer.universal.UniversalService.collect_wazuhindexer_details"
789
+ href="#app.services.WazuhIndexer.index.IndexService"
790
+ class="md-nav__link"
791
+ >
792
+ IndexService
793
+ </a>
794
+
795
+ <nav class="md-nav" aria-label="IndexService">
796
+ <ul class="md-nav__list">
797
+ <li class="md-nav__item">
798
+ <a
799
+ href="#app.services.WazuhIndexer.index.IndexService.__init__"
800
+ class="md-nav__link"
801
+ >
802
+ __init__()
803
+ </a>
804
+ </li>
805
+
806
+ <li class="md-nav__item">
807
+ <a
808
+ href="#app.services.WazuhIndexer.index.IndexService.collect_indices_summary"
809
+ class="md-nav__link"
810
+ >
811
+ collect_indices_summary()
812
+ </a>
813
+ </li>
814
+
815
+ <li class="md-nav__item">
816
+ <a
817
+ href="#universal-services"
818
+ class="md-nav__link"
819
+ >
820
+ Universal Services
821
+ </a>
822
+ </li>
823
+ </ul>
824
+ </nav>
825
+ </li>
826
+
827
+ <li class="md-nav__item">
828
+ <a
829
+ href="#app.services.WazuhIndexer.universal"
830
class="md-nav__link"
831
>
524
- collect_wazuhindexer_details()
832
+ app.services.WazuhIndexer.universal
833
</a>
834
</li>
835
+
836
+ <li class="md-nav__item">
837
+ <a
838
+ href="#app.services.WazuhIndexer.universal.UniversalService"
839
+ class="md-nav__link"
840
+ >
841
+ UniversalService
842
+ </a>
843
+
844
+ <nav class="md-nav" aria-label="UniversalService">
845
+ <ul class="md-nav__list">
846
+ <li class="md-nav__item">
847
+ <a
848
+ href="#app.services.WazuhIndexer.universal.UniversalService.collect_indices"
849
+ class="md-nav__link"
850
+ >
851
+ collect_indices()
852
+ </a>
853
+ </li>
854
+
855
+ <li class="md-nav__item">
856
+ <a
857
+ href="#app.services.WazuhIndexer.universal.UniversalService.collect_wazuhindexer_details"
858
+ class="md-nav__link"
859
+ >
860
+ collect_wazuhindexer_details()
861
+ </a>
862
+ </li>
863
+ </ul>
864
+ </nav>
865
+ </li>
866
</ul>
867
</nav>
868
</li>
@@ -558,10 +897,593 @@
897
898
<div class="md-content" data-md-component="content">
899
<article class="md-content__inner md-typeset">
561
- <h1>Wazuh-Indexer</h1>
562
-
900
<h2 id="wazuh-indexer-overview">Wazuh-Indexer Overview</h2>
901
+ <h3 id="wazuh-indexer-metrics-models">
902
+ <span style="color: blue">Wazuh-Indexer Metrics Models</span>
903
+ </h3>
904
+ <h1 id="wazuh_indexerpy-overview">wazuh_indexer.py Overview</h1>
905
+ <p>
906
+ This script contains two primary components: a SQLAlchemy model class
907
+ <code>WazuhIndexerAllocation</code> and a Marshmallow schema class
908
+ <code>WazuhIndexerAllocationSchema</code>.
909
+ </p>
910
+ <h2 id="wazuhindexerallocation-class">WazuhIndexerAllocation Class</h2>
911
+ <p>
912
+ This class is a SQLAlchemy model that represents a table in a database. Each instance of
913
+ this class corresponds to a row in the table. The class contains the following fields:
914
+ </p>
915
+ <ul>
916
+ <li><code>id</code>: A unique integer ID for the allocation (primary key).</li>
917
+ <li>
918
+ <code>node</code>: The node or host for the allocation (string, max length 100).
919
+ </li>
920
+ <li><code>disk_used</code>: The amount of disk used (floating-point number).</li>
921
+ <li>
922
+ <code>disk_available</code>: The amount of disk available (floating-point number).
923
+ </li>
924
+ <li><code>disk_total</code>: The total amount of disk (floating-point number).</li>
925
+ <li><code>disk_percent</code>: The percent of disk used (floating-point number).</li>
926
+ <li>
927
+ <code>timestamp</code>: The timestamp when the allocation was created (DateTime). By
928
+ default, it is the time when the entry is created.
929
+ </li>
930
+ </ul>
931
+ <p>
932
+ It also includes an <code>__init__</code> method for initialization and a
933
+ <code>__repr__</code> method that returns a string representation of an instance.
934
+ </p>
935
+ <h2 id="wazuhindexerallocationschema-class">WazuhIndexerAllocationSchema Class</h2>
936
+ <p>
937
+ This class is a Marshmallow schema that defines how instances of the
938
+ <code>WazuhIndexerAllocation</code> class are serialized to and deserialized from JSON.
939
+ </p>
940
+ <p>
941
+ It includes a nested <code>Meta</code> class that specifies the fields to be included in
942
+ the serialized/deserialized data: "id", "node", "disk_used", "disk_available",
943
+ "disk_total", "disk_percent", "timestamp".
944
+ </p>
945
+ <p>
946
+ At the end of the script, it creates two schema instances:
947
+ <code>wazuh_indexer_allocation_schema</code> for a single
948
+ <code>WazuhIndexerAllocation</code> object, and
949
+ <code>wazuh_indexer_allocations_schema</code> for multiple
950
+ <code>WazuhIndexerAllocation</code> objects (specified by <code>many=True</code>).
951
+ </p>
952
+ <h2 id="purpose">Purpose</h2>
953
+ <p>
954
+ This script is used to interact with a database table that tracks the disk usage on
955
+ different nodes or hosts. It provides a way to create, read, update, and delete rows in
956
+ this table, as well as to convert these rows to and from JSON. This can be useful, for
957
+ instance, in a web service that monitors disk usage.
958
+ </p>
959
+
960
+ <div class="doc doc-object doc-module">
961
+ <a id="app.models.wazuh_indexer"></a>
962
+ <div class="doc doc-contents first">
963
+ <div class="doc doc-children">
964
+ <div class="doc doc-object doc-class">
965
+ <h2
966
+ id="app.models.wazuh_indexer.WazuhIndexerAllocation"
967
+ class="doc doc-heading"
968
+ >
969
+ <code>WazuhIndexerAllocation</code>
970
+ </h2>
971
+
972
+ <div class="doc doc-contents">
973
+ <p class="doc doc-class-bases">
974
+ Bases:
975
+ <code
976
+ ><span title="app.db">db</span>.<span title="app.db.Model"
977
+ >Model</span
978
+ ></code
979
+ >
980
+ </p>
981
+
982
+ <p>
983
+ Class for Wazuh indexer allocation which stores disk stats and the
984
+ host. The timestamp is generated for each entry and it is invoked
985
+ every 5 minutes. This class inherits from SQLAlchemy's Model class.
986
+ </p>
987
+ <p>
988
+ :ivar id: Unique integer ID for the allocation. :ivar node: The node
989
+ or host for the allocation. :ivar disk_used: The amount of disk
990
+ used. :ivar disk_available: The amount of disk available. :ivar
991
+ disk_total: The total amount of disk. :ivar disk_percent: The
992
+ percent of disk used. :ivar timestamp: The timestamp when the
993
+ allocation was created.
994
+ </p>
995
+
996
+ <details class="quote">
997
+ <summary>
998
+ Source code in <code>app\models\wazuh_indexer.py</code>
999
+ </summary>
1000
+ <div class="highlight">
1001
+ <table class="highlighttable">
1002
+ <tr>
1003
+ <td class="linenos">
1004
+ <div class="linenodiv">
1005
+ <pre><span></span><span class="normal"><a href="#__codelineno-0-14">14</a></span>
1006
+<span class="normal"><a href="#__codelineno-0-15">15</a></span>
1007
+<span class="normal"><a href="#__codelineno-0-16">16</a></span>
1008
+<span class="normal"><a href="#__codelineno-0-17">17</a></span>
1009
+<span class="normal"><a href="#__codelineno-0-18">18</a></span>
1010
+<span class="normal"><a href="#__codelineno-0-19">19</a></span>
1011
+<span class="normal"><a href="#__codelineno-0-20">20</a></span>
1012
+<span class="normal"><a href="#__codelineno-0-21">21</a></span>
1013
+<span class="normal"><a href="#__codelineno-0-22">22</a></span>
1014
+<span class="normal"><a href="#__codelineno-0-23">23</a></span>
1015
+<span class="normal"><a href="#__codelineno-0-24">24</a></span>
1016
+<span class="normal"><a href="#__codelineno-0-25">25</a></span>
1017
+<span class="normal"><a href="#__codelineno-0-26">26</a></span>
1018
+<span class="normal"><a href="#__codelineno-0-27">27</a></span>
1019
+<span class="normal"><a href="#__codelineno-0-28">28</a></span>
1020
+<span class="normal"><a href="#__codelineno-0-29">29</a></span>
1021
+<span class="normal"><a href="#__codelineno-0-30">30</a></span>
1022
+<span class="normal"><a href="#__codelineno-0-31">31</a></span>
1023
+<span class="normal"><a href="#__codelineno-0-32">32</a></span>
1024
+<span class="normal"><a href="#__codelineno-0-33">33</a></span>
1025
+<span class="normal"><a href="#__codelineno-0-34">34</a></span>
1026
+<span class="normal"><a href="#__codelineno-0-35">35</a></span>
1027
+<span class="normal"><a href="#__codelineno-0-36">36</a></span>
1028
+<span class="normal"><a href="#__codelineno-0-37">37</a></span>
1029
+<span class="normal"><a href="#__codelineno-0-38">38</a></span>
1030
+<span class="normal"><a href="#__codelineno-0-39">39</a></span>
1031
+<span class="normal"><a href="#__codelineno-0-40">40</a></span>
1032
+<span class="normal"><a href="#__codelineno-0-41">41</a></span>
1033
+<span class="normal"><a href="#__codelineno-0-42">42</a></span>
1034
+<span class="normal"><a href="#__codelineno-0-43">43</a></span>
1035
+<span class="normal"><a href="#__codelineno-0-44">44</a></span>
1036
+<span class="normal"><a href="#__codelineno-0-45">45</a></span>
1037
+<span class="normal"><a href="#__codelineno-0-46">46</a></span>
1038
+<span class="normal"><a href="#__codelineno-0-47">47</a></span>
1039
+<span class="normal"><a href="#__codelineno-0-48">48</a></span>
1040
+<span class="normal"><a href="#__codelineno-0-49">49</a></span>
1041
+<span class="normal"><a href="#__codelineno-0-50">50</a></span>
1042
+<span class="normal"><a href="#__codelineno-0-51">51</a></span>
1043
+<span class="normal"><a href="#__codelineno-0-52">52</a></span>
1044
+<span class="normal"><a href="#__codelineno-0-53">53</a></span>
1045
+<span class="normal"><a href="#__codelineno-0-54">54</a></span>
1046
+<span class="normal"><a href="#__codelineno-0-55">55</a></span>
1047
+<span class="normal"><a href="#__codelineno-0-56">56</a></span>
1048
+<span class="normal"><a href="#__codelineno-0-57">57</a></span>
1049
+<span class="normal"><a href="#__codelineno-0-58">58</a></span>
1050
+<span class="normal"><a href="#__codelineno-0-59">59</a></span>
1051
+<span class="normal"><a href="#__codelineno-0-60">60</a></span>
1052
+<span class="normal"><a href="#__codelineno-0-61">61</a></span>
1053
+<span class="normal"><a href="#__codelineno-0-62">62</a></span>
1054
+<span class="normal"><a href="#__codelineno-0-63">63</a></span>
1055
+<span class="normal"><a href="#__codelineno-0-64">64</a></span>
1056
+<span class="normal"><a href="#__codelineno-0-65">65</a></span>
1057
+<span class="normal"><a href="#__codelineno-0-66">66</a></span></pre>
1058
+ </div>
1059
+ </td>
1060
+ <td class="code">
1061
+ <div>
1062
+ <pre><span></span><code><a id="__codelineno-0-14" name="__codelineno-0-14"></a><span class="k">class</span> <span class="nc">WazuhIndexerAllocation</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
1063
+<a id="__codelineno-0-15" name="__codelineno-0-15"></a><span class="w"> </span><span class="sd">"""</span>
1064
+<a id="__codelineno-0-16" name="__codelineno-0-16"></a><span class="sd"> Class for Wazuh indexer allocation which stores disk stats and the host.</span>
1065
+<a id="__codelineno-0-17" name="__codelineno-0-17"></a><span class="sd"> The timestamp is generated for each entry and it is invoked every 5 minutes.</span>
1066
+<a id="__codelineno-0-18" name="__codelineno-0-18"></a><span class="sd"> This class inherits from SQLAlchemy's Model class.</span>
1067
+<a id="__codelineno-0-19" name="__codelineno-0-19"></a>
1068
+<a id="__codelineno-0-20" name="__codelineno-0-20"></a><span class="sd"> :ivar id: Unique integer ID for the allocation.</span>
1069
+<a id="__codelineno-0-21" name="__codelineno-0-21"></a><span class="sd"> :ivar node: The node or host for the allocation.</span>
1070
+<a id="__codelineno-0-22" name="__codelineno-0-22"></a><span class="sd"> :ivar disk_used: The amount of disk used.</span>
1071
+<a id="__codelineno-0-23" name="__codelineno-0-23"></a><span class="sd"> :ivar disk_available: The amount of disk available.</span>
1072
+<a id="__codelineno-0-24" name="__codelineno-0-24"></a><span class="sd"> :ivar disk_total: The total amount of disk.</span>
1073
+<a id="__codelineno-0-25" name="__codelineno-0-25"></a><span class="sd"> :ivar disk_percent: The percent of disk used.</span>
1074
+<a id="__codelineno-0-26" name="__codelineno-0-26"></a><span class="sd"> :ivar timestamp: The timestamp when the allocation was created.</span>
1075
+<a id="__codelineno-0-27" name="__codelineno-0-27"></a><span class="sd"> """</span>
1076
+<a id="__codelineno-0-28" name="__codelineno-0-28"></a>
1077
+<a id="__codelineno-0-29" name="__codelineno-0-29"></a> <span class="nb">id</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">Integer</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
1078
+<a id="__codelineno-0-30" name="__codelineno-0-30"></a> <span class="n">node</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">String</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">(</span><span class="mi">100</span><span class="p">))</span>
1079
+<a id="__codelineno-0-31" name="__codelineno-0-31"></a> <span class="n">disk_used</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">Float</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Float</span><span class="p">)</span>
1080
+<a id="__codelineno-0-32" name="__codelineno-0-32"></a> <span class="n">disk_available</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">Float</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Float</span><span class="p">)</span>
1081
+<a id="__codelineno-0-33" name="__codelineno-0-33"></a> <span class="n">disk_total</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">Float</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Float</span><span class="p">)</span>
1082
+<a id="__codelineno-0-34" name="__codelineno-0-34"></a> <span class="n">disk_percent</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">Float</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Float</span><span class="p">)</span>
1083
+<a id="__codelineno-0-35" name="__codelineno-0-35"></a> <span class="n">timestamp</span><span class="p">:</span> <span class="n">Column</span><span class="p">[</span><span class="n">DateTime</span><span class="p">]</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">DateTime</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">)</span>
1084
+<a id="__codelineno-0-36" name="__codelineno-0-36"></a>
1085
+<a id="__codelineno-0-37" name="__codelineno-0-37"></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
1086
+<a id="__codelineno-0-38" name="__codelineno-0-38"></a> <span class="bp">self</span><span class="p">,</span>
1087
+<a id="__codelineno-0-39" name="__codelineno-0-39"></a> <span class="n">node</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
1088
+<a id="__codelineno-0-40" name="__codelineno-0-40"></a> <span class="n">disk_used</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1089
+<a id="__codelineno-0-41" name="__codelineno-0-41"></a> <span class="n">disk_available</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1090
+<a id="__codelineno-0-42" name="__codelineno-0-42"></a> <span class="n">disk_total</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1091
+<a id="__codelineno-0-43" name="__codelineno-0-43"></a> <span class="n">disk_percent</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1092
+<a id="__codelineno-0-44" name="__codelineno-0-44"></a> <span class="p">):</span>
1093
+<a id="__codelineno-0-45" name="__codelineno-0-45"></a><span class="w"> </span><span class="sd">"""</span>
1094
+<a id="__codelineno-0-46" name="__codelineno-0-46"></a><span class="sd"> Initialize a new instance of the WazuhIndexerAllocation class.</span>
1095
+<a id="__codelineno-0-47" name="__codelineno-0-47"></a>
1096
+<a id="__codelineno-0-48" name="__codelineno-0-48"></a><span class="sd"> :param node: The node or host for the allocation.</span>
1097
+<a id="__codelineno-0-49" name="__codelineno-0-49"></a><span class="sd"> :param disk_used: The amount of disk used.</span>
1098
+<a id="__codelineno-0-50" name="__codelineno-0-50"></a><span class="sd"> :param disk_available: The amount of disk available.</span>
1099
+<a id="__codelineno-0-51" name="__codelineno-0-51"></a><span class="sd"> :param disk_total: The total amount of disk.</span>
1100
+<a id="__codelineno-0-52" name="__codelineno-0-52"></a><span class="sd"> :param disk_percent: The percent of disk used.</span>
1101
+<a id="__codelineno-0-53" name="__codelineno-0-53"></a><span class="sd"> """</span>
1102
+<a id="__codelineno-0-54" name="__codelineno-0-54"></a> <span class="bp">self</span><span class="o">.</span><span class="n">node</span> <span class="o">=</span> <span class="n">node</span>
1103
+<a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_used</span> <span class="o">=</span> <span class="n">disk_used</span>
1104
+<a id="__codelineno-0-56" name="__codelineno-0-56"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_available</span> <span class="o">=</span> <span class="n">disk_available</span>
1105
+<a id="__codelineno-0-57" name="__codelineno-0-57"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_total</span> <span class="o">=</span> <span class="n">disk_total</span>
1106
+<a id="__codelineno-0-58" name="__codelineno-0-58"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_percent</span> <span class="o">=</span> <span class="n">disk_percent</span>
1107
+<a id="__codelineno-0-59" name="__codelineno-0-59"></a>
1108
+<a id="__codelineno-0-60" name="__codelineno-0-60"></a> <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span>
1109
+<a id="__codelineno-0-61" name="__codelineno-0-61"></a><span class="w"> </span><span class="sd">"""</span>
1110
+<a id="__codelineno-0-62" name="__codelineno-0-62"></a><span class="sd"> Returns a string representation of the WazuhIndexerAllocation instance.</span>
1111
+<a id="__codelineno-0-63" name="__codelineno-0-63"></a>
1112
+<a id="__codelineno-0-64" name="__codelineno-0-64"></a><span class="sd"> :return: A string representation of the node.</span>
1113
+<a id="__codelineno-0-65" name="__codelineno-0-65"></a><span class="sd"> """</span>
1114
+<a id="__codelineno-0-66" name="__codelineno-0-66"></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<WazuhIndexerAllocation </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">node</span><span class="si">}</span><span class="s2">>"</span>
1115
+</code></pre>
1116
+ </div>
1117
+ </td>
1118
+ </tr>
1119
+ </table>
1120
+ </div>
1121
+ </details>
1122
+
1123
+ <div class="doc doc-children">
1124
+ <div class="doc doc-object doc-function">
1125
+ <h3
1126
+ id="app.models.wazuh_indexer.WazuhIndexerAllocation.__init__"
1127
+ class="doc doc-heading"
1128
+ >
1129
+ <code class="highlight language-python"
1130
+ ><span class="fm">__init__</span><span class="p">(</span
1131
+ ><span class="n">node</span><span class="p">,</span>
1132
+ <span class="n">disk_used</span
1133
+ ><span class="p">,</span>
1134
+ <span class="n">disk_available</span
1135
+ ><span class="p">,</span>
1136
+ <span class="n">disk_total</span
1137
+ ><span class="p">,</span>
1138
+ <span class="n">disk_percent</span
1139
+ ><span class="p">)</span></code
1140
+ >
1141
+ </h3>
1142
+
1143
+ <div class="doc doc-contents">
1144
+ <p>
1145
+ Initialize a new instance of the WazuhIndexerAllocation
1146
+ class.
1147
+ </p>
1148
+ <p>
1149
+ :param node: The node or host for the allocation. :param
1150
+ disk_used: The amount of disk used. :param
1151
+ disk_available: The amount of disk available. :param
1152
+ disk_total: The total amount of disk. :param
1153
+ disk_percent: The percent of disk used.
1154
+ </p>
1155
+
1156
+ <details class="quote">
1157
+ <summary>
1158
+ Source code in
1159
+ <code>app\models\wazuh_indexer.py</code>
1160
+ </summary>
1161
+ <div class="highlight">
1162
+ <table class="highlighttable">
1163
+ <tr>
1164
+ <td class="linenos">
1165
+ <div class="linenodiv">
1166
+ <pre><span></span><span class="normal"><a href="#__codelineno-0-37">37</a></span>
1167
+<span class="normal"><a href="#__codelineno-0-38">38</a></span>
1168
+<span class="normal"><a href="#__codelineno-0-39">39</a></span>
1169
+<span class="normal"><a href="#__codelineno-0-40">40</a></span>
1170
+<span class="normal"><a href="#__codelineno-0-41">41</a></span>
1171
+<span class="normal"><a href="#__codelineno-0-42">42</a></span>
1172
+<span class="normal"><a href="#__codelineno-0-43">43</a></span>
1173
+<span class="normal"><a href="#__codelineno-0-44">44</a></span>
1174
+<span class="normal"><a href="#__codelineno-0-45">45</a></span>
1175
+<span class="normal"><a href="#__codelineno-0-46">46</a></span>
1176
+<span class="normal"><a href="#__codelineno-0-47">47</a></span>
1177
+<span class="normal"><a href="#__codelineno-0-48">48</a></span>
1178
+<span class="normal"><a href="#__codelineno-0-49">49</a></span>
1179
+<span class="normal"><a href="#__codelineno-0-50">50</a></span>
1180
+<span class="normal"><a href="#__codelineno-0-51">51</a></span>
1181
+<span class="normal"><a href="#__codelineno-0-52">52</a></span>
1182
+<span class="normal"><a href="#__codelineno-0-53">53</a></span>
1183
+<span class="normal"><a href="#__codelineno-0-54">54</a></span>
1184
+<span class="normal"><a href="#__codelineno-0-55">55</a></span>
1185
+<span class="normal"><a href="#__codelineno-0-56">56</a></span>
1186
+<span class="normal"><a href="#__codelineno-0-57">57</a></span>
1187
+<span class="normal"><a href="#__codelineno-0-58">58</a></span></pre>
1188
+ </div>
1189
+ </td>
1190
+ <td class="code">
1191
+ <div>
1192
+ <pre><span></span><code><a id="__codelineno-0-37" name="__codelineno-0-37"></a><span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
1193
+<a id="__codelineno-0-38" name="__codelineno-0-38"></a> <span class="bp">self</span><span class="p">,</span>
1194
+<a id="__codelineno-0-39" name="__codelineno-0-39"></a> <span class="n">node</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
1195
+<a id="__codelineno-0-40" name="__codelineno-0-40"></a> <span class="n">disk_used</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1196
+<a id="__codelineno-0-41" name="__codelineno-0-41"></a> <span class="n">disk_available</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1197
+<a id="__codelineno-0-42" name="__codelineno-0-42"></a> <span class="n">disk_total</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1198
+<a id="__codelineno-0-43" name="__codelineno-0-43"></a> <span class="n">disk_percent</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
1199
+<a id="__codelineno-0-44" name="__codelineno-0-44"></a><span class="p">):</span>
1200
+<a id="__codelineno-0-45" name="__codelineno-0-45"></a><span class="w"> </span><span class="sd">"""</span>
1201
+<a id="__codelineno-0-46" name="__codelineno-0-46"></a><span class="sd"> Initialize a new instance of the WazuhIndexerAllocation class.</span>
1202
+<a id="__codelineno-0-47" name="__codelineno-0-47"></a>
1203
+<a id="__codelineno-0-48" name="__codelineno-0-48"></a><span class="sd"> :param node: The node or host for the allocation.</span>
1204
+<a id="__codelineno-0-49" name="__codelineno-0-49"></a><span class="sd"> :param disk_used: The amount of disk used.</span>
1205
+<a id="__codelineno-0-50" name="__codelineno-0-50"></a><span class="sd"> :param disk_available: The amount of disk available.</span>
1206
+<a id="__codelineno-0-51" name="__codelineno-0-51"></a><span class="sd"> :param disk_total: The total amount of disk.</span>
1207
+<a id="__codelineno-0-52" name="__codelineno-0-52"></a><span class="sd"> :param disk_percent: The percent of disk used.</span>
1208
+<a id="__codelineno-0-53" name="__codelineno-0-53"></a><span class="sd"> """</span>
1209
+<a id="__codelineno-0-54" name="__codelineno-0-54"></a> <span class="bp">self</span><span class="o">.</span><span class="n">node</span> <span class="o">=</span> <span class="n">node</span>
1210
+<a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_used</span> <span class="o">=</span> <span class="n">disk_used</span>
1211
+<a id="__codelineno-0-56" name="__codelineno-0-56"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_available</span> <span class="o">=</span> <span class="n">disk_available</span>
1212
+<a id="__codelineno-0-57" name="__codelineno-0-57"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_total</span> <span class="o">=</span> <span class="n">disk_total</span>
1213
+<a id="__codelineno-0-58" name="__codelineno-0-58"></a> <span class="bp">self</span><span class="o">.</span><span class="n">disk_percent</span> <span class="o">=</span> <span class="n">disk_percent</span>
1214
+</code></pre>
1215
+ </div>
1216
+ </td>
1217
+ </tr>
1218
+ </table>
1219
+ </div>
1220
+ </details>
1221
+ </div>
1222
+ </div>
1223
+
1224
+ <div class="doc doc-object doc-function">
1225
+ <h3
1226
+ id="app.models.wazuh_indexer.WazuhIndexerAllocation.__repr__"
1227
+ class="doc doc-heading"
1228
+ >
1229
+ <code class="highlight language-python"
1230
+ ><span class="fm">__repr__</span
1231
+ ><span class="p">()</span></code
1232
+ >
1233
+ </h3>
1234
+
1235
+ <div class="doc doc-contents">
1236
+ <p>
1237
+ Returns a string representation of the
1238
+ WazuhIndexerAllocation instance.
1239
+ </p>
1240
+ <p>:return: A string representation of the node.</p>
1241
+
1242
+ <details class="quote">
1243
+ <summary>
1244
+ Source code in
1245
+ <code>app\models\wazuh_indexer.py</code>
1246
+ </summary>
1247
+ <div class="highlight">
1248
+ <table class="highlighttable">
1249
+ <tr>
1250
+ <td class="linenos">
1251
+ <div class="linenodiv">
1252
+ <pre><span></span><span class="normal"><a href="#__codelineno-0-60">60</a></span>
1253
+<span class="normal"><a href="#__codelineno-0-61">61</a></span>
1254
+<span class="normal"><a href="#__codelineno-0-62">62</a></span>
1255
+<span class="normal"><a href="#__codelineno-0-63">63</a></span>
1256
+<span class="normal"><a href="#__codelineno-0-64">64</a></span>
1257
+<span class="normal"><a href="#__codelineno-0-65">65</a></span>
1258
+<span class="normal"><a href="#__codelineno-0-66">66</a></span></pre>
1259
+ </div>
1260
+ </td>
1261
+ <td class="code">
1262
+ <div>
1263
+ <pre><span></span><code><a id="__codelineno-0-60" name="__codelineno-0-60"></a><span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span>
1264
+<a id="__codelineno-0-61" name="__codelineno-0-61"></a><span class="w"> </span><span class="sd">"""</span>
1265
+<a id="__codelineno-0-62" name="__codelineno-0-62"></a><span class="sd"> Returns a string representation of the WazuhIndexerAllocation instance.</span>
1266
+<a id="__codelineno-0-63" name="__codelineno-0-63"></a>
1267
+<a id="__codelineno-0-64" name="__codelineno-0-64"></a><span class="sd"> :return: A string representation of the node.</span>
1268
+<a id="__codelineno-0-65" name="__codelineno-0-65"></a><span class="sd"> """</span>
1269
+<a id="__codelineno-0-66" name="__codelineno-0-66"></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<WazuhIndexerAllocation </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">node</span><span class="si">}</span><span class="s2">>"</span>
1270
+</code></pre>
1271
+ </div>
1272
+ </td>
1273
+ </tr>
1274
+ </table>
1275
+ </div>
1276
+ </details>
1277
+ </div>
1278
+ </div>
1279
+ </div>
1280
+ </div>
1281
+ </div>
1282
+
1283
+ <div class="doc doc-object doc-class">
1284
+ <h2
1285
+ id="app.models.wazuh_indexer.WazuhIndexerAllocationSchema"
1286
+ class="doc doc-heading"
1287
+ >
1288
+ <code>WazuhIndexerAllocationSchema</code>
1289
+ </h2>
1290
+
1291
+ <div class="doc doc-contents">
1292
+ <p class="doc doc-class-bases">
1293
+ Bases:
1294
+ <code
1295
+ ><span title="app.ma">ma</span>.<span title="app.ma.Schema"
1296
+ >Schema</span
1297
+ ></code
1298
+ >
1299
+ </p>
1300
+
1301
+ <p>
1302
+ Schema for serializing and deserializing instances of the
1303
+ WazuhIndexerAllocation class.
1304
+ </p>
1305
+
1306
+ <details class="quote">
1307
+ <summary>
1308
+ Source code in <code>app\models\wazuh_indexer.py</code>
1309
+ </summary>
1310
+ <div class="highlight">
1311
+ <table class="highlighttable">
1312
+ <tr>
1313
+ <td class="linenos">
1314
+ <div class="linenodiv">
1315
+ <pre><span></span><span class="normal"><a href="#__codelineno-0-69">69</a></span>
1316
+<span class="normal"><a href="#__codelineno-0-70">70</a></span>
1317
+<span class="normal"><a href="#__codelineno-0-71">71</a></span>
1318
+<span class="normal"><a href="#__codelineno-0-72">72</a></span>
1319
+<span class="normal"><a href="#__codelineno-0-73">73</a></span>
1320
+<span class="normal"><a href="#__codelineno-0-74">74</a></span>
1321
+<span class="normal"><a href="#__codelineno-0-75">75</a></span>
1322
+<span class="normal"><a href="#__codelineno-0-76">76</a></span>
1323
+<span class="normal"><a href="#__codelineno-0-77">77</a></span>
1324
+<span class="normal"><a href="#__codelineno-0-78">78</a></span>
1325
+<span class="normal"><a href="#__codelineno-0-79">79</a></span>
1326
+<span class="normal"><a href="#__codelineno-0-80">80</a></span>
1327
+<span class="normal"><a href="#__codelineno-0-81">81</a></span>
1328
+<span class="normal"><a href="#__codelineno-0-82">82</a></span>
1329
+<span class="normal"><a href="#__codelineno-0-83">83</a></span>
1330
+<span class="normal"><a href="#__codelineno-0-84">84</a></span>
1331
+<span class="normal"><a href="#__codelineno-0-85">85</a></span>
1332
+<span class="normal"><a href="#__codelineno-0-86">86</a></span>
1333
+<span class="normal"><a href="#__codelineno-0-87">87</a></span></pre>
1334
+ </div>
1335
+ </td>
1336
+ <td class="code">
1337
+ <div>
1338
+ <pre><span></span><code><a id="__codelineno-0-69" name="__codelineno-0-69"></a><span class="k">class</span> <span class="nc">WazuhIndexerAllocationSchema</span><span class="p">(</span><span class="n">ma</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span>
1339
+<a id="__codelineno-0-70" name="__codelineno-0-70"></a><span class="w"> </span><span class="sd">"""</span>
1340
+<a id="__codelineno-0-71" name="__codelineno-0-71"></a><span class="sd"> Schema for serializing and deserializing instances of the WazuhIndexerAllocation class.</span>
1341
+<a id="__codelineno-0-72" name="__codelineno-0-72"></a><span class="sd"> """</span>
1342
+<a id="__codelineno-0-73" name="__codelineno-0-73"></a>
1343
+<a id="__codelineno-0-74" name="__codelineno-0-74"></a> <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
1344
+<a id="__codelineno-0-75" name="__codelineno-0-75"></a><span class="w"> </span><span class="sd">"""</span>
1345
+<a id="__codelineno-0-76" name="__codelineno-0-76"></a><span class="sd"> Meta class defines the fields to be serialized/deserialized.</span>
1346
+<a id="__codelineno-0-77" name="__codelineno-0-77"></a><span class="sd"> """</span>
1347
+<a id="__codelineno-0-78" name="__codelineno-0-78"></a>
1348
+<a id="__codelineno-0-79" name="__codelineno-0-79"></a> <span class="n">fields</span><span class="p">:</span> <span class="nb">tuple</span> <span class="o">=</span> <span class="p">(</span>
1349
+<a id="__codelineno-0-80" name="__codelineno-0-80"></a> <span class="s2">"id"</span><span class="p">,</span>
1350
+<a id="__codelineno-0-81" name="__codelineno-0-81"></a> <span class="s2">"node"</span><span class="p">,</span>
1351
+<a id="__codelineno-0-82" name="__codelineno-0-82"></a> <span class="s2">"disk_used"</span><span class="p">,</span>
1352
+<a id="__codelineno-0-83" name="__codelineno-0-83"></a> <span class="s2">"disk_available"</span><span class="p">,</span>
1353
+<a id="__codelineno-0-84" name="__codelineno-0-84"></a> <span class="s2">"disk_total"</span><span class="p">,</span>
1354
+<a id="__codelineno-0-85" name="__codelineno-0-85"></a> <span class="s2">"disk_percent"</span><span class="p">,</span>
1355
+<a id="__codelineno-0-86" name="__codelineno-0-86"></a> <span class="s2">"timestamp"</span><span class="p">,</span>
1356
+<a id="__codelineno-0-87" name="__codelineno-0-87"></a> <span class="p">)</span>
1357
+</code></pre>
1358
+ </div>
1359
+ </td>
1360
+ </tr>
1361
+ </table>
1362
+ </div>
1363
+ </details>
1364
+
1365
+ <div class="doc doc-children">
1366
+ <div class="doc doc-object doc-class">
1367
+ <h3
1368
+ id="app.models.wazuh_indexer.WazuhIndexerAllocationSchema.Meta"
1369
+ class="doc doc-heading"
1370
+ >
1371
+ <code>Meta</code>
1372
+ </h3>
1373
+
1374
+ <div class="doc doc-contents">
1375
+ <p>
1376
+ Meta class defines the fields to be
1377
+ serialized/deserialized.
1378
+ </p>
1379
+
1380
+ <details class="quote">
1381
+ <summary>
1382
+ Source code in
1383
+ <code>app\models\wazuh_indexer.py</code>
1384
+ </summary>
1385
+ <div class="highlight">
1386
+ <table class="highlighttable">
1387
+ <tr>
1388
+ <td class="linenos">
1389
+ <div class="linenodiv">
1390
+ <pre><span></span><span class="normal"><a href="#__codelineno-0-74">74</a></span>
1391
+<span class="normal"><a href="#__codelineno-0-75">75</a></span>
1392
+<span class="normal"><a href="#__codelineno-0-76">76</a></span>
1393
+<span class="normal"><a href="#__codelineno-0-77">77</a></span>
1394
+<span class="normal"><a href="#__codelineno-0-78">78</a></span>
1395
+<span class="normal"><a href="#__codelineno-0-79">79</a></span>
1396
+<span class="normal"><a href="#__codelineno-0-80">80</a></span>
1397
+<span class="normal"><a href="#__codelineno-0-81">81</a></span>
1398
+<span class="normal"><a href="#__codelineno-0-82">82</a></span>
1399
+<span class="normal"><a href="#__codelineno-0-83">83</a></span>
1400
+<span class="normal"><a href="#__codelineno-0-84">84</a></span>
1401
+<span class="normal"><a href="#__codelineno-0-85">85</a></span>
1402
+<span class="normal"><a href="#__codelineno-0-86">86</a></span>
1403
+<span class="normal"><a href="#__codelineno-0-87">87</a></span></pre>
1404
+ </div>
1405
+ </td>
1406
+ <td class="code">
1407
+ <div>
1408
+ <pre><span></span><code><a id="__codelineno-0-74" name="__codelineno-0-74"></a><span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
1409
+<a id="__codelineno-0-75" name="__codelineno-0-75"></a><span class="w"> </span><span class="sd">"""</span>
1410
+<a id="__codelineno-0-76" name="__codelineno-0-76"></a><span class="sd"> Meta class defines the fields to be serialized/deserialized.</span>
1411
+<a id="__codelineno-0-77" name="__codelineno-0-77"></a><span class="sd"> """</span>
1412
+<a id="__codelineno-0-78" name="__codelineno-0-78"></a>
1413
+<a id="__codelineno-0-79" name="__codelineno-0-79"></a> <span class="n">fields</span><span class="p">:</span> <span class="nb">tuple</span> <span class="o">=</span> <span class="p">(</span>
1414
+<a id="__codelineno-0-80" name="__codelineno-0-80"></a> <span class="s2">"id"</span><span class="p">,</span>
1415
+<a id="__codelineno-0-81" name="__codelineno-0-81"></a> <span class="s2">"node"</span><span class="p">,</span>
1416
+<a id="__codelineno-0-82" name="__codelineno-0-82"></a> <span class="s2">"disk_used"</span><span class="p">,</span>
1417
+<a id="__codelineno-0-83" name="__codelineno-0-83"></a> <span class="s2">"disk_available"</span><span class="p">,</span>
1418
+<a id="__codelineno-0-84" name="__codelineno-0-84"></a> <span class="s2">"disk_total"</span><span class="p">,</span>
1419
+<a id="__codelineno-0-85" name="__codelineno-0-85"></a> <span class="s2">"disk_percent"</span><span class="p">,</span>
1420
+<a id="__codelineno-0-86" name="__codelineno-0-86"></a> <span class="s2">"timestamp"</span><span class="p">,</span>
1421
+<a id="__codelineno-0-87" name="__codelineno-0-87"></a> <span class="p">)</span>
1422
+</code></pre>
1423
+ </div>
1424
+ </td>
1425
+ </tr>
1426
+ </table>
1427
+ </div>
1428
+ </details>
1429
+
1430
+ <div class="doc doc-children"></div>
1431
+ </div>
1432
+ </div>
1433
+ </div>
1434
+ </div>
1435
+ </div>
1436
+ </div>
1437
+ </div>
1438
+ </div>
1439
+ <p><br /></p>
1440
<h3 id="alert-routes"><span style="color: green">Alert Routes</span></h3>
1441
+ <h1 id="alertspy">alerts.py</h1>
1442
+ <p>
1443
+ This file is part of a Flask application and is responsible for defining an API endpoint
1444
+ related to alerts. The alerts are retrieved using the <code>AlertsService</code> and are
1445
+ returned in a JSON format.
1446
+ </p>
1447
+ <h2 id="dependencies">Dependencies</h2>
1448
+ <p>The file imports the following modules:</p>
1449
+ <ul>
1450
+ <li>
1451
+ <code>Blueprint</code> and <code>jsonify</code> from the <code>flask</code> module.
1452
+ </li>
1453
+ <li>
1454
+ <code>AlertsService</code> from the
1455
+ <code>app.services.WazuhIndexer.alerts</code> module.
1456
+ </li>
1457
+ </ul>
1458
+ <h2 id="blueprint">Blueprint</h2>
1459
+ <p>
1460
+ A Blueprint, <code>bp</code>, is created with the name "alerts". This Blueprint is used
1461
+ to register the routes and their corresponding view functions to the Flask application.
1462
+ </p>
1463
+ <h2 id="route-alerts">Route: "/alerts"</h2>
1464
+ <p>
1465
+ This route is associated with the <code>get_alerts()</code> view function. The route
1466
+ listens for HTTP GET requests. When a GET request is made to the "/alerts" URL, the
1467
+ <code>get_alerts()</code> function is invoked.
1468
+ </p>
1469
+ <h2 id="view-function-get_alerts">View Function: get_alerts()</h2>
1470
+ <p>
1471
+ The <code>get_alerts()</code> function retrieves all alerts from the
1472
+ <code>AlertsService</code>.
1473
+ </p>
1474
+ <p>The process is as follows:</p>
1475
+ <ol>
1476
+ <li>An instance of the <code>AlertsService</code> class is created.</li>
1477
+ <li>
1478
+ The <code>collect_alerts()</code> method of the <code>AlertsService</code> instance
1479
+ is called to fetch all alerts.
1480
+ </li>
1481
+ <li>The fetched alerts are returned as a JSON response.</li>
1482
+ </ol>
1483
+ <p>
1484
+ The function is documented with a docstring that provides a brief description of its
1485
+ purpose, the process it follows to retrieve alerts, and the data it returns.
1486
+ </p>
1487
1488
<div class="doc doc-object doc-module">
1489
<a id="app.routes.alerts"></a>
@@ -679,6 +1601,59 @@
1601
</div>
1602
<p><br /></p>
1603
<h3 id="wazuh-indexer-routes"><span style="color: green">Wazuh-Indexer Routes</span></h3>
1604
+ <h1 id="wazuhindexerpy">wazuhindexer.py</h1>
1605
+ <p>
1606
+ The <code>wazuhindexer.py</code> file is a Flask Blueprint file that sets up HTTP
1607
+ endpoints for interacting with the Wazuh-Indexer. Wazuh-Indexer is a security detection
1608
+ and response tool that indexes and correlates security data. The endpoints provide
1609
+ information about the indices, allocation of indices, cluster health, and shards in the
1610
+ Wazuh-Indexer.
1611
+ </p>
1612
+ <p>The following endpoints are defined:</p>
1613
+ <h2 id="get-wazuh_indexerindices">GET /wazuh_indexer/indices</h2>
1614
+ <p>
1615
+ This endpoint lists all available indices and collects relevant information for each,
1616
+ including:
1617
+ </p>
1618
+ <ul>
1619
+ <li>Index name</li>
1620
+ <li>Index health status</li>
1621
+ <li>Document count in the index</li>
1622
+ <li>Size of the index</li>
1623
+ <li>Number of replicas for the index</li>
1624
+ </ul>
1625
+ <p>
1626
+ The returned JSON object contains a list of all available indices along with their
1627
+ respective details.
1628
+ </p>
1629
+ <h2 id="get-wazuh_indexerallocation">GET /wazuh_indexer/allocation</h2>
1630
+ <p>This endpoint lists all available indices allocation, including:</p>
1631
+ <ul>
1632
+ <li>Disk space used by the index</li>
1633
+ <li>Available disk space</li>
1634
+ <li>Total disk space</li>
1635
+ <li>Disk usage percentage</li>
1636
+ <li>Node on which the index resides</li>
1637
+ </ul>
1638
+ <p>
1639
+ The returned JSON object contains a list of all available indices along with their
1640
+ respective allocation details.
1641
+ </p>
1642
+ <h2 id="get-wazuh_indexerhealth">GET /wazuh_indexer/health</h2>
1643
+ <p>
1644
+ This endpoint collects Wazuh-Indexer cluster health information. The returned JSON
1645
+ object contains health information for the Wazuh-Indexer cluster.
1646
+ </p>
1647
+ <h2 id="get-wazuh_indexershards">GET /wazuh_indexer/shards</h2>
1648
+ <p>
1649
+ This endpoint collects information about Wazuh-Indexer shards. The returned JSON object
1650
+ contains information about the shards in the Wazuh-Indexer.
1651
+ </p>
1652
+ <p>
1653
+ The file uses services defined in <code>ClusterService</code> and
1654
+ <code>IndexService</code> to interact with the Wazuh-Indexer and collect the required
1655
+ information.
1656
+ </p>
1657
1658
<div class="doc doc-object doc-module">
1659
<a id="app.routes.wazuhindexer"></a>
@@ -1064,6 +2039,69 @@
2039
</div>
2040
<p><br /></p>
2041
<h3 id="alert-services"><span style="color: red">Alert Services</span></h3>
2042
+ <h1 id="alertspy_1">alerts.py</h1>
2043
+ <p>
2044
+ This Python module contains the <code>AlertsService</code> class, which is responsible
2045
+ for handling alert data from the Wazuh-Indexer.
2046
+ </p>
2047
+ <h2 id="alertsservice-class"><code>AlertsService</code> Class</h2>
2048
+ <p>
2049
+ The <code>AlertsService</code> class is a service class that handles the logic of
2050
+ pulling alerts from the Wazuh-Indexer. It manages the connection details to the
2051
+ Wazuh-Indexer and provides methods to collect alerts.
2052
+ </p>
2053
+ <h3 id="attributes">Attributes</h3>
2054
+ <ul>
2055
+ <li><code>connector_url</code>: The URL of the Wazuh-Indexer.</li>
2056
+ <li>
2057
+ <code>connector_username</code>: The username to authenticate with the
2058
+ Wazuh-Indexer.
2059
+ </li>
2060
+ <li>
2061
+ <code>connector_password</code>: The password to authenticate with the
2062
+ Wazuh-Indexer.
2063
+ </li>
2064
+ </ul>
2065
+ <p>
2066
+ The class uses the <code>UniversalService</code> class to collect connection details for
2067
+ the Wazuh-Indexer.
2068
+ </p>
2069
+ <h3 id="methods">Methods</h3>
2070
+ <p>
2071
+ The <code>AlertsService</code> class defines various methods for interacting with the
2072
+ Wazuh-Indexer. These methods include:
2073
+ </p>
2074
+ <ul>
2075
+ <li>
2076
+ <code>__init__</code>: Initializes the <code>AlertsService</code> instance and
2077
+ collects Wazuh-Indexer details.
2078
+ </li>
2079
+ <li><code>_collect_alerts</code>: Collects alerts from the Wazuh-Indexer.</li>
2080
+ <li>
2081
+ <code>_collect_alerts_details</code>: Collects detailed information about alerts
2082
+ from the Wazuh-Indexer.
2083
+ </li>
2084
+ <li>
2085
+ <code>_handle_request_error</code>: Handles errors during HTTP requests to the
2086
+ Wazuh-Indexer.
2087
+ </li>
2088
+ <li>
2089
+ <code>collect_alerts</code>: Provides a public interface for collecting alerts from
2090
+ the Wazuh-Indexer.
2091
+ </li>
2092
+ </ul>
2093
+ <h3 id="dependencies_1">Dependencies</h3>
2094
+ <p>The <code>alerts.py</code> file imports the following libraries and modules:</p>
2095
+ <ul>
2096
+ <li><code>typing</code>: For supporting type hints.</li>
2097
+ <li><code>elasticsearch7</code>: The Python client for Elasticsearch 7.</li>
2098
+ <li><code>loguru</code>: A simple and powerful logging utility.</li>
2099
+ <li>
2100
+ <code>app.services.WazuhIndexer.universal</code>: The
2101
+ <code>UniversalService</code> class from the <code>universal</code> module in the
2102
+ <code>WazuhIndexer</code> package under <code>app.services</code>.
2103
+ </li>
2104
+ </ul>
2105
2106
<div class="doc doc-object doc-module">
2107
<a id="app.services.WazuhIndexer.alerts"></a>
@@ -1798,6 +2836,82 @@
2836
</div>
2837
</div>
2838
<h3 id="cluster-services"><span style="color: red">Cluster Services</span></h3>
2839
+ <h1 id="clusterpy">cluster.py</h1>
2840
+ <p>
2841
+ This Python script defines the <code>ClusterService</code> class which provides methods
2842
+ for interacting with a Wazuh-Indexer's Elasticsearch cluster. The class includes methods
2843
+ for collecting details about the Wazuh-Indexer, initializing an Elasticsearch client,
2844
+ and fetching various pieces of information about the state of the cluster.
2845
+ </p>
2846
+ <h2 id="class-clusterservice">Class: ClusterService</h2>
2847
+ <h3 id="initialization">Initialization</h3>
2848
+ <p>
2849
+ The <code>ClusterService</code> class is initialized by calling the
2850
+ <code>_collect_wazuhindexer_details()</code> method to collect details about the
2851
+ Wazuh-Indexer and then initializing the Elasticsearch client with these details.
2852
+ </p>
2853
+ <h3 id="methods_1">Methods</h3>
2854
+ <p>The class includes the following methods:</p>
2855
+ <ul>
2856
+ <li>
2857
+ <code>_collect_wazuhindexer_details()</code>: Collects the details (URL, username,
2858
+ password) of the Wazuh-Indexer.
2859
+ </li>
2860
+ <li>
2861
+ <code>_initialize_es_client()</code>: Initializes the Elasticsearch client with the
2862
+ collected Wazuh-Indexer details.
2863
+ </li>
2864
+ <li>
2865
+ <code>_are_details_collected()</code>: Checks if all the required details for the
2866
+ Wazuh-Indexer have been collected.
2867
+ </li>
2868
+ <li>
2869
+ <code>collect_node_allocation()</code>: Fetches the node allocation details from the
2870
+ Elasticsearch cluster. It returns a dictionary containing the success status, a
2871
+ message, and potentially the node allocation details.
2872
+ </li>
2873
+ <li>
2874
+ <code>_collect_node_allocation()</code>: Handles the actual request to Elasticsearch
2875
+ to fetch the node allocation details. It returns a dictionary containing the success
2876
+ status, a message, and potentially the node allocation details.
2877
+ </li>
2878
+ <li>
2879
+ <code>_format_node_allocation()</code>: Formats the node allocation details into a
2880
+ list of dictionaries. Each dictionary contains disk used, disk available, total
2881
+ disk, disk usage percentage, and node name.
2882
+ </li>
2883
+ <li>
2884
+ <code>collect_cluster_health()</code>: Fetches the cluster health details from
2885
+ Elasticsearch. It returns a dictionary containing the success status, a message, and
2886
+ potentially the cluster health details.
2887
+ </li>
2888
+ <li>
2889
+ <code>_collect_cluster_health()</code>: Handles the actual request to Elasticsearch
2890
+ to fetch the cluster health details. It returns a dictionary containing the success
2891
+ status, a message, and potentially the cluster health details.
2892
+ </li>
2893
+ <li>
2894
+ <code>collect_shards()</code>: Fetches the shard details from the Elasticsearch
2895
+ cluster. It returns a dictionary containing the success status, a message, and
2896
+ potentially the shard details.
2897
+ </li>
2898
+ <li>
2899
+ <code>_collect_shards()</code>: Handles the actual request to Elasticsearch to fetch
2900
+ the shard details. It returns a dictionary containing the success status, a message,
2901
+ and potentially the shard details.
2902
+ </li>
2903
+ <li>
2904
+ <code>_format_shards()</code>: Formats the shard details into a list of
2905
+ dictionaries. Each dictionary contains index name, shard number, shard state, shard
2906
+ size, and node name.
2907
+ </li>
2908
+ </ul>
2909
+ <p>
2910
+ In general, the <code>ClusterService</code> class provides an interface to query various
2911
+ details about the state of a Wazuh-Indexer's Elasticsearch cluster. It includes methods
2912
+ for collecting details about the cluster's health, node allocation, and shard
2913
+ distribution.
2914
+ </p>
2915
2916
<div class="doc doc-object doc-module">
2917
<a id="app.services.WazuhIndexer.cluster"></a>
@@ -2670,6 +3784,59 @@
3784
</div>
3785
</div>
3786
<h3 id="index-services"><span style="color: red">Index Services</span></h3>
3787
+ <h1 id="indexpy">index.py</h1>
3788
+ <p>
3789
+ The file <code>index.py</code> is a Python module that primarily contains the
3790
+ <code>IndexService</code> class. This class encapsulates the logic for interacting with
3791
+ a Wazuh-Indexer's Elasticsearch cluster to collect information about the indices in the
3792
+ cluster.
3793
+ </p>
3794
+ <p>Here is a detailed breakdown of the module:</p>
3795
+ <h2 id="indexservice-class">IndexService class</h2>
3796
+ <p>
3797
+ This class is designed to interact with an Elasticsearch cluster, specifically a
3798
+ Wazuh-Indexer.
3799
+ </p>
3800
+ <h3 id="initialization_1">Initialization</h3>
3801
+ <p>
3802
+ During the initialization of an <code>IndexService</code> object, the details of the
3803
+ Wazuh-Indexer are collected, and the Elasticsearch client is initialized.
3804
+ </p>
3805
+ <h3 id="methods_2">Methods</h3>
3806
+ <p>The class provides the following methods:</p>
3807
+ <ul>
3808
+ <li>
3809
+ <code>_collect_wazuhindexer_details</code>: This private method collects the details
3810
+ of the Wazuh-Indexer, which include the connector URL, username, and password.
3811
+ </li>
3812
+ <li>
3813
+ <code>_initialize_es_client</code>: This private method initializes the
3814
+ Elasticsearch client with the details of the Wazuh-Indexer.
3815
+ </li>
3816
+ <li>
3817
+ <code>_are_details_collected</code>: This private method checks whether the details
3818
+ of the Wazuh-Indexer have been collected.
3819
+ </li>
3820
+ <li>
3821
+ <code>collect_indices_summary</code>: This method collects summary information for
3822
+ each index from the Wazuh-Indexer's Elasticsearch cluster.
3823
+ </li>
3824
+ <li>
3825
+ <code>_format_indices_summary</code>: This private method formats the indices
3826
+ summary into a list of dictionaries. Each dictionary contains the index name, health
3827
+ status, document count, store size, and replica count.
3828
+ </li>
3829
+ <li>
3830
+ <code>_collect_indices</code>: This private method collects indices from the
3831
+ Wazuh-Indexer's Elasticsearch cluster. It returns a dictionary containing success
3832
+ status, a message, and potentially the indices.
3833
+ </li>
3834
+ </ul>
3835
+ <p>
3836
+ Overall, this module is used to facilitate the interaction between the application and a
3837
+ Wazuh-Indexer's Elasticsearch cluster, allowing the application to collect and format
3838
+ summary information about the indices in the cluster.
3839
+ </p>
3840
3841
<div class="doc doc-object doc-module">
3842
<a id="app.services.WazuhIndexer.index"></a>