Git Product home page Git Product logo

jenkins-exporter's Introduction

Jenkins Exporter

An exporter for Jenkins Build metrics written in Golang. The program is intended to run as daemon. It fetches periodically metrics for Jenkins builds and Stages via the Jenkins API and publishes them via an HTTP endpoint in Prometheus format.

It provides the following Prometheus metrics:

  • Histograms:
    • jenkins_exporter_job_duration_seconds_bucket,
      jenkins_exporter_job_duration_seconds_sum,
      jenkins_exporter_job_duration_seconds_count
      • Labels:
        • result
        • jenkins_job: the name of the Jenkins Job
        • branch: for multibranch Jenkins Jobs, the branch name
      • type: type of recorded duration, one of:
        • blocked_time
        • buildable_time
        • building_duration
        • executing_time
        • waiting_time
    • jenkins_exporter_stage_duration_seconds_bucket,
      jenkins_exporter_stage_duration_seconds_sum,
      jenkins_exporter_stage_duration_seconds_count,
      • Labels:
        • result: result of the stage
        • stage: stage name
        • type:
          • duration
        • branch: for multibranch Jenkins Jobs, the branch name
  • Counter:
    • jenkins_exporter_errors
      Counts the number of errors the jenkins-exporter encountered when fetching information from the Jenkins API.
      • Labels:
        • type:
          • jenkins_api
          • jenkins_wfapi

By default job metrics are recorded for every finished Jenkins build. The Jenkins jobs for that builds are recorded can be limited with the --jenkins-job-whitelist command-line parameter. The duration types that are recorded can also be configured via a command-line parameter.

The exporter can also record durations of individual pipeline stages. This requires that the Pipeline Stage View Plugin is installed on the Jenkins server. Recording per stage metrics can be enabled via the -enable-build-stage-metrics command-line parameter. The -build-stage-allowlist parameter allows to specify for which jobs and stages, per-stage metrics are recorded.

All parameter can also be specified via environment variables. See ./jenkins-exporter -help for more information.

Installation

Binary

Download Release Binary

Download a release binary from: https://github.com/simplesurance/jenkins-exporter/releases.

go install

go install github.com/simplesurance/jenkins-exporter@latest

git clone

git clone --depth 1 https://github.com/simplesurance/jenkins-exporter.git jenkins-exporter
cd jenkins-exporter
make

Then copy the jenkins-exporter into your $PATH.

As Systemd Service

  1. Install jenkins-exporter to /usr/local/bin
  2. cp dist/etc/default/jenkins-exporter /etc/default/
  3. Configure the jenkins-exporter by editing /etc/default/jenkins-exporter
  4. cp dist/etc/systemd/system/jenkins-exporter.service /etc/systemd/system
  5. systemctl daemon-reload && systemctl enable jenkins-exporter && systemctl start jenkins-exporter

jenkins-exporter's People

Contributors

dependabot[bot] avatar fho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jenkins-exporter's Issues

runtime metrics for builds that are still running are recorded

Sometimes the result of a build is "success" but some stage statuses are still "in progress".
This causes that metrics for those stages won't be recorded.
This might also cause that the overall runtime metrics for a build are wrong because they are recorded while the build is still running.

A successful build result surprisingly can not be used to determine if a build has finished, find another value that can be queried instead.

metrics often not recorded when builds run in paralllel for jobs

When multiple builds run for the same job, it can happen that build N finishes before build N-1.
If the jenkins-exporter retrieves an unfinished build it removes it from the result, if a following build already has finished, it's build number is recorded as highest seen buildnr and all previous builds are ignored.

This caused that metrics for builds are often not recorded.

Visualisation

Hi, is there already a dashboard available to visualize the metrics? With grafana for example?

metrics for builds

It is not an issue but like to know the below
you have any idea about working on total number of builds, successful builds, failed builds and killed builds

it will be helpful for all if you do so

throttle retrieving per-stage metrics

Throttle the number of API requests that are made to retrieve per-stage metrics.
If metrics for a lot of builds are retrieved, sending tons of requests to the jenkins-server in a loop could generate too much load.
Ideally the number of requests are configurable via a parameter.

Not pulling data from Jenkins instance

I had installed ur binary and tried to run it like below

./jenkins-exporter-linux_amd64 -jenkins-url -jenkins-user= -jenkins-password= -jenkins-job-whitelist=

While the server starts, I don't see any entry related to jenkins job

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.