Skip to content

fix: pass prometheus and grafana config as env vars in helm chart - #63

Merged
dimetron merged 1 commit into
kagent-dev:mainfrom
ruslanaliyevn:fix/prometheus-url-helm
Sep 22, 2026
Merged

dimetron merged 1 commit into
kagent-dev:mainfrom
ruslanaliyevn:fix/prometheus-url-helm

Conversation

@ruslanaliyevn

Copy link
Copy Markdown
Contributor

Problem

tools.prometheus.url, tools.prometheus.username, tools.prometheus.password,
tools.grafana.url and tools.grafana.apiKey values were defined in values.yaml
but never passed to the container as environment variables in deployment.yaml.

Solution

Added the missing environment variables to the deployment template so that
Prometheus and Grafana configuration is properly passed to the tool server.

Fixes #36

Signed-off-by: Ruslan Aliyev <ruslanaliyevn@email.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the kagent-tools Helm chart Deployment template to actually wire Prometheus and Grafana configuration values (previously present only in values.yaml) into the running container via environment variables, addressing issue #36.

Changes:

  • Add missing Prometheus and Grafana environment variables to helm/kagent-tools/templates/deployment.yaml.
  • Minor template cleanup/formatting adjustments in the same manifest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +97 to +98
- name: PROMETHEUS_URL
value: {{ .Values.tools.prometheus.url | quote }}
Comment on lines +99 to +102
- name: PROMETHEUS_USERNAME
value: {{ .Values.tools.prometheus.username | quote }}
- name: PROMETHEUS_PASSWORD
value: {{ .Values.tools.prometheus.password | quote }}
Comment on lines +101 to +106
- name: PROMETHEUS_PASSWORD
value: {{ .Values.tools.prometheus.password | quote }}
- name: GRAFANA_URL
value: {{ .Values.tools.grafana.url | quote }}
- name: GRAFANA_API_KEY
value: {{ .Values.tools.grafana.apiKey | quote }}
Comment on lines +97 to +106
- name: PROMETHEUS_URL
value: {{ .Values.tools.prometheus.url | quote }}
- name: PROMETHEUS_USERNAME
value: {{ .Values.tools.prometheus.username | quote }}
- name: PROMETHEUS_PASSWORD
value: {{ .Values.tools.prometheus.password | quote }}
- name: GRAFANA_URL
value: {{ .Values.tools.grafana.url | quote }}
- name: GRAFANA_API_KEY
value: {{ .Values.tools.grafana.apiKey | quote }}
@dimetron
dimetron self-requested a review June 23, 2026 14:41
jedi-tal added a commit to jedi-tal/tools that referenced this pull request Aug 14, 2026
`PROMETHEUS_URL` is documented in the README ("Default Prometheus server
URL") but was never read: every prometheus_* handler hard-coded
`http://localhost:9090` as the fallback for the optional `prometheus_url`
parameter, and the Helm chart's `tools.prometheus.url` value was never
passed to the container (kagent-dev#63, kagent-dev#36).

The practical effect is that the ONLY way to reach a Prometheus that is
not on localhost is for the model to pass `prometheus_url` on every single
call. Because the parameter is optional and the schema advertises a
plausible-looking default, models routinely omit it - the call then fails
with "connection refused" against a port nothing serves inside the tool
server's pod, and the agent burns a turn retrying. On one of our scheduled
survey agents this wasted 12 of a 24-call budget in a single run.

- read `PROMETHEUS_URL` (trimmed) as the default, falling back to
  `http://localhost:9090` when unset, so existing deployments are unchanged
- build the `prometheus_url` parameter description from that same value, so
  the tool schema advertises the default a caller will actually get instead
  of always claiming localhost
- render `PROMETHEUS_URL` in the chart from `tools.prometheus.url`, only
  when set; its previous default was schemeless
  (`prometheus.kagent.svc.cluster.local:9090`) and would have been rejected
  by `security.ValidateURL`, so it now defaults to empty = tool default

The explicit `prometheus_url` parameter still wins when supplied.

Closes kagent-dev#63

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: jedi-tal <tal@jedify.com>
@dimetron
dimetron merged commit e5cea22 into kagent-dev:main Sep 22, 2026
5 checks passed
dimetron added a commit that referenced this pull request Sep 23, 2026
Upstream main still runs mark3labs/mcp-go; this branch migrates to the official
go-sdk. The three incoming commits therefore needed judgement, not just a
take-theirs/take-ours:

* 1bdfcd6 (heap leak, #85) fixes a session leak that exists on mark3labs v0.43.2
  by bumping to v1.1.0 and enabling its opt-in sweeper. This branch removed
  mark3labs entirely in 6dc138b/761a438 and ported the same fix to the go-sdk
  path. Its only surviving contribution is intent, already implemented, so its
  cmd/main.go edits are dropped rather than merged - they reference
  server.StreamableHTTPServer and server.NewMCPServer, which do not exist here.

* e5cea22 (prometheus/grafana env vars, #63) applied cleanly to
  helm/kagent-tools/templates/deployment.yaml.

* bd6e49d (quickstart typo, #17) applied cleanly.

Conflict resolutions:

  go.mod/go.sum        ours. Upstream is the older line throughout - kubescape
                       k8s-interface 0.0.203 vs 0.0.221, k8s.io 0.35.3 vs 0.37.0,
                       jsonschema-go 0.4.2 vs 0.4.3 - and the SDK differs by
                       design. Re-tidied after.
  Makefile             ours. Upstream pins istio 1.30.1, kubectl 1.36.2, helm
                       4.2.2, cilium 0.19.4 and golangci-lint v1.63.4; this
                       branch is newer on all five. Keeps the .golangci.yml v2
                       config that only golangci-lint v2 understands.
  README.md            ours for the --session-idle-ttl default, because this
                       branch defines sessionIdleTTLDefault = 30m; upstream
                       says 10m for its own variable. Upstreams mcp_inspect
                       removal is not taken - the tool is still registered in
                       pkg/utils/common.go:220.
  cmd/main.go          ours (go-sdk API), see 1bdfcd6 above.
  cmd/streamable_http_test.go  ours (add/add, go-sdk version).

Verified on the merged tree: go build ./... clean, go vet ./... clean, 19/19
unit packages pass, golangci-lint 0 issues.

Signed-off-by: Dmytro Rashko <dimetron@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools.prometheus.url value is defined but not used in kagent-tools Helm chart

3 participants