From 5dfea099573ac02220dc37872467d0fd2308d6e2 Mon Sep 17 00:00:00 2001 From: Negash Date: Wed, 3 Jan 2024 14:28:56 +0000 Subject: [PATCH] change script --- chart/templates/generator-application.yaml | 11 +---------- chart/templates/metrics-config-map.yaml | 10 +++++++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/chart/templates/generator-application.yaml b/chart/templates/generator-application.yaml index fa767c4..68188ca 100644 --- a/chart/templates/generator-application.yaml +++ b/chart/templates/generator-application.yaml @@ -172,16 +172,7 @@ spec: - sh - -c args: - - pip - - install - - prometheus_client - - requests - - && - - python - - /script/run.py - - && - - sleep - - infinity + - pip install prometheus_client requests && python3 /script/run.py && sleep infinity volumeMounts: - name: python-uptime-script mountPath: /script diff --git a/chart/templates/metrics-config-map.yaml b/chart/templates/metrics-config-map.yaml index ead56bd..d4f1060 100644 --- a/chart/templates/metrics-config-map.yaml +++ b/chart/templates/metrics-config-map.yaml @@ -5,4 +5,12 @@ metadata: namespace: {{ .Release.Namespace }} data: run.py: | - print('hello world') \ No newline at end of file + from prometheus_client.parser import text_string_to_metric_families + import requests + import time + while True: + metrics = requests.get("http://0.0.0.0:{{ .Values.tunnel.port }}/metrics").content + for family in text_string_to_metric_families(metrics): + for sample in family.samples: + print("Name: {0} Labels: {1} Value: {2}".format(*sample)) + time.sleep(5) \ No newline at end of file