public static void main(String[] args) throws Exception { InetAddress ia = InetAddress.getLocalHost(); Map<String,String> map = new HashMap<>(); map.put("serverip",ia.getHostAddress()); map.put("interfacename","http://ip:8194/gw/ent/hot"); map.put("instance",ia.getHostName()); /** * 推送指标到pushgetway,prometheus从pushgetway中pull */ PushGateway pg = new PushGateway("ip:9091"); Gauge gauge = Gauge.build().name("springboot_push").help("服务接口监听").register(); gauge.set(0); pg.push(gauge, "springboot_push",map); }
<dependency> <groupId>org.springframework.boot<\/groupId> <artifactId>spring-boot-starter-web<\/artifactId> <\/dependency> <dependency> <groupId>io.micrometer<\/groupId> <artifactId>micrometer-registry-prometheus<\/artifactId> <\/dependency> <dependency> <groupId>org.springframework.boot<\/groupId> <artifactId>spring-boot-starter-actuator<\/artifactId> <\/dependency>
标签:map,demo,boot,put,prometheus,push,ia,推送 From: https://www.cnblogs.com/goPush/p/17621258.html