首頁>技術>

前面講了安裝jenkins exporter方式監控jenkins,但是grafana支援較少。

接下來,我們用Jenkins plugin的方式監控,這個方法部署簡單,然後grafana支援比較完整。

首先,需要安裝Jenkins,參照上一個文件完成。

1.安裝Jenkins Plugin

開啟外掛管理介面

搜尋Prometheus外掛

安裝完成重啟生效

2.檢查外掛配置

檢查配置

儲存配置

設定完成後重啟Jenkins服務,並且訪問jenkins的url檢視指標情況

訪問 http://192.168.0.107:8080/prometheus/

# HELP jvm_threads_current Current thread count of a JVM# TYPE jvm_threads_current gaugejvm_threads_current 34.0# HELP jvm_threads_daemon Daemon thread count of a JVM# TYPE jvm_threads_daemon gaugejvm_threads_daemon 16.0# HELP jvm_threads_peak Peak thread count of a JVM# TYPE jvm_threads_peak gaugejvm_threads_peak 47.0# HELP jvm_threads_started_total Started thread count of a JVM# TYPE jvm_threads_started_total counterjvm_threads_started_total 73.0# HELP jvm_threads_deadlocked Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers# TYPE jvm_threads_deadlocked gaugejvm_threads_deadlocked 0.0
3. Prometheus監控Jenkins
Prometheus配置檔案/etc/prometheus/prometheus.yml,新增如下內容:scrape_configs:    - job_name: "jenkins"      metrics_path: "/prometheus/"      scheme: http      static_configs:      - targets: ['192.168.0.107:8080']這裡如果用的是tls, 用下面的配置scrape_configs:  - job_name: 'jenkins'    scheme: https # change to http if don't you have https    metrics_path: '/prometheus/'    static_configs:      - targets: ['192.168.0.107:443'] # Jenkins host and port you serve    tls_config:      insecure_skip_verify: true重啟Prometheussystemctl restart prometheus

檢查Prometheus Target

Prometheus Target

4.Grafana模板

這裡我使用模板 https://grafana.com/grafana/dashboards/9964

匯入模板

Jenkins監控

至此,完成Prometheus對Jenkins的監控。

推薦此方法。

23
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • SpringCloud實戰:從公共模組搭建一套完整微服務架構