Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 使用Metrics模块进行数据采集然后暴漏数据给普罗米修斯监控
Dubbo使用开源的[Dubbo Metrics](https://github.com/alibaba/metrics)进行数据埋点,并且通过服务暴露,使用的时候,首先需要进行配置:

* 依赖(其中Dubbo版本在3.2.0及以后)
```xml
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
</dependency>

```
* 服务端
```xml
<dubbo:metrics protocol="prometheus">
<dubbo:aggregation enabled="true"/>
</dubbo:metrics>

```

* 客户端
```xml
<dubbo:metrics protocol="prometheus">
<dubbo:aggregation enabled="true"/>
</dubbo:metrics>

```
先启动服务端,然后启动客户端,
提供端监控指标:http://localhost:20888/metrics
消费端监控指标:http://localhost:20889/metrics


可观测性文档如下链接:
[https://cn.dubbo.apache.org/zh-cn/overview/tasks/observability/metrics-start/](https://cn.dubbo.apache.org/zh-cn/overview/tasks/observability/metrics-start/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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.

services:
metrics-prometheus-provider-springboot3:
type: app
basedir: dubbo-samples-metrics-prometheus-provider-springboot3
mainClass: org.apache.dubbo.samples.metrics.prometheus.provider.MetricsProvider

metrics-prometheus-consumer-springboot3:
type: test
basedir: dubbo-samples-metrics-prometheus-consumer-springboot3
tests:
- "**/*IT.class"
systemProps:
- zookeeper.address=metrics-prometheus-provider-springboot3
- zookeeper.port=2181
- dubbo.address=metrics-prometheus-provider-springboot3
- dubbo.port=20880
waitPortsBeforeRun:
- metrics-prometheus-provider-springboot3:2181
- metrics-prometheus-provider-springboot3:20880
depends_on:
- metrics-prometheus-provider-springboot3
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
#
# 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.
#


# Supported component versions of the test case

# Spring app
dubbo.version=[ >= 3.3.7 ]
spring.version=6.*
java.version= [>= 17]
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!--
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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-samples-metrics-prometheus-springboot3</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>dubbo-samples-metrics-prometheus-consumer-springboot3</artifactId>
<name>dubbo-samples-metrics-prometheus-consumer-springboot3</name>

<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-samples-metrics-prometheus-interface-springboot3</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>4.1.12.1</version>
</dependency>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.10.5</version>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metrics-prometheus</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.14</version>
<configuration>
<mainClass>org.apache.dubbo.samples.metrics.prometheus.consumer.MetricsConsumer</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-jar-file</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="target/dubbo-samples-metrics-prometheus-consumer-springboot3-1.0-SNAPSHOT.jar" tofile="target/consumer.jar"></copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading