Skip to content
Snippets Groups Projects
Commit 35b9ecad authored by delacal's avatar delacal
Browse files

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

- Minor fixes.
parent c2ce42d0
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!93Updated L3 components + scalability
...@@ -30,23 +30,23 @@ spec: ...@@ -30,23 +30,23 @@ spec:
terminationGracePeriodSeconds: 5 terminationGracePeriodSeconds: 5
restartPolicy: Always restartPolicy: Always
containers: containers:
- name: metricsdb - name: metricsdb
image: questdb/questdb image: questdb/questdb
ports: ports:
- name: http - name: http
containerPort: 9000 containerPort: 9000
protocol: TCP protocol: TCP
- name: influxdb - name: influxdb
containerPort: 9009 containerPort: 9009
protocol: TCP protocol: TCP
- name: postgre - name: postgre
containerPort: 8812 containerPort: 8812
protocol: TCP protocol: TCP
env: env:
- name: QDB_CAIRO_COMMIT_LAG - name: QDB_CAIRO_COMMIT_LAG
value: "1000" value: "1000"
- name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS
value: "100000" value: "100000"
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
...@@ -65,37 +65,37 @@ spec: ...@@ -65,37 +65,37 @@ spec:
terminationGracePeriodSeconds: 5 terminationGracePeriodSeconds: 5
restartPolicy: Always restartPolicy: Always
containers: containers:
- name: server - name: server
image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- name: grpc - name: grpc
containerPort: 7070 containerPort: 7070
protocol: TCP protocol: TCP
env: env:
- name: LOG_LEVEL - name: LOG_LEVEL
value: "INFO" value: "DEBUG"
- name: METRICSDB_HOSTNAME - name: METRICSDB_HOSTNAME
value: "monitoringservice" value: "monitoringservice"
- name: METRICSDB_ILP_PORT - name: METRICSDB_ILP_PORT
value: "9009" value: "9009"
- name: METRICSDB_REST_PORT - name: METRICSDB_REST_PORT
value: "9000" value: "9000"
- name: METRICSDB_TABLE - name: METRICSDB_TABLE
value: "monitoring" value: "monitoring"
readinessProbe: readinessProbe:
exec: exec:
command: ["/bin/grpc_health_probe", "-addr=:7070"] command: ["/bin/grpc_health_probe", "-addr=:7070"]
livenessProbe: livenessProbe:
exec: exec:
command: ["/bin/grpc_health_probe", "-addr=:7070"] command: ["/bin/grpc_health_probe", "-addr=:7070"]
resources: resources:
requests: requests:
cpu: 250m cpu: 250m
memory: 512Mi memory: 512Mi
limits: limits:
cpu: 700m cpu: 700m
memory: 1024Mi memory: 1024Mi
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
...@@ -106,22 +106,22 @@ spec: ...@@ -106,22 +106,22 @@ spec:
selector: selector:
app: monitoringservice app: monitoringservice
ports: ports:
- name: grpc - name: grpc
protocol: TCP protocol: TCP
port: 7070 port: 7070
targetPort: 7070 targetPort: 7070
- name: http - name: http
protocol: TCP protocol: TCP
port: 9000 port: 9000
targetPort: 9000 targetPort: 9000
- name: influxdb - name: influxdb
protocol: TCP protocol: TCP
port: 9009 port: 9009
targetPort: 9009 targetPort: 9009
- name: postgre - name: postgre
protocol: TCP protocol: TCP
port: 8812 port: 8812
targetPort: 8812 targetPort: 8812
--- ---
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
...@@ -131,16 +131,16 @@ metadata: ...@@ -131,16 +131,16 @@ metadata:
spec: spec:
podSelector: podSelector:
matchLabels: matchLabels:
app: monitoringservice app: monitoringservice
ingress: ingress:
- from: [] - from: []
ports: ports:
- port: 7070 - port: 7070
- port: 8812 - port: 8812
- from: - from:
- podSelector: - podSelector:
matchLabels: matchLabels:
app: monitoringservice app: monitoringservice
ports: ports:
- port: 9009 - port: 9009
- port: 9000 - port: 9000
...@@ -123,10 +123,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto ...@@ -123,10 +123,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
-output: KPI identifier representing the KPI -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 = KpiDescriptor()
kpidescriptor.kpi_description = kpi_description kpidescriptor.kpi_description = kpi_description
kpidescriptor.service_id.service_uuid.uuid = service_id.service_uuid.uuid 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 kpidescriptor.kpi_sample_type = kpi_sample_type
new_kpi = client.SetKpi(kpidescriptor) new_kpi = client.SetKpi(kpidescriptor)
...@@ -141,12 +145,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto ...@@ -141,12 +145,14 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
-output: None -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 now, all the KPIs are created for all the services from which requests are received
for kpi in self.monitored_kpis: for kpi in self.monitored_kpis:
created_kpi = self.create_kpi( created_kpi = self.create_kpi(
self.monitoring_client, self.monitoring_client,
service_id, service_id,
device_id,
endpoint_id,
kpi, kpi,
self.monitored_kpis[kpi]["description"], self.monitored_kpis[kpi]["description"],
self.monitored_kpis[kpi]["kpi_sample_type"], self.monitored_kpis[kpi]["kpi_sample_type"],
...@@ -428,10 +434,12 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto ...@@ -428,10 +434,12 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
self.inference_results.put({"output": cryptomining_detector_output_serialized, "timestamp": datetime.now()}) self.inference_results.put({"output": cryptomining_detector_output_serialized, "timestamp": datetime.now()})
service_id = request.service_id 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 # 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: 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) self.service_ids.append(service_id)
# Only notify Attack Mitigator when a cryptomining connection has been detected # Only notify Attack Mitigator when a cryptomining connection has been detected
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment