Hey everyone,
If you manage an LGTM (Loki, Grafana, Tempo, Prometheus) stack, you know the drill: an incident happens, you context-switch out of your terminal, hunt down the right dashboard, and manually write/tweak PromQL or LogQL queries to figure out what’s broken. I got really tired of doing this.
At the same time, I’ve been building local AI agents using the OpenClaw framework. But running autonomous agents is risky—you never know exactly how many tokens they are burning, if they are stuck in an infinite tool loop, or if they are executing prompt injections.
So, I built openclaw-grafana-lens to solve both problems.
It’s an open-source plugin that seamlessly connects an OpenClaw agent to your existing Grafana stack. Basically, it turns your local LLM into a dedicated “AI SRE”, while completely monitoring the AI itself.
GitHub: https://github.com/awsome-o/grafana-lens
What it actually does (The Features)
1. Agent-Driven Debugging (Talk to your metrics): You don’t need to write PromQL/LogQL anymore. Just ask the agent: “Check the memory usage of the postgres container over the last 3 hours” or “Why did the checkout API just spike in latency?” The agent generates the query, fetches the data from your datasources, and summarizes the root cause.
2. Auto-Provision Alerts & Dashboards: Describe your monitoring needs in plain English. Say “Alert me if the API error rate > 5%” and the agent will automatically provision the native Grafana alert rule. Need a dashboard? It can create them on the fly, and even render panels as PNGs directly into your chat.
3. Push & Monitor Literally Anything: It includes a “Custom Data Observatory.” You can use the agent to push arbitrary data directly into Grafana via conversation. Want to track custom scripts, git commits, or even fitness data? Just tell the agent.
4. Native GenAI OTLP Push (Monitor the Agent): To solve the “AI black box” problem, the plugin automatically pushes all agent telemetry to your OTLP receivers (e.g., :4318). You get full hierarchical traces (Session -> LLM Call -> Tool Execution) natively in Tempo so you can see exactly how the agent is “thinking.”
5. Comprehensive Security & Cost Monitors: It tracks the agent’s token burn rate in Prometheus. It also runs parallel security checks to detect prompt injections (12 patterns), catches webhook errors, and aggressively halts infinite tool-call loops before they fry your CPU. (The repo ships with 12 pre-built dashboards for this).
Stupidly Easy to Setup
I wanted this to be zero-friction. If you already have OpenClaw and a Grafana instance running, there are no new databases to deploy. You just need a Grafana Service Account Token:
Bash
# 1. Install the OpenClaw framework (if you don't have it)
npm install -g openclaw
# 2. Install the Grafana Lens plugin
openclaw plugins install openclaw-grafana-lens
# 3. Point it to your existing Grafana URL and API token
export GRAFANA_URL=http://localhost:3000
export GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_xxxxxxxxxxxx
# 4. Start the agent gateway
openclaw gateway restart
(Don’t have a local stack? The README has a 1-liner to spin up the official grafana/otel-lgtm docker container, and to kick off the openclaw agent, you can use it’s cli mode or using it’s gateway. The plugin has everything ready to teach the agent, from creating a dashboard to using query tools for LGTM).
I built this to scratch my own itch for local homelab observability and agent debugging. I’d love for the power users here to test it out—especially to see how well the PromQL generation handles your highly custom metrics.
Let me know what you think!



