> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lwops.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 2.14. dubbo

# 开启 Metrics 数据采集并上报到 Prometheus

Dubbo 支持通过两种方式对外暴露 Metrics 指标给 Prometheus，具体可参见dubbo-samples-metrics-spring-boot.zip或 [官方文档配置说明](https://github.com/apache/dubbo-samples/blob/master/4-governance/dubbo-samples-metrics-spring-boot)。 - Spring-boot-actuator，即通过标准的 Spring boot actuator 端口在特定的 endpoint 将 Dubbo 监控指标暴露出去 - dubbo qos，即通过 Dubbo 内置的 qos 端口将 Dubbo 监控指标暴露出去

本示例中，我们使用 spring-boot-actuator 的方式透出 Dubbo 指标信息，请注意本示例**使用的 Dubbo 版本必须为 3.2.0-beta.6 以上**。

### Metrics 相关示例配置（**以下配置实施工程师请勿操作**，需由客户开发工程师修改程序代码埋点操作）

```text theme={null}
# ......
management.server.port=18081
management.endpoints.web.base-path=/management
dubbo.metrics.protocol=prometheus

# 如果不使用 spring-boot-actuator，可使用下面配置开启 qos 配置
# dubbo.metrics.enable-jvm-metrics=true
# dubbo.application.qos-port=22222
# dubbo.application.qos-accept-foreign-ip=true
```

启动 MetricsApplication，测试访问监控指标：[http://hostaddress:18081/management/prometheus](http://hostaddress:18081/management/prometheus)

# python模块按照

> 安装在server或proxy服务器

````shell theme={null}
# tar -vxf prometheus_client-0.21.0.tar.gz
# cd prometheus_client-0.21.0
# python3 setup.py install
# python3 -m pip list | grep prometheus
```
 # 监控脚本解压
 ```shell
[root@c-wst externalscripts]# pwd
/itops/zabbix/share/zabbix/externalscripts
[root@c-wst externalscripts]#
[root@c-wst externalscripts]# ll
-rw-r--r--. 1 root root 11415 Sep 29 15:37 dubboConsumer.py
-rw-r--r--. 1 root root 11491 Sep 29 15:37 dubboProvider.py
-rw-r--r--. 1 root root   518 Sep 29 15:40 getdubboConsumer.py
-rw-r--r--. 1 root root   522 Sep 29 15:39 getdubboProvider.py
-rw-r--r--. 1 root root 4714  Sep 24 10:10 zbxsend.py
````

迁移模板添加监控 <img src="https://lwweb.oss-cn-shenzhen.aliyuncs.com/docs/images/yuque/dubbo/image-01.png" alt="image.png" />

![image.png](https://lwweb.oss-cn-shenzhen.aliyuncs.com/docs/images/yuque/dubbo/image-02.png)
