From be051780f0525b12a2ac89925c14e900c175b0a2 Mon Sep 17 00:00:00 2001 From: kondratyevd Date: Thu, 6 Feb 2025 19:06:51 -0500 Subject: [PATCH] move scaling metric to a separate file for clarity --- helm/supersonic/templates/NOTES.txt | 2 +- helm/supersonic/templates/_helpers.tpl | 14 ----------- helm/supersonic/templates/_scaling-metric.tpl | 23 +++++++++++++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 helm/supersonic/templates/_scaling-metric.tpl diff --git a/helm/supersonic/templates/NOTES.txt b/helm/supersonic/templates/NOTES.txt index 0803c45..4704f35 100644 --- a/helm/supersonic/templates/NOTES.txt +++ b/helm/supersonic/templates/NOTES.txt @@ -18,7 +18,7 @@ SuperSONIC chart successfully installed! Scaling metric:{{ if not ( eq .Values.prometheus.serverLoadMetric "" ) }} {{ .Values.prometheus.serverLoadMetric }}{{ else }}{{ include "supersonic.defaultMetric" . | nindent 4 }}{{ end }} -Scaling threshold: {{ .Values.prometheus.serverLoadThreshold }}{{"\n"}} +Scaling threshold: {{ include "supersonic.serverLoadThreshold" . }}{{"\n"}} {{- if or (and .Values.grafana.enabled (eq (include "supersonic.grafanaExists" .) "true")) (eq (include "supersonic.prometheusExists" .) "true") .Values.prometheus.external }} ┌-----------------------------------------------------------------------------┐ diff --git a/helm/supersonic/templates/_helpers.tpl b/helm/supersonic/templates/_helpers.tpl index b42ad4f..2293fdc 100644 --- a/helm/supersonic/templates/_helpers.tpl +++ b/helm/supersonic/templates/_helpers.tpl @@ -25,20 +25,6 @@ Get Envoy name {{- printf "%s-envoy" (include "supersonic.name" .) | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{- define "supersonic.defaultMetric" -}} -{{- if not ( eq .Values.prometheus.serverLoadMetric "" ) }} - {{- printf "%s" .Values.prometheus.serverLoadMetric -}} -{{- else }} -sum by (release) ( - rate(nv_inference_queue_duration_us{release=~"{{ include "supersonic.name" . }}"}[15s]) -) - / -sum by (release) ( - (rate(nv_inference_exec_count{release=~"{{ include "supersonic.name" . }}"}[15s]) * 1000) + 0.001 -) -{{- end }} -{{- end }} - {{/* Get gRPC endpoint */}} diff --git a/helm/supersonic/templates/_scaling-metric.tpl b/helm/supersonic/templates/_scaling-metric.tpl new file mode 100644 index 0000000..e20ae91 --- /dev/null +++ b/helm/supersonic/templates/_scaling-metric.tpl @@ -0,0 +1,23 @@ +{{/* +Get default scaling metric +*/}} +{{- define "supersonic.defaultMetric" -}} +{{- if not ( eq .Values.prometheus.serverLoadMetric "" ) }} + {{- printf "%s" .Values.prometheus.serverLoadMetric -}} +{{- else }} +sum by (release) ( + rate(nv_inference_queue_duration_us{release=~"{{ include "supersonic.name" . }}"}[15s]) +) + / +sum by (release) ( + (rate(nv_inference_exec_count{release=~"{{ include "supersonic.name" . }}"}[15s]) * 1000) + 0.001 +) +{{- end }} +{{- end }} + +{{/* +Get server load threshold (defaults to 100 if not set) +*/}} +{{- define "supersonic.serverLoadThreshold" -}} +{{- default 100 .Values.prometheus.serverLoadThreshold -}} +{{- end -}} \ No newline at end of file