Integrating Databrain with Grafana Cloud
This guide explains how to send OpenTelemetry traces, metrics, and logs from your self-hosted Databrain instance to Grafana Cloud.Prerequisites
- Databrain self-hosted version with OpenTelemetry support
- Grafana Cloud account (free tier available)
- Grafana Cloud API token
What You’ll Get
Grafana Cloud provides three integrated observability products:| Product | Purpose | What It Shows |
|---|---|---|
| Grafana Tempo | Distributed tracing | Request traces with spans and timing |
| Grafana Loki | Log aggregation | Structured logs with trace correlation |
| Prometheus | Metrics | Request rates, latency histograms, error rates |
Configuration
1. Get Your Grafana Cloud Credentials
- Log into Grafana Cloud
- Navigate to your stack (e.g.,
yourstack.grafana.net) - Go to Connections → Add new connection → OpenTelemetry
- Note the following:
- Tempo endpoint:
tempo-<region>.grafana.net:443 - Prometheus endpoint:
prometheus-<region>.grafana.net:443 - Loki endpoint:
logs-<region>.grafana.net - Instance ID: Your unique instance identifier
- API Token: Generate one under Access Policies
- Tempo endpoint:
2. Using Grafana Alloy (Recommended)
Grafana Alloy is the easiest way to send telemetry to Grafana Cloud. It replaces the generic OpenTelemetry Collector.Docker Compose Configuration
Alloy Configuration
Createalloy-config.alloy:
3. Alternative: Direct OTLP to Grafana Cloud
You can also send data directly without Alloy (less flexible):4. Kubernetes with Grafana Agent
For Kubernetes, use the Grafana Agent Operator:Verification
1. Check Alloy Status
Visit the Alloy UI:http://localhost:12345
You should see:
- Active OTLP receivers
- Successful exports to Grafana Cloud
2. Generate Test Traffic
3. View in Grafana Cloud
Tempo (Traces)
- Go to Explore in Grafana
- Select Tempo as the data source
- Query:
{service.name="databrain-api"} - You should see traces within 1-2 minutes
Prometheus (Metrics)
- Go to Explore
- Select Prometheus as the data source
- Query:
rate(http_server_duration_milliseconds_count{service_name="databrain-api"}[5m])
Loki (Logs)
- Go to Explore
- Select Loki as the data source
- Query:
{service_name="databrain-api"} - Click on any log to see correlated traces
Creating Dashboards
Pre-built Dashboard
Import the OpenTelemetry APM dashboard:- Go to Dashboards → New → Import
- Use dashboard ID:
19419(OpenTelemetry APM) - Select your Tempo and Prometheus data sources
- Filter by
service_name = databrain-api
Custom Dashboard Example
Create a new dashboard with these panels: Request Rate:Setting Up Alerts
Grafana Alerting
Create alert rules in Grafana: High Error Rate:- Go to Alerting → Alert rules → New alert rule
- Query:
- Threshold: Alert when value > 0.05 (5% errors)
- Add notification channel (email, Slack, PagerDuty)
Trace Exemplars
Link metrics to traces using exemplars:LogQL Queries
Use LogQL to query structured logs in Loki: All errors:Troubleshooting
| Issue | Solution |
|---|---|
| No data in Grafana Cloud | Check Alloy logs: docker logs grafana-alloy |
| 401 Unauthorized | Verify Instance ID and API Key are correct |
| Connection timeout | Check firewall allows outbound HTTPS (443) |
| Missing traces in Tempo | Wait 2-3 minutes for ingestion delay |
| High costs | Implement sampling in Alloy configuration |
Debug Alloy
Check Alloy logs:Test Connectivity
Cost Optimization
Grafana Cloud free tier includes:- Tempo: 50 GB traces/month
- Loki: 50 GB logs/month
- Prometheus: 10k active series
- Sampling: Sample traces in Alloy
- Filter low-value logs: Exclude health checks
- Set retention: Adjust in Grafana Cloud settings
- Tempo: Default 7 days
- Loki: Default 30 days
- Prometheus: Default 13 months
Best Practices
1. Use Service Graph
Enable service graph in Tempo to visualize service dependencies:- Go to Tempo → Service Graph
- View request flow between services
- Identify bottlenecks and failures
2. Correlate Logs with Traces
When logging, Winston automatically includes trace context:3. Use Grafana Oncall
Integrate with Grafana Oncall for advanced alert management:- On-call rotations
- Escalation policies
- Alert grouping and deduplication
Support
- Grafana Community: https://community.grafana.com/
- Grafana Cloud Support: Available for paid plans
- Documentation: https://grafana.com/docs/grafana-cloud/
- Alloy Docs: https://grafana.com/docs/alloy/

