grafana-bridge
v0.1.2
Published
Local HTTP proxy that bridges CLI tools to Grafana Cloud instances behind SSO
Maintainers
Readme
grafana-bridge
Local HTTP proxy that bridges CLI tools, scripts, and AI-powered dashboards to Grafana Cloud instances behind SSO (Okta, Google, Azure AD, etc.).
Install
npx grafana-bridge --grafana-url https://mycompany.grafana.netOr install globally:
npm install -g grafana-bridge
grafana-bridge -u https://mycompany.grafana.netRequires Node.js >= 18. Playwright's Chromium is installed automatically via postinstall.
Usage
# Start the proxy
grafana-bridge -u https://mycompany.grafana.net
# With custom port
grafana-bridge -u https://mycompany.grafana.net -p 8080
# With verbose logging
grafana-bridge -u https://mycompany.grafana.net --verbose
# With config file
grafana-bridge -c ./my-config.yamlOnce running, any HTTP client can query Grafana through the local proxy:
# List datasources
curl http://localhost:4000/api/datasources
# Query Loki
curl -X POST http://localhost:4000/api/ds/query \
-H "Content-Type: application/json" \
-d '{"queries": [...]}'
# Search dashboards
curl http://localhost:4000/api/search
# Health check
curl http://localhost:4000/health
# Trigger proactive authentication
curl -X POST http://localhost:4000/authConfiguration
CLI flags
grafana-bridge [options]
-u, --grafana-url <url> Grafana instance URL (required)
-p, --port <number> Local proxy port (default: 4000)
-c, --config <path> Path to config file
--login-timeout <ms> SSO login timeout (default: 120000)
--session-file <path> Session persistence file path
--verbose Enable debug logging
-v, --version
-h, --helpConfig file
Place at ~/.config/grafana-bridge/config.yaml or ./grafana-bridge.yaml:
grafanaUrl: 'https://mycompany.grafana.net'
port: 4000
loginTimeoutMs: 120000
sessionFile: '~/.config/grafana-bridge/session.json'
verbose: falseEnvironment variables
GRAFANA_BRIDGE_URL— Grafana instance URLGRAFANA_BRIDGE_PORT— Local proxy port
Precedence
CLI flags > environment variables > config file > defaults
How it works
- All requests are forwarded to Grafana with session cookies injected (if a session exists)
- If Grafana returns 401, a Chromium browser opens for SSO login (lazy authentication)
- After successful login,
grafana_sessionandgrafana_session_expirycookies are captured - Session is cached in memory and persisted to
~/.config/grafana-bridge/session.json - Subsequent requests reuse the cached session — the browser only opens when Grafana rejects the session
- Re-authentication retries up to 3 times before returning 401 to the client
- Persistent browser context means SSO IdP cookies are remembered — subsequent re-auths only need Grafana consent, not full IdP login
POST /authcan be used to proactively trigger authentication before any request
License
MIT
