Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
QA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mayi-operation
QA
Commits
f1684ee9
Commit
f1684ee9
authored
Feb 28, 2019
by
ChongmingDu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://code.mayi888.com/operation/QA
parents
8f99f822
f351a453
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
spring boot开启prometheus
+39
-0
No files found.
spring boot开启prometheus
0 → 100644
View file @
f1684ee9
1、天才第一步,commons项目添加prometheus依赖
1、天才第一步,commons项目添加prometheus依赖
<!-- Micrometer Prometheus registry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
2、确保commons的pom.xml 里面actuator有开启
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
3、修改一下com.mayi.core.config.WebMvcConfig
找到configureMessageConverters方法添加如下代码:
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
stringHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
converters.add(stringHttpMessageConverter);
PS:这一步的目的是支持 text/plain,prometheus监控请求响应的content-type为text/plain
4、将/actuator添加到url白名单
5、配置actuator,在commons项目config/system.properties内添加下面代码
management.endpoints.web.exposure.include=*
PS:这一步的目的是加载actuator所有的端点,默认只加载了 info / health,更多配置请百度。
6、以上步骤已经完成配置,下面验证一下是否正常开启。
任意启动一个服务,访问:http://localhost:【端口】/actuator
如图会列出所有actuator支持的端口信息,正常的话可以发现有prometheus的信息。
7、接着访问http://localhost:【端口】/actuator/prometheus
8、很开心的去找杜崇铭吧,后面的事情是他的活
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment