From b2c0fa32581bbed818099f80c523ff11fdd9b0b8 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Tue, 31 Mar 2026 14:25:03 +0000 Subject: [PATCH] feat(helm): Add prometheus servicemonitor to medcat-service-helm --- helm-charts/medcat-service-helm/README.md | 8 +++++- .../templates/serviceMonitor.yaml | 25 +++++++++++++++++++ helm-charts/medcat-service-helm/values.yaml | 17 ++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 helm-charts/medcat-service-helm/templates/serviceMonitor.yaml diff --git a/helm-charts/medcat-service-helm/README.md b/helm-charts/medcat-service-helm/README.md index 5447450..788e8ec 100644 --- a/helm-charts/medcat-service-helm/README.md +++ b/helm-charts/medcat-service-helm/README.md @@ -132,7 +132,7 @@ You should see the NVIDIA GPU device listing if the GPU is properly accessible. | autoscaling.minReplicas | int | `1` | | | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | env.APP_ENABLE_DEMO_UI | bool | `true` | | -| env.APP_ENABLE_METRICS | bool | `false` | Observability Env Vars | +| env.APP_ENABLE_METRICS | bool | `true` | Observability Env Vars | | env.APP_ENABLE_TRACING | bool | `false` | | | env.APP_MEDCAT_MODEL_PACK | string | `"/cat/models/examples/example-medcat-v2-model-pack.zip"` | This defines the Model Pack used by the medcat service Example (download on startup): uncomment `ENABLE_MODEL_DOWNLOAD` and the `MODEL_*` URLs below. Example (DeID mode): uncomment `DEID_MODE`/`DEID_REDACT` and use the DeID model pack referenced below. | | env.OTEL_EXPERIMENTAL_RESOURCE_DETECTORS | string | `"containerid,os"` | | @@ -184,6 +184,12 @@ You should see the NVIDIA GPU device listing if the GPU is properly accessible. | serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| serviceMonitor | object | `{"enabled":false,"interval":"10s","labels":{},"path":"/metrics","scheme":"http","tlsConfig":{}}` | Create a Prometheus ServiceMonitor for the medcat service. Requires the Prometheus Operator to be installed Ensure APP_ENABLE_METRICS is set to true to expose the /metrics endpoint. | +| serviceMonitor.enabled | bool | `false` | Set to true to enable creation of a ServiceMonitor resource | +| serviceMonitor.interval | string | `"10s"` | Frequency at which Prometheus will scrape metrics. | +| serviceMonitor.labels | object | `{}` | Additional labels to be added to the ServiceMonitor | +| serviceMonitor.path | string | `"/metrics"` | HTTP path where metrics are exposed. | +| serviceMonitor.scheme | string | `"http"` | Scheme to use for scraping. | | startupProbe.failureThreshold | int | `30` | | | startupProbe.httpGet.path | string | `"/api/health/ready"` | | | startupProbe.httpGet.port | string | `"http"` | | diff --git a/helm-charts/medcat-service-helm/templates/serviceMonitor.yaml b/helm-charts/medcat-service-helm/templates/serviceMonitor.yaml new file mode 100644 index 0000000..040e903 --- /dev/null +++ b/helm-charts/medcat-service-helm/templates/serviceMonitor.yaml @@ -0,0 +1,25 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "medcat-service.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "medcat-service.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "medcat-service.selectorLabels" . | nindent 6 }} + endpoints: + - port: http + interval: {{ .Values.serviceMonitor.interval }} + path: {{ .Values.serviceMonitor.path }} + scheme: {{ .Values.serviceMonitor.scheme }} + {{- with .Values.serviceMonitor.tlsConfig }} + tlsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/helm-charts/medcat-service-helm/values.yaml b/helm-charts/medcat-service-helm/values.yaml index c424ed3..3d54ed3 100644 --- a/helm-charts/medcat-service-helm/values.yaml +++ b/helm-charts/medcat-service-helm/values.yaml @@ -55,7 +55,7 @@ env: # APP_TORCH_THREADS: "-1" # -- Observability Env Vars - APP_ENABLE_METRICS: false + APP_ENABLE_METRICS: true APP_ENABLE_TRACING: false OTEL_EXPORTER_OTLP_ENDPOINT: "http://:4317" OTEL_SERVICE_NAME: "medcat-service" @@ -252,3 +252,18 @@ extraInitContainers: [] # -- Additional manifests to deploy to kubernetes. Can be templated extraManifests: [] + +# -- Create a Prometheus ServiceMonitor for the medcat service. Requires the Prometheus Operator to be installed +# Ensure APP_ENABLE_METRICS is set to true to expose the /metrics endpoint. +serviceMonitor: + # -- Set to true to enable creation of a ServiceMonitor resource + enabled: false + # -- HTTP path where metrics are exposed. + path: /metrics + # -- Scheme to use for scraping. + scheme: http + # -- Frequency at which Prometheus will scrape metrics. + interval: 10s + # -- Additional labels to be added to the ServiceMonitor + labels: {} + tlsConfig: {}