Technical note

Prometheus改造

参考

helm方式安装

# 安装
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配置

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
  <version>1.3.6</version>
</dependency>

Nacos配置

management:
  endpoints:
    web:
      exposure:
        include: 'health,prometheus'

临时测试

# 本机测试
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配置

    - 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