BlueXIII's Blog

热爱技术,持续学习

0%

Prometheus改造

参考

helm方式安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 安装
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/prometheus --namespace prometheus --create-namespace

# UI
http://prometheus-server.prometheus:80 # DNS
http://10.193.36.41:30022 # NodePort


prometheus-prometheus-node-exporter.prometheus
node-exporter.kubesphere-monitoring-system
prometheus-k8s.kubesphere-monitoring-system

# 打开prometheus
kubectl port-forward --namespace kubesphere-monitoring-system service/prometheus-k8s 9090:9090
open http://localhost:9090

pom.xml配置

1
2
3
4
5
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.3.6</version>
</dependency>

Nacos配置

1
2
3
4
5
management:
endpoints:
web:
exposure:
include: 'health,prometheus'

临时测试

1
2
3
4
5
6
7
8
9
10
11
12
# 本机测试
cd /Users/bluexiii/Documents/code/devops/dubhe-app/dubhe-metadata/dubhe-metadata-biz/target
export NACOS_HOST=10.193.36.41
export NACOS_PORT=30101
export NACOS_USERNAME=nacos
export NACOS_PASSWORD=nacos
java -jar dubhe-metadata-biz.jar
open http://localhost:8600/actuator/prometheus

# K8S测试 dubhe-metadata.dubhe-dev
kubectl port-forward --namespace dubhe-dev service/dubhe-metadata 8600:8600
open http://localhost:8600/actuator/prometheus

prometheus配置

1
2
3
4
5
6
7
8
9
10
- job_name: "应用详细指标"
metrics_path: "/actuator/prometheus"
static_configs:
- targets:
[
"dubhe-metadata.dubhe-dev:8600",
"dubhe-quality.dubhe-dev:8604"
]
labels:
application: "开发环境"

Grafana 配置

复用Loki的Grafana:
http://10.193.36.41:30016