Dubbo:搭建监控中心(dubbo-monitor-simple)

本文深入解析Dubbo-Monitor的功能,展示如何通过Dubbo-Monitor统计服务调用次数和时间,配置并启动监控中心,以及如何在服务提供者和消费者中进行监控配置。同时,介绍了Dubbo-Monitor的图表显示问题及解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Dubbo-Monitor介绍

  1. Dubbo-Monitor主要用来统计服务的调用次数和调用时间,服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心,监控中心则使用数据绘制图表来显示。
  2. Dubbo-Monitor挂掉不会影响到Consumer和Provider之间的调用,所以用于生产环境不会有风险。 
  3.  配置好了之后可以结合admin管理后台使用,可以清晰的看到服务的访问记录、成功次数、失败次数等…..
  4. Simple Monitor采用磁盘存储统计信息,请注意安装机器的磁盘限制,如果要集群,建议用mount共享磁盘。 

Dubbo-Monitor安装和配置

下载dubbo-monitor-simple

官网地址:https://github.com/apache/incubator-dubbo/tree/2.5.x/dubbo-simple

配置dubbo.properties

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

dubbo.container=log4j,spring,registry,jetty
dubbo.application.name=simple-monitor
dubbo.application.owner=
#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://192.168.60.207:2181
#dubbo.registry.address=redis://127.0.0.1:6379
#dubbo.registry.address=dubbo://127.0.0.1:9090
# 是Monitor提供的远程服务监听端口,服务提供者和消费者会调用这个端口提供的服务,发送统计信息到Monitor
dubbo.protocol.port=7070
# 设置Jetty容器的监听地址,类似于Tomcat的8080端口,这里设置为8099
dubbo.jetty.port=8099
# 存放图表的位置
dubbo.jetty.directory=${user.home}/monitor
#dubbo.charts.directory=${dubbo.jetty.directory}/charts
dubbo.charts.directory=${user.home}/monitor/charts
dubbo.statistics.directory=${user.home}/monitor/statistics
# 日志
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN

监控服务提供方和消费方

需要在服务提供方和消费方增加连接配置中心的配置来实现监控

<dubbo:monitor/>监控中心配置用于配置连接监控中心相关信息,可选

在服务提供方和消费方的配置文件中添加如下代码

  <!-- 连接监控中心 -->
    <dubbo:monitor protocol="registry"></dubbo:monitor>
    <!-- 
      <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor> 
    -->

示例(dubbo-demo-provider.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- provider's application name, used for tracing dependency relationship -->
    <dubbo:application name="demo-provider"/>

    <!-- use multicast registry center to export service -->
    <!--<dubbo:registry address="multicast://224.5.6.7:1234"/>-->
    <dubbo:registry protocol="zookeeper" address="192.168.60.207:2181" />

    <!-- use dubbo protocol to export service on port 20880 -->
    <dubbo:protocol name="dubbo" port="20880"/>

    <!-- service implementation, as same as regular local bean -->
    <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl"/>

    <!-- declare the service interface to be exported -->
    <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"/>

    <!--监控中心-->
    <dubbo:monitor protocol="registry"/>

</beans>

 

启动Dubbo-Monitor

进入\dubbo-monitor-simple-2.5.10-assembly\dubbo-monitor-simple-2.5.10\bin

启动:

./bin/start.sh  (windows系统是/bin/start.bat)

Dubbo-Monitor常用命令

启动:

./bin/start.sh  (windows系统是/bin/start.bat)

停止:

./bin/stop.sh

重启:

./bin/restart.sh

调试:

./bin/start.sh debug

系统状态:

./bin/dump.sh

总控入口:

./bin/server.sh start
./bin/server.sh stop
./bin/server.sh restart
./bin/server.sh debug
./bin/server.sh dump

Dubbo-Monitor

访问 http://192.168.60.207:8099

可以服务查看,应用程序查看,调用情况统计;

可以看到服务提供的名称(Service Name),配置的提供者的名称(Application),提供者的数量(Providers(2)),消费者的数量( Consumers(3)),统计(Statistics) 和 图表(Charts)。

    1.点击 Providers(1),可以看到提供者的详细信息,即提供者的URL

  2.点击Consumers(1),可以看到消费者的详细信息,即消费者的URL

  3.点击Statistics,成功的次数,失败的次数,平均花费的时间,最大花费的时间,并发的次数。

  4.点击Charts,可以看到请求和响应的图表。
 

 

Dubbo-Monitor图表不显示

1.可能不会自动创建monitor文件夹,需要在${user.home}目录下创建monitor目录

2.需要在服务端配置<dubbo:monitor protocol="registry"/>

3.在消费端配置<dubbo:monitor protocol="registry"/>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

萤火AI百宝箱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值