Testing Vitals Locally
This guide will help you test the Vitals extension with a real, local Prometheus instance.
Prerequisites
- Docker: To easily run a Prometheus server.
- Node.js & npm: To build the extension.
- VS Code: To run the extension in debug mode.
Step 1: Start a Local Prometheus Instance
The easiest way to run Prometheus is via Docker. We will also configure it to scrape itself so we have some metrics to view.
Create a file named
prometheus.ymlin a temporary directory (e.g.,tmp/prometheus.yml) with the following content:yamlglobal: scrape_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"]Run the Prometheus container:
bashdocker run -d -p 9090:9090 -v /path/to/your/tmp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus(Replace
/path/to/your/tmp/prometheus.ymlwith the absolute path to the file you created).Alternatively, for a quick test without a custom config (it usually scrapes itself by default):
bashdocker run -d -p 9090:9090 prom/prometheusVerify Prometheus is running by visiting
http://localhost:9090in your browser.
Step 2: Build and Run the Extension
Open the `` project in VS Code.
Install dependencies (if you haven't already):
bashnpm installStart the build watcher for both the extension and the webview:
bashnpm run watchPress F5 (or go to Run and Debug > Run Extension) to open a new VS Code window with the extension loaded.
Step 3: Configure the Extension
In the new Extension Development Host window:
- Open Settings (
Ctrl+,orCmd+,). - Search for
Vitals. - Ensure
Vitals: Prometheus Urlis set tohttp://localhost:9090.
Step 4: Open the Dashboard
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P). - Run the command:
Vitals: Open Vitals. - The dashboard should open in a new panel.
Step 5: Verification
- Metrics: You should see a chart displaying the
upmetric (or whichever query is hardcoded inuseData.ts). It should show a value of1. - Alerts: If you configured any alerts in Prometheus, they will appear in the Alert Panel.
- Logs: The Log Viewer will currently show mock data (as implemented).
Troubleshooting
- "Failed to fetch metrics":
- Ensure Prometheus is running at
http://localhost:9090. - Check if the extension host can access
localhost.
- Ensure Prometheus is running at
- Empty Chart:
- Wait a few seconds for Prometheus to scrape some data.
- Verify the query in
useData.tsis valid (currentlyup).