Skip to content

feat: turn Prometheus and Grafana on from the web app - #337

Merged
adeelahmad merged 4 commits into
mainfrom
claude/project-thread-kxit86
Oct 11, 2026
Merged

adeelahmad merged 4 commits into
mainfrom
claude/project-thread-kxit86

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Description

Before: running Prometheus, node-exporter and Grafana meant editing .env (COMPOSE_PROFILES=monitoring, a scrape token, the Grafana address) and running docker compose in a terminal.

After: one Charts and history switch, on Admin → System health and in Settings → Telemetry → Prometheus. Lens turns /metrics on, generates a scrape token if there is none, and the host upgrade agent adds monitoring to COMPOSE_PROFILES in .env and starts the three containers. The page shows how it is going, then links to Grafana on the host you opened Lens at (:3001, or the port in LENS_GRAFANA_PORT). Off stops and removes them, and turns /metrics off again if this switch was what turned it on.

How: the request goes in .lens-control/inbox/upgrade with action=services, because that is the file every installed agent already watches, so existing installs need no new systemd or launchd unit. lens-upgrade.sh handles only monitoring=on|off (it never installs anything for that request) and writes services-status and services.log. Prometheus reads the token from .lens-control/prometheus-token (kept in step with Settings), or from LENS_PROMETHEUS_TOKEN when that is set. Without an agent, the switch shows the one line to run on the machine.

API: GET/PUT /api/v1/admin/monitoring. MCP: monitoring, set_monitoring.

Motivation and Context

Adeel's rule: no terminal and no .env editing; every setting lives in the web app.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (ruff, mypy, eslint, prettier, tsc clean).
  • I added or updated tests (tests/api/test_monitoring.py, which also runs the agent script against a stand-in docker; MCP test; __tests__/monitoring-switch.test.ts).
  • My change requires documentation updates, and I have updated docs/ accordingly (prometheus.md, updates.md; mkdocs build --strict clean).
  • CHANGELOG: n/a, the title is enough.

Done questions (AGENTS.md)

  • Goal: monitoring is a web toggle; merged on green CI.
  • Agents: REST endpoint and MCP tools.
  • Zero setup: uses the agent install.sh already sets up; no new unit or .env edit.
  • Fewest clicks: one switch, and the token and Grafana link are set up automatically.
  • Configurable: off by default; the Grafana address can still be overridden in Settings.
  • Light: nothing runs until the switch is turned on.
  • Private and secure: the threat model has a row for the control inbox and the token file; the token reads metrics only, which carry no personal content.
  • Cost: n/a, no model calls.
  • User decides: off by default, and existing defaults are unchanged.
  • Upgrades: no stored-data shape change; the new app_service:monitoring row is created on first use.
  • Honest: docs say what is built; this has not been run with real Docker here (no daemon in CI's unit tests), and the agent script is tested with a stand-in docker.
  • Tests, docs and generated files (make openapi) updated.
  • Open standards; no new dependencies.
  • Refine later: a live end-to-end check on a real install.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XCh396xzDRUrSuH1xohcXR


Generated by Claude Code

A "Charts and history" switch on System health and in Settings → Telemetry asks the
host upgrade agent to add or remove the monitoring compose profile and start or stop
Prometheus, node-exporter and Grafana. Turning it on also turns /metrics on with a
generated scrape token, which Prometheus reads from the control folder, and links
System health to Grafana on this host. API: GET/PUT /admin/monitoring; MCP:
monitoring, set_monitoring.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XCh396xzDRUrSuH1xohcXR
…anions

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XCh396xzDRUrSuH1xohcXR
…-kxit86

# Conflicts:
#	fastapi_backend/app/api/mcp_tools.py
#	fastapi_backend/tests/api/test_mcp.py
@adeelahmad
adeelahmad merged commit 9b0ee50 into main Oct 11, 2026
18 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-kxit86 branch October 11, 2026 00:40
adeelahmad added a commit that referenced this pull request Oct 11, 2026
…349)

"Stay private and safe" now covers flagging instruction-like text (patterns or the optional local classifier, #329,
#347), asking before the browser acts on what the assistant wrote (#333), breaking up links in chat-room answers
(#338), the archive as data over MCP (#343) and the audit log of what was caught (#344). "See what it costs" adds the
overall budget asked for in setup (#281). "In progress" drops what merged and adds #337, #341 and #346.


Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS

Co-authored-by: Adeel Ahmad <noreply@anthropic.com>
adeelahmad added a commit that referenced this pull request Oct 11, 2026
…monitoring switch as built (#351)

"Ask" names the built-in Telegram bot (#293) and Slack app (#287); "Connect your agents" adds mounting the graph's
files read-only over S3, WebDAV, NFS or SMB (#324, #295, #305) and copying the MCP address from the account menu
(#340); "Watch it run" says one switch in the web app starts Prometheus and Grafana (#337); "Light by default" adds
the cloud model presets (#334). The docs index gains the NFS and SMB pages, and "In progress" keeps only open PRs.


Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS

Co-authored-by: Adeel Ahmad <noreply@anthropic.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.

2 participants