Skip to content
Snippets Groups Projects
Commit a3700c1e authored by Sergio Gonzalez Diaz's avatar Sergio Gonzalez Diaz
Browse files

Update monitoringservice.yaml

parent c1b33911
No related branches found
No related tags found
1 merge request!54Release 2.0.0
......@@ -13,13 +13,14 @@
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: monitoringservice
name: monitoringdb
spec:
selector:
matchLabels:
app: monitoringservice
serviceName: "monitoringservice"
replicas: 1
template:
metadata:
......@@ -32,35 +33,47 @@ spec:
- name: metricsdb
image: questdb/questdb
ports:
- containerPort: 9000
- containerPort: 9009
- containerPort: 9003
- name: http
containerPort: 9000
protocol: TCP
- name: influxdb
containerPort: 9009
protocol: TCP
env:
- name: QDB_CAIRO_COMMIT_LAG
value: "1000"
- name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS
value: "100000"
readinessProbe:
exec:
command: ["curl", "-XGET", "localhost:9000"]
livenessProbe:
exec:
command: ["curl", "-XGET", "localhost:9003/metrics"]
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 700m
memory: 1024Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: monitoringserver
spec:
selector:
matchLabels:
app: monitoringservice
replicas: 1
template:
metadata:
labels:
app: monitoringservice
spec:
terminationGracePeriodSeconds: 5
restartPolicy: Always
containers:
- name: server
image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest
imagePullPolicy: Always
ports:
- containerPort: 7070
- name: grpc
containerPort: 7070
protocol: TCP
env:
- name: LOG_LEVEL
value: "INFO"
- name: METRICSDB_HOSTNAME
value: "localhost"
value: "monitoringservice"
- name: METRICSDB_ILP_PORT
value: "9009"
- name: METRICSDB_REST_PORT
......@@ -68,19 +81,13 @@ spec:
- name: METRICSDB_TABLE
value: "monitoring"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:7070"]
grpc:
port: 7070
initialDelaySeconds: 5
livenessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:7070"]
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 700m
memory: 1024Mi
grpc:
port: 7070
initialDelaySeconds: 10
---
apiVersion: v1
kind: Service
......@@ -95,7 +102,11 @@ spec:
protocol: TCP
port: 7070
targetPort: 7070
- name: questdb
- name: http
protocol: TCP
port: 9000
targetPort: 9000
\ No newline at end of file
targetPort: 9000
- name: influxdb
protocol: TCP
port: 9009
targetPort: 9009
\ No newline at end of file
......@@ -17,14 +17,17 @@ import socket
import requests
import json
import sys
import logging
LOGGER = logging.getLogger(__name__)
class MetricsDB():
def __init__(self, host, ilp_port, rest_port, table):
self.socket=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.host=host
self.ilp_port=ilp_port
self.rest_port=rest_port
self.table=table
self.socket=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.host=host
self.ilp_port=int(ilp_port)
self.rest_port=rest_port
self.table=table
def write_KPI(self,time,kpi_id,kpi_sample_type,device_id,endpoint_id,service_id,kpi_value):
self.socket.connect((self.host,self.ilp_port))
......@@ -42,11 +45,11 @@ class MetricsDB():
self.socket.close()
def run_query(self, sql_query):
query_params = {'query': sql_query, 'fmt' : 'json'}
url = f"http://{self.host}:{self.rest_port}/exec"
try:
response = requests.get(url, params=query_params)
json_response = json.loads(response.text)
print(json_response)
except requests.exceptions.RequestException as e:
print(f'Error: {e}', file=sys.stderr)
query_params = {'query': sql_query, 'fmt' : 'json'}
url = f"http://{self.host}:{self.rest_port}/exec"
try:
response = requests.get(url, params=query_params)
json_response = json.loads(response.text)
LOGGER.info(json_response)
except requests.exceptions.RequestException as e:
LOGGER.info(f'Error: {e}', file=sys.stderr)
......@@ -59,6 +59,7 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
# Set metrics_db client
self.metrics_db = MetricsDBTools.MetricsDB(METRICSDB_HOSTNAME,METRICSDB_ILP_PORT,METRICSDB_REST_PORT,METRICSDB_TABLE)
LOGGER.info('MetricsDB initialized')
# SetKpi (SetKpiRequest) returns (KpiId) {}
def SetKpi(
......
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