Dubbo-Go supports runtime metrics collection and integration with Prometheus + Grafana to enable full observability for microservices.
This example supports two monitoring modes:
Example source code:
https://github.com/apache/dubbo-go-samples/tree/main/metrics
Dubbo-Go Application ---> Prometheus ---> Grafana
(exposes /metrics or /prometheus endpoint)
Prometheus actively scrapes metrics from Dubbo-Go applications.
Dubbo-Go Application ---> Pushgateway ---> Prometheus ---> Grafana
Applications push metrics to Pushgateway. Prometheus scrapes Pushgateway.
⚠️ Note:
Pushgateway is designed for short-lived jobs (batch / cron). It is not recommended for long-running services.
| Component | Port | Description |
|---|---|---|
| Grafana | 3000 | Metrics visualization dashboard |
| Prometheus | 9090 | Metrics storage and query engine |
| Pushgateway | 9091 | Receives pushed metrics |
| go-server | — | Dubbo-Go Provider example |
| go-client | — | Dubbo-Go Consumer example |
Navigate to:
cd metrics/prometheus_grafana
Start services:
docker-compose up -d
Access:
Both client and server share the same configuration:
export ZK_ADDRESS="127.0.0.1:2181"
# Required for Push mode
export PUSHGATEWAY_URL="127.0.0.1:9091"
export JOB_NAME="dubbo-service"
# Optional
export PUSHGATEWAY_USER="username"
export PUSHGATEWAY_PASS="1234"
go run ./go-server/cmd/main.go
go run ./go-client/cmd/main.go
go run ./go-client/cmd/main.go --push=false
go run ./go-server/cmd/main.go --push=false
Open:
http://localhost:9091/metrics
Open:
http://localhost:<app_port>/prometheus
admin / adminHome → Connections → Data sources
http://host.docker.internal:9090
Note:
host.docker.internalallows Docker containers to access the host network. Replace with your actual IP if necessary.
Home → Dashboards → New → Import
Upload grafana.json
OR paste the JSON content
Select the Prometheus data source
Click Import
You will see:
Metrics update dynamically as the client continuously calls the server.
Pushgateway does not automatically delete old metrics.
If a job stops:
Mechanism:
job_pushed_at_secondsTool:
tools/pgw-cleaner
Purpose:
Check:
dubbo_consumer_requests_succeed_total
returns results
Replace it with your actual host IP:
prometheus_pull.ymlRecommended:
kube-prometheus https://github.com/prometheus-operator/kube-prometheus
Create dubboPodMonitor.yaml:
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: dubbo-pod-monitor
namespace: monitoring
spec:
namespaceSelector:
matchNames:
- dubbo-system
selector:
matchLabels:
app-type: dubbo
podMetricsEndpoints:
- port: metrics
path: /prometheus
kubectl apply -f Deployment.yaml
Visit:
http://<prometheus-nodeport>/targets
Ensure your pods show:
UP
| Scenario | Recommended Mode |
|---|---|
| Long-running services | Pull |
| Short-lived jobs | Push |
| Kubernetes | Pull + PodMonitor |
| Pushgateway usage | Use pgw-cleaner |
Dubbo-Go provides:
With this setup, you can build a complete Dubbo-Go observability system.