Skip to content

inputs.jenkins: Only lastBuild is reported, missing concurrent and queued builds #18345

@jeffhoek

Description

@jeffhoek

Relevant telegraf.conf

[[inputs.jenkins]]
  url = "${JENKINS_URL}"
  ## No authentication — setup wizard is disabled
  # username = ""
  # password = ""

  ## Collect all job and node metrics
  max_build_age = "1h"
  max_connections = 5
  response_timeout = "10s"

Logs from Telegraf

# (The Telegraf logs do not have any errors or entries related to this bug.)

podman compose logs telegraf
telegraf  | 2026-02-13T01:31:27Z W! Strict environment variable handling will be the new default starting with v1.38.0! If your configuration works with strict handling or you don't use environment variables it is safe to ignore this warning. Otherwise please explicitly add the --non-strict-env-handling flag!
telegraf  | 2026-02-13T01:31:27Z I! Loading config: /etc/telegraf/telegraf.conf
telegraf  | 2026-02-13T01:31:27Z I! Starting Telegraf 1.37.1 brought to you by InfluxData the makers of InfluxDB
telegraf  | 2026-02-13T01:31:27Z I! Available plugins: 243 inputs, 9 aggregators, 35 processors, 26 parsers, 67 outputs, 8 secret-stores
telegraf  | 2026-02-13T01:31:27Z I! Loaded inputs: jenkins
telegraf  | 2026-02-13T01:31:27Z I! Loaded aggregators:
telegraf  | 2026-02-13T01:31:27Z I! Loaded processors:
telegraf  | 2026-02-13T01:31:27Z I! Loaded secretstores:
telegraf  | 2026-02-13T01:31:27Z I! Loaded outputs: influxdb_v2
telegraf  | 2026-02-13T01:31:27Z I! Tags enabled: host=39c273fc6f2c
telegraf  | 2026-02-13T01:31:27Z I! [agent] Config: Interval:30s, Quiet:false, Hostname:"39c273fc6f2c", Flush Interval:10s
telegraf  | 2026-02-13T01:31:27Z W! [agent] The default value of 'skip_processors_after_aggregators' will change to 'true' with Telegraf v1.40.0! If you need the current default behavior, please explicitly set the option to 'false'!

System info

Telegraf 1.37.1 (git: HEAD@3352c0d5), Debian GNU/Linux 12 (bookworm), Podman Engine 5.7.1

Docker

See https://github.com/jeffhoek/tig-stack for Telegraf-InfluxDB-Grafana (TIG) + Jenkins stack for testing and validation.

Steps to reproduce

  1. Configure a Jenkins job that allows concurrent builds (or triggers builds faster than they complete so one queues behind another). For example, create a Freestyle job that sleeps for 10 seconds.
  2. Trigger two builds in quick succession
  3. Observe that jenkins_job metrics are missing for one of the builds
Image Image

Expected behavior

All completed builds within max_build_age should be reported as jenkins_job metrics.

Actual behavior

Only lastBuild is checked. If that build is still running, the plugin skips the entire job and reports nothing — even if other builds have already completed. This leads to two failure modes:

  1. Running + completed builds: If lastBuild is still building, the plugin returns early. Any older builds that already finished are never reported.
  2. Multiple completed builds: If two or more builds complete between gather cycles, only the latest (lastBuild) is reported. The others are lost.

Additional info

This issue is similar to #6966, but the report is more comprehensive and forthcoming fix much more concise.

The Jenkins input plugin only inspects the lastBuild field from the Jenkins API when collecting build metrics. This means only a single build per job is ever evaluated per gather cycle. When a job has multiple builds — whether running concurrently or queued — completed builds are silently dropped.

Root cause:
In getJobDetail(), the plugin reads only js.LastBuild.Number and fetches that single build. The Jenkins API also returns a builds array containing all recent builds, but this field was not being used.

Affected versions: All current versions of the plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions