Loading src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py +13 −6 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ from common.proto.kpi_sample_types_pb2 import KpiSampleType # from monitoring.client.MonitoringClient import MonitoringClient from monitoring.client.MonitoringClient import MonitoringClient from common.proto.monitoring_pb2 import Kpi from common.tools.timestamp.Converters import timestamp_utcnow_to_float from common.proto.context_pb2 import Timestamp LOGGER = logging.getLogger(__name__) here = os.path.dirname(os.path.abspath(__file__)) Loading Loading @@ -70,7 +72,7 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto # create kpi kpi_description: KpiDescriptor = KpiDescriptor() kpi_description.kpi_description = "L3 security status of service {}".format(service_id) kpi_description.service_id.service_uuid.uuid = service_id kpi_description.service_id.service_uuid.uuid = str(service_id) kpi_description.kpi_sample_type = KpiSampleType.KPISAMPLETYPE_UNKNOWN new_kpi = client.SetKpi(kpi_description) Loading Loading @@ -152,14 +154,19 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto # Counter 2: Rate of crypto attack connections with respect to the total number of connections kpi_class = Kpi() kpi_class.kpi_id.kpi_id.uuid = self.predicted_class_kpi_id.uuid kpi_class.kpi_value.int32Val = 1 if request.tag_name == "Crypto" else 0 kpi_class.kpi_id.kpi_id.uuid = str(self.predicted_class_kpi_id) kpi_class.kpi_value.int32Val = 1 if output.tag_name == "Crypto" else 0 kpi_prob = Kpi() kpi_prob.kpi_id.kpi_id.uuid = self.class_probability_kpi_id.uuid kpi_prob.kpi_value.floatVal = request.confidence kpi_prob.kpi_id.kpi_id.uuid = str(self.class_probability_kpi_id) kpi_prob.kpi_value.floatVal = output.confidence # timestamp = timestamp_utcnow_to_float() timestamp = Timestamp() timestamp.timestamp = timestamp_utcnow_to_float() kpi_class.timestamp = kpi_prob.timestamp = timestamp_utcnow_to_float() kpi_class.timestamp.CopyFrom(timestamp) kpi_prob.timestamp.CopyFrom(kpi_class.timestamp) self.monitoring_client.IncludeKpi(kpi_class) self.monitoring_client.IncludeKpi(kpi_prob) Loading Loading
src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py +13 −6 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ from common.proto.kpi_sample_types_pb2 import KpiSampleType # from monitoring.client.MonitoringClient import MonitoringClient from monitoring.client.MonitoringClient import MonitoringClient from common.proto.monitoring_pb2 import Kpi from common.tools.timestamp.Converters import timestamp_utcnow_to_float from common.proto.context_pb2 import Timestamp LOGGER = logging.getLogger(__name__) here = os.path.dirname(os.path.abspath(__file__)) Loading Loading @@ -70,7 +72,7 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto # create kpi kpi_description: KpiDescriptor = KpiDescriptor() kpi_description.kpi_description = "L3 security status of service {}".format(service_id) kpi_description.service_id.service_uuid.uuid = service_id kpi_description.service_id.service_uuid.uuid = str(service_id) kpi_description.kpi_sample_type = KpiSampleType.KPISAMPLETYPE_UNKNOWN new_kpi = client.SetKpi(kpi_description) Loading Loading @@ -152,14 +154,19 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto # Counter 2: Rate of crypto attack connections with respect to the total number of connections kpi_class = Kpi() kpi_class.kpi_id.kpi_id.uuid = self.predicted_class_kpi_id.uuid kpi_class.kpi_value.int32Val = 1 if request.tag_name == "Crypto" else 0 kpi_class.kpi_id.kpi_id.uuid = str(self.predicted_class_kpi_id) kpi_class.kpi_value.int32Val = 1 if output.tag_name == "Crypto" else 0 kpi_prob = Kpi() kpi_prob.kpi_id.kpi_id.uuid = self.class_probability_kpi_id.uuid kpi_prob.kpi_value.floatVal = request.confidence kpi_prob.kpi_id.kpi_id.uuid = str(self.class_probability_kpi_id) kpi_prob.kpi_value.floatVal = output.confidence # timestamp = timestamp_utcnow_to_float() timestamp = Timestamp() timestamp.timestamp = timestamp_utcnow_to_float() kpi_class.timestamp = kpi_prob.timestamp = timestamp_utcnow_to_float() kpi_class.timestamp.CopyFrom(timestamp) kpi_prob.timestamp.CopyFrom(kpi_class.timestamp) self.monitoring_client.IncludeKpi(kpi_class) self.monitoring_client.IncludeKpi(kpi_prob) Loading