Skip to content

Commit

Permalink
Make it possible to disable the prometheus datasource configured in g…
Browse files Browse the repository at this point in the history
…rafana
  • Loading branch information
Danny Guinther committed May 9, 2024
1 parent 903acdd commit 3279e6f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions charts/nm-vllm-production-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following options are supported. See [values.yaml](/charts/nm-vllm-productio
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| datasource | object | -- | Configuration for the datasource connecting prometheus and grafana. |
| datasource.enabled | bool | `true` | Toggles whether or not a prometheus datasource will be configured in grafana. |
| datasource.httpMethod | string | `"POST"` | The HTTP method to use for prometheus datasource configured in grafana. |
| datasource.isDefault | bool | `true` | Toggles whether or not the prometheus datasource configured in grafana should be the default grafana datasource. |
| datasource.name | string | `"Prometheus"` | The name to use for the prometheus datasource configured in grafana. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A lot of inspiration taken from:
- https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/templates/grafana/configmaps-datasources.yaml
*/ -}}
{{- if .Values.datasource.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -21,3 +22,4 @@ data:
type: prometheus
uid: {{ .Values.datasource.uid }}
url: {{ template "nm-vllm-production-monitoring.grafanaDatasourceUrl" $ }}
{{- end }}
5 changes: 5 additions & 0 deletions charts/nm-vllm-production-monitoring/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"datasource": {
"description": "Configuration for the datasource connecting prometheus and grafana.",
"properties": {
"enabled": {
"default": true,
"description": "Toggles whether or not a prometheus datasource will be configured in grafana.",
"type": "boolean"
},
"httpMethod": {
"default": "POST",
"description": "The HTTP method to use for the prometheus datasource configured in grafana",
Expand Down
3 changes: 3 additions & 0 deletions charts/nm-vllm-production-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# @default -- --
datasource:

# -- Toggles whether or not a prometheus datasource will be configured in grafana.
enabled: true

# -- The HTTP method to use for prometheus datasource configured in grafana.
httpMethod: POST

Expand Down
18 changes: 18 additions & 0 deletions tests/charts/nm_vllm_production_monitoring/test_config_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ def test_datasource_url_can_be_configured(helm_runner: HelmRunner) -> None:
assert actual_url == url


def test_datasource_can_be_disabled(helm_runner: HelmRunner) -> None:
for datasource_enabled in [False, True]:
resources = helm_runner.template(
chart="nm-vllm-production-monitoring",
name="nm-vllm",
values=[{"datasource": {"enabled": datasource_enabled}}],
)
config_map_names = [
resource["metadata"]["name"]
for resource in resources
if resource["kind"] == "ConfigMap"
]
assert (
"nm-vllm-nm-vllm-production-monitoring-grafana-datasource"
in config_map_names
) is datasource_enabled


def render_subject(
helm_runner: HelmRunner,
name: str = "name-given-to-the-release",
Expand Down

0 comments on commit 3279e6f

Please sign in to comment.