Skip to content

dbazhenov/pmm-chart-ai-explainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PMM Chart AI Explainer

A Chrome extension that adds AI-powered analysis to every chart in Percona Monitoring and Management (PMM) dashboards.

Click the AI button on any panel to get an instant explanation of what the metric measures, whether anything looks abnormal, and what to do about it — powered by OpenAI GPT-4o Vision.

AI buttons on PMM dashboard panels and extension popup


Features

  • One-click analysis — an AI button appears on every PMM dashboard panel
  • Chart screenshot — captures the visible panel and sends it to GPT-4o Vision for visual analysis
  • PromQL-aware — intercepts the real executed queries (with substituted variables) and includes them in the prompt so the AI understands the exact metric and database type
  • Data table — optionally reads the Inspect → Data table and appends actual metric values to the prompt
  • Time range context — includes the current dashboard time range in every analysis
  • Database-aware — automatically identifies MySQL, PostgreSQL, MongoDB, ProxySQL, Redis/Valkey, and OS-level metrics from metric name prefixes
  • Smart deduplication — collapses redundant data frames to minimize token usage and cost
  • Debug mode — preview the exact prompt and screenshot before sending to OpenAI
  • Configurable — toggle data table inclusion, adjust max response tokens, enable/disable per session

Installation

From source (Developer mode)

  1. Clone or download this repository:

    git clone https://github.com/percona/pmm-chart-ai-explainer.git
  2. Open Chrome and navigate to chrome://extensions

  3. Enable Developer mode (toggle in the top-right corner)

  4. Click Load unpacked and select the extension/ subfolder inside the cloned repository

  5. The extension icon will appear in the Chrome toolbar

Note: The extension matches any URL so it works on any PMM instance — cloud-hosted, self-managed, or accessed via a VPN.


Setup

  1. Click the extension icon in the Chrome toolbar to open the popup

  2. Enter your OpenAI API key (starts with sk-) and click Save

  3. Navigate to any PMM dashboard — each chart will now show an AI button in its header

Your API key is stored locally in Chrome's sync storage and is only ever sent to api.openai.com — never to any other server.


Usage

Basic analysis

  1. Open a PMM dashboard
  2. Click the AI button on any chart panel
  3. Wait a few seconds while the extension:
    • Opens the Grafana Inspect panel to capture the real PromQL queries
    • Takes a screenshot of the panel
    • Sends everything to GPT-4o
  4. A modal appears with the AI analysis

AI analysis result for Database Queries/s (QPS) panel

Analysis output

Every response includes:

Section When shown
What this metric measures Always — with description, value interpretation, and normal range
Anomalies & observations Always
What it means Only if anomalies found
Recommended action Only if anomalies found
Related PMM dashboards & panels Always — even when everything looks healthy

Debug mode

Enable Debug Mode in the popup to preview the full prompt and screenshot without spending API tokens. You can then click Send to OpenAI to trigger the call manually.

Debug mode showing the prompt sent to GPT-4o

The debug view also shows the full data table when Include Data Table is enabled:

Debug mode with data table and Send to OpenAI button

Popup settings

Setting Description
Plugin enabled Show/hide AI buttons on all PMM dashboards
OpenAI API Key Your sk-... key from platform.openai.com
Include Data Table Read actual metric values from Inspect → Data and include them in the prompt
Debug Mode Show the prompt + screenshot instead of calling OpenAI
Max tokens GPT-4o response length limit (200–16 000, default 800)

How it works

User clicks AI button
        │
        ▼
content.js opens Grafana Inspect → Data tab
        │  (Grafana executes real queries; interceptor.js captures PromQL)
        │  (content.js reads the Data table if "Include Data" is on)
        ▼
content.js captures panel bounding rect + dashboard time range
        │
        ▼
background.js takes a tab screenshot → crops to panel bounds (OffscreenCanvas)
        │
        ▼
background.js builds a prompt:
   Panel name + time range
   + PromQL queries (with expanded variables)
   + Database type inferred from metric prefixes
   + Data table values (optional)
        │
        ▼
background.js calls OpenAI GPT-4o Vision API
        │
        ▼
content.js renders the response in a modal overlay

Architecture

File World Role
interceptor.js MAIN (page context) Wraps window.fetch to intercept /api/ds/query calls; forwards query expressions and time range via postMessage
content.js ISOLATED Injects AI buttons; orchestrates Inspect drawer navigation; reads data table; shows modal UI
background.js Service Worker Takes screenshots; crops images; builds prompts; calls OpenAI API
popup.html/js Extension popup Settings UI
styles.css Injected CSS Modal and button styles

Requirements


Privacy, Security & Cost

The extension is designed around the principle that your data never leaves your control.

Your own API key — by design. The extension uses your personal OpenAI API key rather than a shared backend service. This means:

  • No usage data, queries, or screenshots pass through any intermediary server
  • You have full visibility into what is sent via your OpenAI usage dashboard
  • The key is stored locally in chrome.storage.sync (your Chrome profile only) and is sent exclusively to https://api.openai.com

Cost. Each analysis call uses GPT-4o with a screenshot + prompt. A typical request costs around $0.01. A dollar's worth of credits is enough to explore most of your PMM dashboards comfortably.

What is and isn't sent.

Sent to OpenAI Never sent anywhere
Cropped screenshot of the clicked panel Full page screenshots
PromQL queries for that panel Dashboard names or URLs
Metric values from the data table (if enabled) PMM credentials or session cookies
Dashboard time range Any other browser data

The extension has no analytics, no telemetry, and no backend of its own.


PMM Resources


Contributing

Contributions are welcome! Please read CONTRIBUTING.md before submitting a pull request.


License

MIT © Percona

About

Chrome extension that adds AI-powered chart analysis to Percona Monitoring and Management (PMM) dashboards using OpenAI GPT-4o Vision

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages