44
55
66class OpenCTIMetricHandler :
7- def __init__ (self , connector_logger , activated : bool = False , port : int = 9095 ):
7+ def __init__ (
8+ self ,
9+ connector_logger ,
10+ activated : bool = False ,
11+ namespace : str = "" ,
12+ subsystem : str = "" ,
13+ port : int = 9095 ,
14+ ):
815 """
916 Init of OpenCTIMetricHandler class.
1017
1118 Parameters
1219 ----------
1320 activated : bool, default False
1421 If True use metrics in client and connectors.
22+ namespace: str, default empty
23+ Namespace for the prometheus metrics.
24+ subsystem: str, default empty
25+ Subsystem for the prometheus metrics.
1526 port : int, default 9095
1627 Port for prometheus server.
1728 """
@@ -22,35 +33,53 @@ def __init__(self, connector_logger, activated: bool = False, port: int = 9095):
2233 start_http_server (port )
2334 self ._metrics = {
2435 "bundle_send" : Counter (
25- "bundle_send" ,
26- "Number of bundle send" ,
36+ "bundles_sent_total" ,
37+ "Number of bundles sent" ,
38+ namespace = namespace ,
39+ subsystem = subsystem ,
2740 ),
2841 "record_send" : Counter (
29- "record_send" ,
30- "Number of record (objects per bundle) send" ,
42+ "records_sent_total" ,
43+ "Number of records (objects per bundle) sent" ,
44+ namespace = namespace ,
45+ subsystem = subsystem ,
3146 ),
3247 "run_count" : Counter (
33- "run_count " ,
48+ "runs_total " ,
3449 "Number of run" ,
50+ namespace = namespace ,
51+ subsystem = subsystem ,
3552 ),
3653 "ping_api_count" : Counter (
37- "ping_api_count" ,
38- "Number of ping to the api" ,
54+ "ping_api_total" ,
55+ "Number of pings to the API" ,
56+ namespace = namespace ,
57+ subsystem = subsystem ,
3958 ),
4059 "ping_api_error" : Counter (
41- "ping_api_error" ,
42- "Number of error when pinging the api" ,
60+ "ping_api_errors_total" ,
61+ "Number of errors when pinging the API" ,
62+ namespace = namespace ,
63+ subsystem = subsystem ,
4364 ),
4465 "error_count" : Counter (
45- "error_count" ,
46- "Number of error" ,
66+ "errors_total" ,
67+ "Number of errors" ,
68+ namespace = namespace ,
69+ subsystem = subsystem ,
4770 ),
4871 "client_error_count" : Counter (
49- "client_error_count" ,
50- "Number of client error" ,
72+ "client_errors_total" ,
73+ "Number of client errors" ,
74+ namespace = namespace ,
75+ subsystem = subsystem ,
5176 ),
5277 "state" : Enum (
53- "state" , "State of connector" , states = ["idle" , "running" , "stopped" ]
78+ "state" ,
79+ "State of connector" ,
80+ states = ["idle" , "running" , "stopped" ],
81+ namespace = namespace ,
82+ subsystem = subsystem ,
5483 ),
5584 }
5685
0 commit comments