@cryptotaxi247 / CoPilot / commits / 9e90e1a1

Create wazuhindexer.py

taylor_socfortress committed Jul 10, 2023 at 16:41 UTC 9e90e1a1fbbc7835c6bce51309ae3a3094c6b3b3
1 file changed +75
backend/app/routes/wazuhindexer.py new
+75
@@ -0,0 +1,75 @@
1 +from flask import Blueprint, jsonify, request
2 +from loguru import logger
3 +from app.models.connectors import Connector, WazuhManagerConnector
4 +
5 +from app.services.agents.agents import AgentService, AgentSyncService
6 +from app.services.WazuhIndexer.alerts import AlertsService
7 +from app.services.WazuhIndexer.index import IndexService
8 +from app.services.WazuhIndexer.cluster import ClusterService
9 +
10 +bp = Blueprint("wazuh_indexer", __name__)
11 +
12 +
13 +@bp.route("/wazuh_indexer/indices", methods=["GET"])
14 +def get_indices_summary():
15 + """
16 + Endpoint to list all available indices and collect.
17 + {
18 + "index": index["index"],
19 + "health": index["health"],
20 + "docs_count": index["docs.count"],
21 + "store_size": index["store.size"],
22 + "replica_count": index["rep"],
23 + },
24 + It processes each alert to verify the connection and returns the results.
25 +
26 + Returns:
27 + json: A JSON response containing the list of all available indices along with their connection verification status.
28 + """
29 + service = IndexService()
30 + indices = service.collect_indices_summary()
31 + return indices
32 +
33 +@bp.route("/wazuh_indexer/allocation", methods=["GET"])
34 +def get_node_allocation():
35 + """
36 + Endpoint to list all available indices allocation.
37 + Returns:
38 + {
39 + "disk_used": index["disk.used"],
40 + "disk_available": index["disk.avail"],
41 + "disk_total": index["disk.total"],
42 + "disk_percent": index["disk.percent"],
43 + "node": index["node"],
44 + },
45 +
46 + Returns:
47 + json: A JSON response containing the list of all available alerts along with their connection verification status.
48 + """
49 + service = ClusterService()
50 + indices = service.collect_node_allocation()
51 + return indices
52 +
53 +@bp.route("/wazuh_indexer/health", methods=["GET"])
54 +def get_cluster_health():
55 + """
56 + Endpoint to collect Wazuh-Indexer cluster health.
57 +
58 + Returns:
59 + json: A JSON response containing the list of all available alerts along with their connection verification status.
60 + """
61 + service = ClusterService()
62 + indices = service.collect_cluster_health()
63 + return indices
64 +
65 +@bp.route("/wazuh_indexer/shards", methods=["GET"])
66 +def get_shards():
67 + """
68 + Endpoint to collect Wazuh-Indexer shards.
69 +
70 + Returns:
71 + json: A JSON response containing the list of all available alerts along with their connection verification status.
72 + """
73 + service = ClusterService()
74 + indices = service.collect_shards()
75 + return indices