Skip to content

Jenkins

·


The Jenkins collector monitors Jenkins through plugin Metrics data collection, including but not limited to the number of tasks, system cpu usage, jvm cpu usage, and so on

Configuration

Preconditions

  • JenKins version >= 2.332.1; Already tested version:

    • 2.332.1
    • 2.452.4
    • 2.479.1
    • 2.504.2
  • Install JenKins see here

  • Download the Metric plug-in, management plug-in page,Metric plug-in page
  • Generate Metric Access keys on the JenKins administration page your_manage_host/configure

Collector Configuration

Go to the conf.d/jenkins directory under the DataKit installation directory, copy jenkins.conf.sample and name it jenkins.conf. Examples are as follows:

[[inputs.jenkins]]
  ## Set true if you want to collect metric from url below.
  enable_collect = true

  ## The Jenkins URL in the format "schema://host:port",required
  url = "http://my-jenkins-instance:8080"

  ## Metric Access Key ,generate in your-jenkins-host:/configure,required
  key = ""

  # ##(optional) collection interval, default is 30s
  # interval = "30s"

  ddinfo_resp = '''{ "endpoints": ["/v0.3/traces"] }'''

  ## Set response_timeout
  # response_timeout = "5s"

  ## Set true to enable election(default: true)
  # election = true

  ## Optional TLS Config
  # tls_ca = "/xx/ca.pem"
  # tls_cert = "/xx/cert.pem"
  # tls_key = "/xx/key.pem"
  ## Use SSL but skip chain & host verification
  # insecure_skip_verify = false

  ## set true to receive jenkins CI event
  enable_ci_visibility = true

  ## which port to listen to jenkins CI event
  ci_event_port = ":9539"

  # [inputs.jenkins.log]
  # files = []
  # #grok pipeline script path
  # pipeline = "jenkins.p"

  [inputs.jenkins.tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"
  # ...

  [inputs.jenkins.ci_extra_tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"

Once configured, restart DataKit.

The collector can now be turned on by ConfigMap Injection Collector Configuration.

Jenkins CI Visibility

The Jenkins collector can realize CI visualization by receiving the CI Event from the Jenkins Datadog plugin.

Jenkins CI Visibility opening method:

  • Ensure that the Jenkins CI Visibility feature is turned on in the configuration file and the listening port number is configured (such as :9539), restart DataKit;
  • Install Jenkins Datadog plugin in Jenkins;
  • Select Use the Datadog Agent to report to Datadog (recommended) in Manage Jenkins > Configure System > Datadog Plugin and configure Agent Host as the DataKit IP address. Both DogStatsD Port and Traces Collection Port are configured to the port number configured in the Jenkins collector configuration file above, such as 9539(do not add :);
  • Check Enable CI Visibility
  • Click Save to Save the settings.

After configuration, Jenkins can send CI events to DataKit through Datadog Plugin.

Metric

For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.jenkins.tags] if needed:

[inputs.jenkins.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
# ...

You can specify additional tags for the Jenkins CI Event in the configuration by [inputs.jenkins.ci_extra_tags]:

[inputs.jenkins.ci_extra_tags]
# some_tag = "some_value"
# more_tag = "some_other_value"

jenkins

Tags & Fields Description
host
(tag)
Hostname
metric_plugin_version
(tag)
Jenkins plugin version
url
(tag)
Jenkins URL
version
(tag)
Jenkins version
executor_count The number of executors available to Jenkins
Type: float
Unit: count
executor_free_count The number of executors available to Jenkins that are not currently in use.
Type: float
Unit: count
executor_in_use_count The number of executors available to Jenkins that are currently in use.
Type: float
Unit: count
job_count The number of jobs in Jenkins
Type: float
Unit: count
node_offline_count The number of build nodes available to Jenkins but currently off-line.
Type: float
Unit: count
node_online_count The number of build nodes available to Jenkins and currently on-line.
Type: float
Unit: count
plugins_active The number of plugins in the Jenkins instance that started successfully.
Type: float
Unit: count
plugins_failed The number of plugins in the Jenkins instance that failed to start.
Type: float
Unit: count
project_count The number of project to Jenkins
Type: float
Unit: count
queue_blocked The number of jobs that are in the Jenkins build queue and currently in the blocked state.
Type: float
Unit: count
queue_buildable The number of jobs that are in the Jenkins build queue and currently in the blocked state.
Type: float
Unit: count
queue_pending Number of times a Job has been Pending in a Queue
Type: float
Unit: count
queue_size The number of jobs that are in the Jenkins build queue.
Type: float
Unit: count
queue_stuck he number of jobs that are in the Jenkins build queue and currently in the blocked state
Type: float
Unit: count
system_cpu_load The system load on the Jenkins controller as reported by the JVM Operating System JMX bean
Type: float
Unit: percent,percent
vm_blocked_count The number of threads in the Jenkins JVM that are currently blocked waiting for a monitor lock.
Type: float
Unit: count
vm_count The total number of threads in the Jenkins JVM. This is the sum of: vm.blocked.count, vm.new.count, vm.runnable.count, vm.terminated.count, vm.timed_waiting.count and vm.waiting.count
Type: float
Unit: count
vm_cpu_load The rate of CPU time usage by the JVM per unit time on the Jenkins controller. This is equivalent to the number of CPU cores being used by the Jenkins JVM.
Type: float
Unit: percent,percent
vm_memory_total_committed The total amount of memory that is guaranteed by the operating system as available for use by the Jenkins JVM. (Units of measurement: bytes)
Type: float
Unit: count
vm_memory_total_used The total amount of memory that the Jenkins JVM is currently using.(Units of measurement: bytes)
Type: float
Unit: count

jenkins_pipeline

Tags & Fields Description
author_email
(tag)
Author's email
ci_status
(tag)
CI status
commit_sha
(tag)
The hash value of the most recent commit that triggered the Pipeline
object_kind
(tag)
Event type,here is Pipeline
operation_name
(tag)
Operation name
pipeline_name
(tag)
Pipeline name
pipeline_url
(tag)
Pipeline URL
ref
(tag)
Branches involved
repository_url
(tag)
Repository URL
resource
(tag)
Project name
commit_message The message accompanying the most recent commit of the code that triggered the Pipeline
Type: string
Unit: -
created_at The millisecond timestamp when Pipeline created
Type: int
Unit: timeStamp,msec
duration Pipeline duration(μs)
Type: int
Unit: time,μs
finished_at The millisecond timestamp when Pipeline finished
Type: int
Unit: timeStamp,msec
message Pipeline id,same as pipeline_id
Type: string
Unit: -
pipeline_id Pipeline id
Type: string
Unit: -

jenkins_job

Tags & Fields Description
build_commit_sha
(tag)
The hash value of the commit corresponding to Build
build_failure_reason
(tag)
Reason for Build failure
build_name
(tag)
Build name
build_repo_name
(tag)
The repository name corresponding to build
build_stage
(tag)
Build stage
build_status
(tag)
Build status
object_kind
(tag)
Event type,here is Job
project_name
(tag)
Project name
sha
(tag)
The hash value of the commit corresponding to Build
user_email
(tag)
Author's email
build_commit_message The message of the latest commit that triggered this Build
Type: string
Unit: -
build_duration Build duration(μs)
Type: int
Unit: time,μs
build_finished_at The millisecond timestamp when Build finished
Type: int
Unit: timeStamp,msec
build_id Build id
Type: string
Unit: -
build_started_at The millisecond timestamp when Build started
Type: int
Unit: timeStamp,msec
message The job name corresponding to Build
Type: string
Unit: -
pipeline_id Pipeline id corresponding to Build
Type: string
Unit: -
runner_id Runner id corresponding to Build
Type: string
Unit: -

Log Collection

To collect the JenKins log, open files in jenkins.conf and write to the absolute path of the JenKins log file. For example:

    [[inputs.JenKins]]
      ...
      [inputs.JenKins.log]
        files = ["/var/log/jenkins/jenkins.log"]

When log collection is turned on, a log with a log source of jenkins is generated by default.

Note: DataKit must be installed on the host where JenKins is located to collect JenKins logs.

Log Pipeline Feature Cut Field Description

  • JenKins Universal Log Cutting

Example of common log text:

2021-05-18 03:08:58.053+0000 [id=32] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins

The list of cut fields is as follows:

Field Name Field Value Description
status info log level
id 32 id
time 1621278538000000000 Nanosecond timestamp (as row protocol time)