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

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

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"/>


目录
相关文章
|
2天前
|
XML 监控 Dubbo
Dubbo怎么配置监控中心
**摘要:** 本文介绍了如何配置Dubbo的简单监控中心。首先,通过添加`&lt;dubbo:monitor protocol=&quot;registry&quot; /&gt;`到配置文件启用监控。接着,修改`dubbo.properties`设置Zookeeper地址。启动监控中心,服务提供者和消费者需添加`monitorEnabled=&quot;true&quot;`以开启监控功能。配置完成后,监控中心的Web界面能展示服务状态和性能指标,助力开发者和运维人员实时监控服务健康。
|
8天前
|
监控 Dubbo 应用服务中间件
DUBBO--基础篇(二)--监控中心
DUBBO--基础篇(二)--监控中心
9 0
|
1月前
|
XML 监控 Dubbo
Dubbo03【管理控制台和监控中心搭建】,Java开发实用必备的几款插件
Dubbo03【管理控制台和监控中心搭建】,Java开发实用必备的几款插件
|
存储 Prometheus 监控
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(1)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(1)
122 3
|
Prometheus 监控 Dubbo
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(5)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(5)
92 1
|
Prometheus 监控 Dubbo
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(6)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(6)
124 0
|
存储 监控 算法
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(4)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(4)
141 0
|
监控 数据可视化 Dubbo
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(7)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(7)
93 0
|
存储 监控 Dubbo
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(2)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(2)
95 1
|
监控 Dubbo 数据可视化
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(3)
带你读《Apache Dubbo微服务开发从入门到精通》——二、 微服务集群监控(3)
150 0