···11+# Grafana Cloud Configuration for wisp.place monorepo
22+# Copy these variables to your .env file to enable Grafana integration
33+# The observability package will automatically pick up these environment variables
44+55+# ============================================================================
66+# Grafana Loki (for logs)
77+# ============================================================================
88+# Get this from your Grafana Cloud portal under Loki → Details
99+# Example: https://logs-prod-012.grafana.net
1010+GRAFANA_LOKI_URL=https://logs-prod-xxx.grafana.net
1111+1212+# Authentication Option 1: Bearer Token (Grafana Cloud)
1313+GRAFANA_LOKI_TOKEN=glc_xxx
1414+1515+# Authentication Option 2: Username/Password (Self-hosted or some Grafana setups)
1616+# GRAFANA_LOKI_USERNAME=your-username
1717+# GRAFANA_LOKI_PASSWORD=your-password
1818+1919+# ============================================================================
2020+# Grafana Prometheus (for metrics)
2121+# ============================================================================
2222+# Get this from your Grafana Cloud portal under Prometheus → Details
2323+# Note: You need to add /api/prom to the base URL for OTLP export
2424+# Example: https://prometheus-prod-10-prod-us-central-0.grafana.net/api/prom
2525+GRAFANA_PROMETHEUS_URL=https://prometheus-prod-xxx.grafana.net/api/prom
2626+2727+# Authentication Option 1: Bearer Token (Grafana Cloud)
2828+GRAFANA_PROMETHEUS_TOKEN=glc_xxx
2929+3030+# Authentication Option 2: Username/Password (Self-hosted or some Grafana setups)
3131+# GRAFANA_PROMETHEUS_USERNAME=your-username
3232+# GRAFANA_PROMETHEUS_PASSWORD=your-password
3333+3434+# ============================================================================
3535+# Optional Configuration
3636+# ============================================================================
3737+# These will be used by both main-app and hosting-service if not overridden
3838+3939+# Service metadata (optional - defaults are provided in code)
4040+# SERVICE_NAME=wisp-app
4141+# SERVICE_VERSION=1.0.0
4242+4343+# Batching configuration (optional)
4444+# GRAFANA_BATCH_SIZE=100 # Flush after this many entries
4545+# GRAFANA_FLUSH_INTERVAL=5000 # Flush every 5 seconds
4646+4747+# ============================================================================
4848+# How to get these values:
4949+# ============================================================================
5050+# 1. Sign up for Grafana Cloud at https://grafana.com/
5151+# 2. Go to your Grafana Cloud portal
5252+# 3. For Loki:
5353+# - Navigate to "Connections" → "Loki"
5454+# - Click "Details"
5555+# - Copy the Push endpoint URL (without /loki/api/v1/push)
5656+# - Create an API token with push permissions
5757+# 4. For Prometheus:
5858+# - Navigate to "Connections" → "Prometheus"
5959+# - Click "Details"
6060+# - Copy the Remote Write endpoint (add /api/prom for OTLP)
6161+# - Create an API token with write permissions
6262+6363+# ============================================================================
6464+# Testing the integration:
6565+# ============================================================================
6666+# 1. Copy this file's contents to your .env file
6767+# 2. Fill in the actual values
6868+# 3. Restart your services (main-app and hosting-service)
6969+# 4. Check your Grafana Cloud dashboard for incoming data
7070+# 5. Use Grafana Explore to query:
7171+# - Loki: {job="main-app"} or {job="hosting-service"}
7272+# - Prometheus: http_requests_total{service="main-app"}
+7-1
apps/hosting-service/src/index.ts
···11import app from './server';
22import { serve } from '@hono/node-server';
33import { FirehoseWorker } from './lib/firehose';
44-import { createLogger } from '@wisp/observability';
44+import { createLogger, initializeGrafanaExporters } from '@wisp/observability';
55import { mkdirSync, existsSync } from 'fs';
66import { backfillCache } from './lib/backfill';
77import { startDomainCacheCleanup, stopDomainCacheCleanup, setCacheOnlyMode } from './lib/db';
88+99+// Initialize Grafana exporters if configured
1010+initializeGrafanaExporters({
1111+ serviceName: 'hosting-service',
1212+ serviceVersion: '1.0.0'
1313+});
814915const logger = createLogger('hosting-service');
1016
+7-1
apps/main-app/src/index.ts
···2020import { siteRoutes } from './routes/site'
2121import { csrfProtection } from './lib/csrf'
2222import { DNSVerificationWorker } from './lib/dns-verification-worker'
2323-import { createLogger, logCollector } from '@wisp/observability'
2323+import { createLogger, logCollector, initializeGrafanaExporters } from '@wisp/observability'
2424import { observabilityMiddleware } from '@wisp/observability/middleware/elysia'
2525import { promptAdminSetup } from './lib/admin-auth'
2626import { adminRoutes } from './routes/admin'
2727+2828+// Initialize Grafana exporters if configured
2929+initializeGrafanaExporters({
3030+ serviceName: 'main-app',
3131+ serviceVersion: '1.0.50'
3232+})
27332834const logger = createLogger('main-app')
2935