Skip to content

Commit 43e3c21

Browse files
committed
chore(monitor): use prometheus replace timeseries
1 parent 3b4d5e3 commit 43e3c21

9 files changed

Lines changed: 155 additions & 260 deletions

File tree

charts/controller/templates/_helpers.tpl

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,6 @@ env:
9090
- name: DRYCC_DATABASE_REPLICA_URL
9191
value: "postgres://$(DRYCC_PG_USER):$(DRYCC_PG_PASSWORD)@drycc-database-replica.{{.Release.Namespace}}.svc.{{.Values.global.clusterDomain}}:5432/controller"
9292
{{- end }}
93-
{{- if (.Values.databaseMonitorUrl) }}
94-
- name: DRYCC_DATABASE_MONITOR_URL
95-
valueFrom:
96-
secretKeyRef:
97-
name: controller-creds
98-
key: database-monitor-url
99-
{{- else if eq .Values.global.timeseriesLocation "on-cluster" }}
100-
- name: DRYCC_TS_USER
101-
valueFrom:
102-
secretKeyRef:
103-
name: timeseries-creds
104-
key: user
105-
- name: DRYCC_TS_PASSWORD
106-
valueFrom:
107-
secretKeyRef:
108-
name: timeseries-creds
109-
key: password
110-
- name: DRYCC_DATABASE_MONITOR_URL
111-
value: "postgres://$(DRYCC_TS_USER):$(DRYCC_TS_PASSWORD)@drycc-timeseries-replica.{{.Release.Namespace}}.svc.{{.Values.global.clusterDomain}}:5432/monitor"
112-
{{- end }}
11393
{{- if (.Values.workflowManagerUrl) }}
11494
- name: WORKFLOW_MANAGER_URL
11595
value: "{{ .Values.workflowManagerUrl }}"

charts/controller/templates/controller-secret-creds.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ data:
1111
{{- if (.Values.databaseReplicaUrl) }}
1212
database-replica-url: {{ .Values.databaseReplicaUrl | b64enc }}
1313
{{- end }}
14-
{{- if (.Values.databaseMonitorUrl) }}
15-
database-monitor-url: {{ .Values.databaseMonitorUrl | b64enc }}
16-
{{- end }}
1714
{{- if (.Values.rabbitmqUrl) }}
1815
rabbitmq-url: {{ .Values.rabbitmqUrl | b64enc }}
1916
{{- end }}

charts/controller/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ service:
8484
# can be specified as key-value pairs under environment
8585
# this is usually a non required setting.
8686
environment:
87-
RESERVED_NAMES: "drycc, drycc-builder, drycc-monitor-grafana, drycc-passport, drycc-helmbroker, drycc-manager"
87+
RESERVED_NAMES: "drycc, drycc-builder, drycc-grafana, drycc-passport, drycc-helmbroker, drycc-manager"
8888

8989
api:
9090
nodeAffinityPreset:

rootfs/api/management/commands/measure_loadbalancers.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
import logging
44
import ipaddress
5+
from asgiref.sync import async_to_sync
56
from django.utils import timezone
67
from django.core.management.base import BaseCommand
78
from django.conf import settings
@@ -24,22 +25,23 @@ def _measure_loadbalancers(self, app_map, timestamp):
2425
stop = timestamp - (timestamp % 3600)
2526
start = stop - 3600
2627
loadbalancers = []
27-
for item in monitor.query_loadbalancer(app_map.keys(), start, stop):
28-
ip = item["ip"]
29-
namespace = item["namespace"]
28+
for metric, (_, value) in async_to_sync(monitor.query_loadbalancer(
29+
app_map.keys(), start, stop)):
30+
ip = metric["ip"]
31+
namespace = metric["namespace"]
3032
owner_id = app_map[namespace].owner_id
3133
loadbalancers.append({
3234
"app_id": str(app_map[namespace].uuid),
3335
"owner": owner_id,
3436
"name": self._get_measure_name(ip),
3537
"type": "loadbalancer",
3638
"unit": "number",
37-
"usage": 1,
39+
"usage": value,
3840
"kwargs": {
3941
"ip": ip,
40-
"node": item["node"],
41-
"service": item["service"],
42-
"instance": item["instance"],
42+
"node": metric["node"],
43+
"service": metric["service"],
44+
"instance": metric["instance"],
4345
},
4446
"timestamp": start
4547
})

rootfs/api/management/commands/measure_networks.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import uuid
22
import time
33
import logging
4+
from asgiref.sync import async_to_sync
45
from django.utils import timezone
56
from django.core.management.base import BaseCommand
67
from django.conf import settings
@@ -18,21 +19,34 @@ def _measure_networks(self, app_map, timestamp):
1819
stop = timestamp - (timestamp % 3600)
1920
start = stop - 3600
2021
networks = []
21-
for namespace, pod_name, rx_bytes, tx_bytes in monitor.query_network_flow(
22-
app_map.keys(), start, stop):
23-
owner_id = app_map[namespace].owner_id
24-
base_measure = {
25-
"app_id": str(app_map[namespace].uuid),
26-
"owner": owner_id,
22+
for metric, (_, value) in async_to_sync(monitor.query_network_receive_flow(
23+
app_map.keys(), start, stop)):
24+
networks.append({
25+
"app_id": str(app_map[metric['namespace']].uuid),
26+
"owner": app_map[metric['namespace']].owner_id,
2727
"type": "network",
2828
"unit": "bytes",
29+
"name": "rx",
30+
"usage": value,
2931
"kwargs": {
30-
"pod": pod_name,
32+
"pod": metric['pod'],
3133
},
3234
"timestamp": start
33-
}
34-
networks.append(base_measure | {"name": "rx", "usage": rx_bytes})
35-
networks.append(base_measure | {"name": "tx", "usage": tx_bytes})
35+
})
36+
for metric, (_, value) in async_to_sync(monitor.query_network_transmit_flow(
37+
app_map.keys(), start, stop)):
38+
networks.append({
39+
"app_id": str(app_map[metric['namespace']].uuid),
40+
"owner": app_map[metric['namespace']].owner_id,
41+
"type": "network",
42+
"unit": "bytes",
43+
"name": "tx",
44+
"usage": value,
45+
"kwargs": {
46+
"pod": metric['pod'],
47+
},
48+
"timestamp": start
49+
})
3650
send_measurements.delay(networks)
3751

3852
def handle(self, *args, **options):

rootfs/api/models/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _update_values(self, previous_config):
174174
else: # force to string
175175
new_item['value'] = str(new_item['value'])
176176
break
177-
if added:
177+
if added and new_item['value'] is not None:
178178
data.append(new_item)
179179
setattr(self, 'values', data)
180180

0 commit comments

Comments
 (0)