|NO.Z.00344|——————————|CloudNative|——|KuberNetes&運維.V61|-----------------------------------------------------------|Prometheus.v03|Micrometer.v03|配置secrets|
阿新 • • 發佈:2022-04-01
[CloudNative:KuberNetes&運維.V61] [Applications.KuberNetes] [|DevOps|k8s|k8s運維|**3節點.V1**|Micrometer|Prometheus監控JVM|服務發現|]
一、通過Chrome訪問配置
二、配置secrets:additional-scrape-configs### --- 通過Chrome訪問驗證euraka:http://192.168.1.11:18761/服務是否啟動 ~~~ ——>這個spring Eureka:只是一個註冊中心:把它當做一個spring-boot專案來監控 ~~~ 檢視它的監控資料:http://192.168.1.11:18761/actuator/prometheus:監控資料已經獲取到了 ~~~ 若是euraka是在k8s裡面的,它就會有service地址,可以直接使用service地址去監控 ~~~ 若是在叢集外部:可以建一個service地址去監控,也可以通過IP+埠號的形式去連線
### --- 配置secrets:additional-scrape-configs
~~~ ——>http://krm.test.com/——>secrets——>Namespace:monitoring
~~~ ——>additional-scrape-configs——>編輯
~~~ ——>prometheus-additional-config:新增下面配置引數——>Update
三、等待Prometheus重新整理即可~~~ # 配置開頭新增如下引數 - job_name: 'jvm-prometheus' scheme: http metrics_path: '/actuator/prometheus' static_configs: - targets: ['192.168.1.11:18761'] # targets寫spring euraka地址 - job_name: 'blackbox' # 此行上面新增內容
### --- 等待Prometheus重新整理即可
~~~ ——>http://prom.test.com/——>status——>Targets——>已獲取監控資訊——>
~~~ ——>status——>Configuration:檢視到JVM配置引數——>
~~~ ——>Alerts——>Enable query history:Jvm——>可以檢視到相應監控資訊——>END
四、Job該儀表盤沒有使用標籤來區分不同的應用程式,
### --- Job該儀表盤沒有使用標籤來區分不同的應用程式, ~~~ 而是使用稱為應用於每個指標的通用標籤application;在 Spring Boot 設定中,示例如下配置:
### --- JVM設定的指標通用標籤:label
label:application="cloud-eureka"
### --- label引數配置:
~~~ # 引數地址:https://grafana.com/grafana/dashboards/4701
@Bean
MeterRegistryCustomizer<MeterRegistry> configurer(
@Value("${spring.application.name}") String applicationName) {
return (registry) -> registry.config().commonTags("application", applicationName);
}
~~~ # 或者因為1.1.0具有屬性的
management.metrics.tags.application=${spring.application.name}
### --- 加入指標通用標籤
~~~ 在public下面新增即可
[root@k8s-master01 spring-cloud-eureka]# cat src/main/java/com/zb/SpringCloudEurekaApplication.java
package com.zb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class SpringCloudEurekaApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudEurekaApplication.class, args);
}
}
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)