Commit 35b9ecad authored by Luis de la Cal's avatar Luis de la Cal
Browse files

- Added endpoint_id field to the monitoring of KPIs in the Centralized Attack Detector.

- Minor fixes.
parent c2ce42d0
Loading
Loading
Loading
Loading
+76 −76
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ spec:
              protocol: TCP
          env:
            - name: LOG_LEVEL
          value: "INFO"
              value: "DEBUG"
            - name: METRICSDB_HOSTNAME
              value: "monitoringservice"
            - name: METRICSDB_ILP_PORT
+11 −3
Original line number Diff line number Diff line
@@ -123,10 +123,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
        -output: KPI identifier representing the KPI
    """

    def create_kpi(self, client: MonitoringClient, service_id, kpi_name, kpi_description, kpi_sample_type):
    def create_kpi(
        self, client: MonitoringClient, service_id, device_id, endpoint_id, kpi_name, kpi_description, kpi_sample_type
    ):
        kpidescriptor = KpiDescriptor()
        kpidescriptor.kpi_description = kpi_description
        kpidescriptor.service_id.service_uuid.uuid = service_id.service_uuid.uuid
        kpidescriptor.device_id.device_uuid.uuid = device_id.device_uuid.uuid
        kpidescriptor.endpoint_id.endpoint_uuid.uuid = endpoint_id.endpoint_uuid.uuid
        kpidescriptor.kpi_sample_type = kpi_sample_type
        new_kpi = client.SetKpi(kpidescriptor)

@@ -141,12 +145,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
        -output: None
    """

    def create_kpis(self, service_id):
    def create_kpis(self, service_id, device_id, endpoint_id):
        # for now, all the KPIs are created for all the services from which requests are received
        for kpi in self.monitored_kpis:
            created_kpi = self.create_kpi(
                self.monitoring_client,
                service_id,
                device_id,
                endpoint_id,
                kpi,
                self.monitored_kpis[kpi]["description"],
                self.monitored_kpis[kpi]["kpi_sample_type"],
@@ -428,10 +434,12 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
        self.inference_results.put({"output": cryptomining_detector_output_serialized, "timestamp": datetime.now()})

        service_id = request.service_id
        device_id = request.endpoint_id.device_id
        endpoint_id = request.endpoint_id

        # Check if a request of a new service has been received and, if so, create the monitored KPIs for that service
        if service_id not in self.service_ids:
            self.create_kpis(service_id)
            self.create_kpis(service_id, device_id, endpoint_id)
            self.service_ids.append(service_id)

        # Only notify Attack Mitigator when a cryptomining connection has been detected