Detailed explanation of monitoring Jenkins process based on zabbix

Detailed explanation of monitoring Jenkins process based on zabbix

1. Monitoring architecture diagram

2. Implementation ideas

  • Install the Metrics plugin on Jenkins to enable Jenkins to expose the metrics API;
  • Write Python code to fetch data from the API and parse the data into a format that Zabbix can recognize;
  • Configure Zabbix server and agent for monitoring and alerting

3. Specific configuration

1. Install the Jenkins Metrics plugin

Plugin download address: http://updates.jenkins-ci.org/download/plugins/metrics/

Install the Metrics plug-in. In the system configuration, there will be an additional "Metrics" configuration, as shown below:


The configuration items are not complicated. We need to click "Generate..." to generate an Access Key (remember to save it after generating it). This key is used for identity verification, which we will use later.

After saving, we enter the URL in the browser: http://jenkins.local,me/metrics/<the newly generated Access Key> to verify whether Jenkins has exposed metrics. If you see the following picture, you can proceed to the next step:

1.1 Introduction to Metrics plugin

The Metrics plugin is implemented based on dropwizard/metrics. It exposes metrics data through four interfaces: /metrics, /ping, /threads, /healthcheck.

1.2 Metrics plugin: /metrics interface introduction

Click the metric link in the above image (http://jenkins.local.me/metrics/<Access Key>/metrics), which exposes the following metric data:

{
 version: "4.0.0",
 gauges: {...},
 counters: {...},
 histograms: {...},
 meters: {...},
 timers: {...}
}

Gauges: The instantaneous value of a metric, for example, the total number of current Jenkins executors (jenkins.executor.count.value)
Counters: The total value of a metric, for example, the number of active http request connections (http.activeRequests)
Meters: The probability of an event occurring over a period of time, for example, the number of successful tasks executed per minute by Jenkins (jenkins.runs.success.m1_rate)
Histogram: distribution of statistical indicators. For example: Distribution of number of Jenkins executors (jenkins.executor.count.history)
Timer: The duration of a metric. For example: Jenkins task waiting time (jenkins.job.waiting.duration)

1.3 Metrics plugin other interfaces

/ping: The interface returns pong, which means Jenkins is alive, as shown below:

/threads: Returns Jenkins thread information

/healthcheck: Returns the following metrics:

{
 "disk-space" : {
  "healthy" : true
 },
 "plugins" : {
  "healthy" : true,
  "message" : "No failed plugins"
 },
 "temporary-space" : {
  "healthy" : true
 },
 "thread-deadlock" : {
  "healthy" : true
 }
}

Zabbix server collects data by communicating with Zabbix agent. The Zabbix agent is divided into two modes: passive and active. We are using passive mode, which means Zabbix server asks the agent for data.
Therefore, we need to put a script to obtain Jenkins indicator data on the machine where the Zabbix agent is located. Then configure Zabbix server to periodically obtain data from the agent, and finally configure the trigger to implement the alarm.

2.1 Create a monitoring template and link it to a host group


2.2 Create monitoring items

Here we need to explain why some of the options are filled in that way:

  • Type: This is the type of metrics collected by Zabbix server. We choose Zabbix agent, as mentioned above.
  • Key value: Since the indicator we want to monitor is not predefined by Zabbix. Therefore, user-defined parameters are needed to monitor Jenkins indicators. The value filled in for Key is: jenkins.metrics[gauges.jenkins.node.count.value.value]. jenkins.metrics is the actual key name that needs to be executed. The [] are the parameters passed to the command corresponding to the key. For beginners, this part of Zabbix is ​​very difficult to understand. Maybe it will be easier to understand this way: when using user-defined parameters to implement monitoring, the Zabbix server will send this key to the agent, and then the agent will execute the specified logic according to this key to obtain indicator data. This logic is usually a script (shell command or Python script, etc.). The script can also pass parameters, and the values ​​in [] are the parameters passed to the script.
  • Information type: The data type of the monitoring data. Since this monitoring item monitors the number of Jenkins nodes, a numeric integer is used.
  • Update interval: refers to how often Zabbix server obtains data from agent.

At this point, the Zabbix server has been configured. You can check whether there is the latest data in Monitoring->Latest Data, and then create a dashboard to present the data in a graphical way. Other monitoring items can also be configured in this way.

Monitoring script code

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Using zabbix to monitor the ogg process (Windows platform)
  • Detailed explanation of the process of Zabbix active, passive and web monitoring in distributed monitoring system
  • Distributed monitoring system Zabbix uses SNMP and JMX channels to collect data
  • Detailed explanation of Zabbix monitoring SQL Server service status
  • How to monitor mysql using zabbix
  • Detailed tutorial for upgrading zabbix monitoring 4.4 to 5.0
  • Detailed steps for adding hosts you need to monitor in zabbix
  • Example code for configuring monitoring items and aggregated graphics in Zabbix
  • Using zabbix to monitor the ogg process (Linux platform)

<<:  MySQL kill command usage guide

>>:  How to encapsulate query components based on element-ui step by step

Recommend

HTML weight loss Streamline HTML tags to create web pages

HTML 4 HTML (not XHTML), MIME type is text/html, ...

MySQL 8.0.11 installation summary tutorial diagram

Installation environment: CAT /etc/os-release Vie...

A brief introduction to web2.0 products and functions

<br />What is web2.0? Web2.0 includes those ...

Docker configures the storage location of local images and containers

Use the find command to find files larger than a ...

Restart all stopped Docker containers with one command

Restart all stopped Docker containers with one co...

Pure CSS to achieve candle melting (water droplets) sample code

Achieve results Implementation ideas The melting ...

How to use node scaffolding to build a server to implement token verification

content Use scaffolding to quickly build a node p...

Detailed explanation of count(), group by, order by in MySQL

I recently encountered a problem when doing IM, a...

Three BOM objects in JavaScript

Table of contents 1. Location Object 1. URL 2. Pr...

How to elegantly back up MySQL account information

Preface: I recently encountered the problem of in...

SQL implementation of LeetCode (183. Customers who have never placed an order)

[LeetCode] 183.Customers Who Never Order Suppose ...

In-depth understanding of JavaScript event execution mechanism

Table of contents Preface The principle of browse...

How to use cookies to remember passwords for 7 days on the vue login page

Problem Description In the login page of the proj...

Understanding render in Vue scaffolding

In the vue scaffolding, we can see that in the ne...

Summary of methods for writing judgment statements in MySQL

How to write judgment statements in mysql: Method...