[feat] Support jenkins monitoring (#3774)

Co-authored-by: Sherlock Yin <sherlock.yin1994@gmail.com>
Co-authored-by: Calvin <zhengqiwei@apache.org>
This commit is contained in:
Duansg
2025-09-21 15:38:14 +08:00
committed by GitHub
co-authored by Sherlock Yin Calvin
parent a8b0c1024d
commit b93613c25e
3 changed files with 849 additions and 0 deletions
@@ -0,0 +1,691 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The monitoring type category: service-application service monitoring, db-database monitoring, custom-custom monitoring.
category: CI/CD
# The monitoring application type name (consistent with the file name)
app: jenkins
# The monitoring i18n name
name:
zh-CN: Jenkins
en-US: Jenkins
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 Jenkins 通用指标进行测量监控。<br>您可以点击 “<i>新建 Jenkins</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: HertzBeat monitors Jenkins generic metrics. You can click "<i>New Jenkins</i>" to configure it, or select "<i>More Actions</i>" to import an existing configuration.
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/jenkins
en-US: https://hertzbeat.apache.org/docs/help/jenkins
# Input params define for monitoring(render web ui by the definition)
params:
# field-param field key
- field: host
# name-param field display i18n name
name:
zh-CN: 目标Host
en-US: Target Host
ja-JP: 目標ホスト
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
# field-param field key
- field: port
# name-param field display i18n name
name:
zh-CN: 端口
en-US: Port
ja-JP: ポート
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[0,65535]'
required: true
defaultValue: 8080
# field-param field key
- field: timeout
# name-param field display i18n name
name:
zh-CN: 查询超时时间
en-US: Query Timeout
ja-JP: クエリタイムアウト
type: number
required: false
# hide param-true or false
hide: true
# default value
defaultValue: 6000
# collect metrics config list
metrics:
# Basic information indicators
- name: jenkins_health_check_score
i18n:
zh-CN: Jenkins 健康检查分值
en-US: Jenkins health check score
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: metric_value
type: 0
i18n:
zh-CN: 分值
en-US: score
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: /prometheus
# http method: GET POST PUT DELETE PATCH
method: GET
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: prometheus
- name: default_jenkins_version_info
i18n:
zh-CN: Jenkins 版本信息
en-US: Jenkins version info
priority: 1
fields:
- field: version
type: 1
i18n:
zh-CN: 版本
en-US: version
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_up
i18n:
zh-CN: Jenkins 是否存活
en-US: Jenkins up
priority: 2
fields:
- field: metric_value
type: 0
i18n:
zh-CN: up
en-US: up
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_uptime
i18n:
zh-CN: Jenkins 运行时间
en-US: Jenkins uptime
priority: 3
fields:
- field: metric_value
type: 0
unit: 'ms'
i18n:
zh-CN: 运行时间
en-US: uptime
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: vm_uptime_milliseconds
i18n:
zh-CN: JVM 运行时间
en-US: JVM uptime
priority: 4
fields:
- field: metric_value
type: 0
unit: 'ms'
i18n:
zh-CN: 运行时间
en-US: uptime
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: system_cpu_load
i18n:
zh-CN: 系统负载
en-US: System load
priority: 5
fields:
- field: metric_value
type: 0
i18n:
zh-CN: value
en-US: value
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: vm_count
i18n:
zh-CN: JVM 线程总数
en-US: Total JVM threads
priority: 6
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 总数
en-US: total
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: vm_memory_heap_max
i18n:
zh-CN: JVM 可使用的最大内存限制
en-US: JVM max heap memory
priority: 7
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 大小
en-US: size
units:
- metric_value=B->MB
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: vm_memory_heap_used
i18n:
zh-CN: JVM 当前使用的内存大小
en-US: JVM heap memory used
priority: 8
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 大小
en-US: size
units:
- metric_value=B->MB
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: jenkins_project_count_value
i18n:
zh-CN: Jenkins 项目数量
en-US: Jenkins project count
priority: 9
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: jenkins_project_enabled_count_value
i18n:
zh-CN: 已启用的项目数量
en-US: Enabled project count
priority: 10
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: jenkins_queue_size_value
i18n:
zh-CN: 构建队列中的任务数量
en-US: Build queue size
priority: 11
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: jenkins_node_online_value
i18n:
zh-CN: 当前在线的构建节点数量
en-US: Online build nodes count
priority: 12
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: jenkins_job_count_value
i18n:
zh-CN: 作业数量
en-US: Job count
priority: 13
fields:
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_executors_available
i18n:
zh-CN: 可用的执行器数量
en-US: Available executors count
priority: 14
fields:
- field: label
type: 1
label: true
i18n:
zh-CN: 标签
en-US: label
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_executors_busy
i18n:
zh-CN: 忙碌的执行器数量
en-US: Busy executors count
priority: 15
fields:
- field: label
type: 1
label: true
i18n:
zh-CN: 标签
en-US: label
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_executors_connecting
i18n:
zh-CN: 正在连接的执行器数量
en-US: Connecting executors count
priority: 16
fields:
- field: label
type: 1
label: true
i18n:
zh-CN: 标签
en-US: label
- field: metric_value
type: 0
i18n:
zh-CN: 数量
en-US: quantity
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_duration_milliseconds_summary_sum
i18n:
zh-CN: 任务构建时长汇总(毫秒)
en-US: Job build duration sum (ms)
priority: 17
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
unit: 'ms'
i18n:
zh-CN: value
en-US: value
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_last_build_duration_milliseconds
i18n:
zh-CN: 最近一次构建的构建时间(毫秒)
en-US: Last build time (ms)
priority: 18
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
unit: 'ms'
i18n:
zh-CN: value
en-US: value
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_success_build_count_total
i18n:
zh-CN: 构建成功次数
en-US: Successful build count
priority: 19
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
i18n:
zh-CN: 总数
en-US: total
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_failed_build_count_total
i18n:
zh-CN: 构建失败次数
en-US: Failed build count
priority: 20
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
i18n:
zh-CN: 总数
en-US: total
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_unstable_build_count_total
i18n:
zh-CN: 不稳定构建次数
en-US: Unstable build count
priority: 21
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
i18n:
zh-CN: 总数
en-US: total
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_total_build_count_total
i18n:
zh-CN: 总构建次数(不包括未构建状态)
en-US: Total builds count (excluding not built)
priority: 22
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
i18n:
zh-CN: 总数
en-US: total
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
- name: default_jenkins_builds_last_build_result_ordinal
i18n:
zh-CN: 任务构建状态(最近一次构建)
en-US: Last build status
priority: 23
fields:
- field: jenkins_job
label: true
i18n:
zh-CN: 任务
en-US: job
type: 1
- field: repo
label: true
i18n:
zh-CN: 仓库
en-US: repo
type: 1
- field: buildable
label: true
i18n:
zh-CN: 是否可构建
en-US: buildable
type: 1
- field: metric_value
i18n:
zh-CN: 状态
en-US: status
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /prometheus
method: GET
parseType: prometheus
+80
View File
@@ -0,0 +1,80 @@
---
id: Jenkins
title: Monitoring Jenkins
sidebar_label: Jenkins
keywords: [ open-source, monitoring system, CI/CD, DevOps, Jenkins monitoring ]
---
> Monitoring of Jenkins' general metrics is performed by invoking the Jenkins Prometheus Plugin.
### Prerequisites
1. Set up Jenkins-related services according to
the [deployment documentation](https://www.jenkins.io/doc/book/installing/).
2. Requires installation of the [plugin](https://www.jenkins.io/doc/book/managing/plugins/) Exposed metric information
has been accessed; refer to the [prometheus-plugin](https://plugins.jenkins.io/prometheus/) for details.
3. The externally exposed metrics endpoint is ```<jenkin_url>/prometheus```. Verify whether you can access the metrics
data.
### Configuration parameters
| Parameter Name | Parameter Help Description |
|-------------------|-----------------------------------------------------------------------------------------------------------------------|
| Target Host | The monitored peer's IPv4, IPv6, or domain name. Note⚠️: Do not include protocol headers (e.g., https://, http://). |
| Port | Jenkins port value, default is 8080. |
| Task Name | The name identifying this monitoring task. The name must be unique. |
| Query Timeout | Set the connection timeout in milliseconds (ms). Default is 3000 ms. |
| Monitoring Cycle | The interval time for periodic data collection, measured in seconds. The minimum configurable interval is 30 seconds. |
| Binding Tags | Used for classifying and managing monitored resources |
| Description Notes | Additional identifiers and descriptive notes for this monitoring task. Users can add notes here. |
### Collection indicators
#### Indicator Set: System Information Indicators
| Indicator name | Unit | Metric Help Description |
|------------------------------|-------------|-----------------------------|
| default_jenkins_uptime | millisecond | Jenkins runtime |
| default_jenkins_up | None | Jenkins still running |
| default_jenkins_version_info | None | Jenkins Version Information |
| jenkins_health_check_score | None | Jenkins Health Check Score |
#### Metric Set: jvm
| Indicator name | Unit | Metric Help Description |
|------------------------|-------------|-------------------------------------------|
| vm_uptime_milliseconds | millisecond | JVM runtime |
| system_cpu_load | None | System Load |
| vm_count | None | Total Number of JVM Threads |
| vm_memory_heap_max | MB | Maximum memory limit available to the JVM |
| vm_memory_heap_used | MB | Current memory usage of the JVM |
#### Indicator set: Basic information indicators
| Indicator name | Unit | Metric Help Description |
|-------------------------------------|------|----------------------------------------|
| jenkins_project_count_value | None | Number of projects |
| jenkins_project_enabled_count_value | None | Number of enabled items |
| jenkins_queue_size_value | None | Number of tasks in the build queue |
| jenkins_node_online_value | None | Number of currently online build nodes |
#### Indicator Set: Actuator Information Indicators
| Indicator name | Unit | Metric Help Description |
|--------------------------------------|------|-----------------------------------------|
| default_jenkins_executors_available | None | Number of available actuators |
| default_jenkins_executors_busy | None | Number of active actuators |
| default_jenkins_executors_connecting | None | Number of actuators currently connected |
#### Indicator Set: Task Information Indicators
| Indicator name | Unit | Metric Help Description |
|----------------------------------------------------------|----------------------------------------------------------|---------------------------------------------------|
| jenkins_job_count_value | None | Number of assignments |
| default_jenkins_builds_duration_milliseconds_summary_sum | millisecond | Task Construction Duration Summary |
| default_jenkins_builds_last_build_duration_milliseconds | millisecond | Time of the most recent build |
| default_jenkins_builds_success_build_count_total | None | Number of successful builds |
| default_jenkins_builds_failed_build_count_total | None | Number of build failures |
| default_jenkins_builds_unstable_build_count_total | None | Number of unstable builds |
| default_jenkins_builds_total_build_count_total | None | Total number of builds (excluding unbuilt states) |
| default_jenkins_builds_last_build_result_ordinal | 0=Success, 1=Unstable, 2=Failure, 3=Not Built, 4=Aborted | Task Build Status (Last Build) |
@@ -0,0 +1,78 @@
---
id: Jenkins
title: 监控:Jenkins
sidebar_label: Jenkins
keywords: [ 开源监控系统, CI/CD, DevOps, Jenkins监控 ]
---
> 通过调用 Jenkins Prometheus Plugin 对 Jenkins 的通用指标进行采集监控。
### 前置条件
1. 按照[部署文档](https://www.jenkins.io/doc/book/installing/)搭建好Jenkins相关服务。
2. 需要安装[插件](https://www.jenkins.io/doc/book/managing/plugins/)
已用来访问暴露的指标信息,可参考[prometheus-plugin](https://plugins.jenkins.io/prometheus/)。
3. 对外暴露指标的地址是```<jenkin_url>/prometheus```,查看是否能访问到metrics数据。
## 配置参数
| 参数名称 | 参数帮助描述 |
|--------|------------------------------------------------------|
| 目标Host | 被监控的对端IPV4,IPV6或域名。注意⚠️不带协议头(eg: https://, http://)。 |
| 端口 | Jenkins Prot值,默认为8080。 |
| 任务名称 | 标识此监控的名称,名称需要保证唯一性。 |
| 查询超时时间 | 设置连接的超时时间,单位ms毫秒,默认3000毫秒。 |
| 监控周期 | 监控周期性采集数据间隔时间,单位秒,可设置的最小间隔为30秒 |
| 绑定标签 | 用于对监控资源进行分类管理 |
| 描述备注 | 更多标识和描述此监控的备注信息,用户可以在这里备注信息 |
### 采集指标
#### 指标集合:系统信息指标
| 指标名称 | 指标单位 | 指标帮助描述 |
|------------------------------|------|----------------|
| default_jenkins_uptime | 毫秒 | Jenkins 运行时间 |
| default_jenkins_up | 无 | Jenkins 是否存活 |
| default_jenkins_version_info | 无 | Jenkins 版本信息 |
| jenkins_health_check_score | 无 | Jenkins 健康检查分值 |
#### 指标集合:jvm
| 指标名称 | 指标单位 | 指标帮助描述 |
|------------------------|------|---------------|
| vm_uptime_milliseconds | 毫秒 | JVM 运行时间 |
| system_cpu_load | 无 | 系统负载 |
| vm_count | 无 | JVM 线程总数 |
| vm_memory_heap_max | MB | JVM可使用的最大内存限制 |
| vm_memory_heap_used | MB | JVM 当前使用的内存大小 |
#### 指标集合:基础信息指标
| 指标名称 | 指标单位 | 指标帮助描述 |
|-------------------------------------|------|-------------|
| jenkins_project_count_value | 无 | 项目数量 |
| jenkins_project_enabled_count_value | 无 | 已启用的项目数量 |
| jenkins_queue_size_value | 无 | 构建队列中的任务数量 |
| jenkins_node_online_value | 无 | 当前在线的构建节点数量 |
#### 指标集合:执行器信息指标
| 指标名称 | 指标单位 | 指标帮助描述 |
|--------------------------------------|------|------------|
| default_jenkins_executors_available | 无 | 可用的执行器数量 |
| default_jenkins_executors_busy | 无 | 忙碌的执行器数量 |
| default_jenkins_executors_connecting | 无 | 正在连接的执行器数量 |
#### 指标集合:任务信息指标
| 指标名称 | 指标单位 | 指标帮助描述 |
|----------------------------------------------------------|-----------------------------|-----------------|
| jenkins_job_count_value | 无 | 作业数量 |
| default_jenkins_builds_duration_milliseconds_summary_sum | 毫秒 | 任务构建时长汇总 |
| default_jenkins_builds_last_build_duration_milliseconds | 毫秒 | 最近一次构建的构建时间 |
| default_jenkins_builds_success_build_count_total | 无 | 构建成功次数 |
| default_jenkins_builds_failed_build_count_total | 无 | 构建失败次数 |
| default_jenkins_builds_unstable_build_count_total | 无 | 不稳定构建次数 |
| default_jenkins_builds_total_build_count_total | 无 | 总构建次数(不包括未构建状态) |
| default_jenkins_builds_last_build_result_ordinal | 0=成功,1=不稳定,2=失败,3=未构建,4=已中止 | 任务构建状态(最近一次构建) |