diff --git a/helm/litellm-helm/README.md b/helm/litellm-helm/README.md index 4c8712ea7b9..9332a49c5ac 100644 --- a/helm/litellm-helm/README.md +++ b/helm/litellm-helm/README.md @@ -29,6 +29,7 @@ If `db.useStackgresOperator` is used (not yet implemented): | `masterkey` | The Master API Key for LiteLLM. If not specified, a random key in the `sk-...` format is generated. | N/A | | `environmentSecrets` | An optional array of Secret object names. The keys and values in these secrets will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` | | `environmentConfigMaps` | An optional array of ConfigMap object names. The keys and values in these configmaps will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` | +| `jsonLogs` | Emit logs as JSON instead of plain text, by setting `JSON_LOGS=True` on the proxy pod. Covers uvicorn's access and error logs alongside LiteLLM's own. Defining `JSON_LOGS` in `envVars` takes precedence. | `false` | | `image.repository` | LiteLLM Proxy image repository | `docker.litellm.ai/berriai/litellm` | | `image.pullPolicy` | LiteLLM Proxy image pull policy | `IfNotPresent` | | `image.tag` | Overrides the image tag whose default the latest version of LiteLLM at the time this chart was published. | `""` | diff --git a/helm/litellm-helm/templates/deployment.yaml b/helm/litellm-helm/templates/deployment.yaml index 32bfa4b2647..54b0e7cb59d 100644 --- a/helm/litellm-helm/templates/deployment.yaml +++ b/helm/litellm-helm/templates/deployment.yaml @@ -133,6 +133,14 @@ spec: - name: LITELLM_LOG value: {{ .Values.logLevel | quote }} {{- end }} + {{- /* + JSON_LOGS is truthy for any non-empty value, so it is injected only when + jsonLogs is on and omitted entirely otherwise. + */}} + {{- if and .Values.jsonLogs (not (hasKey (default dict .Values.envVars) "JSON_LOGS")) }} + - name: JSON_LOGS + value: "True" + {{- end }} {{- if .Values.envVars }} {{- range $key, $val := .Values.envVars }} - name: {{ $key }} diff --git a/helm/litellm-helm/tests/deployment_tests.yaml b/helm/litellm-helm/tests/deployment_tests.yaml index f3d62651d8f..39afa53d7b9 100644 --- a/helm/litellm-helm/tests/deployment_tests.yaml +++ b/helm/litellm-helm/tests/deployment_tests.yaml @@ -402,3 +402,38 @@ tests: - equal: path: spec.template.metadata.annotations["example.com/literal"] value: "plain-string-value" + - it: should not set JSON_LOGS by default + template: deployment.yaml + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: JSON_LOGS + value: "True" + - it: should set JSON_LOGS when jsonLogs is enabled + template: deployment.yaml + set: + jsonLogs: true + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: JSON_LOGS + value: "True" + - it: should let envVars win over jsonLogs instead of emitting JSON_LOGS twice + template: deployment.yaml + set: + jsonLogs: true + envVars: + JSON_LOGS: "1" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: JSON_LOGS + value: "1" + - notContains: + path: spec.template.spec.containers[0].env + content: + name: JSON_LOGS + value: "True" diff --git a/helm/litellm-helm/values.yaml b/helm/litellm-helm/values.yaml index df2b55723fe..6877c7e900f 100644 --- a/helm/litellm-helm/values.yaml +++ b/helm/litellm-helm/values.yaml @@ -459,6 +459,16 @@ migrationJob: # this injection entirely when envVars already defines LITELLM_LOG. logLevel: INFO +# Emit logs as JSON instead of the default plain text (sets JSON_LOGS=True in the +# deployment env), for centralized log systems that would otherwise need a custom +# parser. Covers uvicorn's access and error logs as well as LiteLLM's own. +# +# JSON_LOGS is truthy for any non-empty value, so the variable is injected only +# when this is true and left out entirely when it is false. Defining JSON_LOGS +# inside `envVars:` below wins: the template skips this injection when envVars +# already defines it. +jsonLogs: false + # Additional environment variables to be added to the deployment as a map of key-value pairs envVars: {}