Skip to content

Commit

Permalink
1.增加文档说明信息
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxuzxx committed Nov 8, 2021
1 parent 37d59dd commit 876b3eb
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,25 @@ scrape_configs:
action: replace
```
## Prometheus修改同上
## Prometheus修改同上
# 备注
## Nacos添加Metadata的处理
```java
//下面这段代码可以朝向Nacos添加如下属性:
//log.path:本服务的日志路径
//startup.time:服务启动时间
//注意:nacos-consul-adapter-go会替换所有Metadata当中的 . 为下划线,所以最后的结果就是:log_path startup_time
//之所以使用 . 是为了迎合nacos的习惯,但是使用下划线是为了迎合prometheus标签的规范,注意不要有大写
@Bean
public NacosDiscoveryProperties nacosProperties() {
NacosDiscoveryProperties nacosDiscoveryProperties = new NacosDiscoveryProperties();
Map<String, String> metadata = nacosDiscoveryProperties.getMetadata();
metadata.put("startup.time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date()));
String logPath = System.getProperty("user.dir") + "/logs/*";
metadata.put("log.path", logPath);
log.info("Register Nacos Metadata information is:{}!", JSON.toJSONString(metadata));
return nacosDiscoveryProperties;
}
```

0 comments on commit 876b3eb

Please sign in to comment.