Build Test Failure Count

Extract and display the number of failed tests reported by a build pipeline. Rather than counting individual failure events, this example reads the exact number that the build system already calculated and logged as part of its output.

Visualization: the widget displays the number of failed tests extracted from the build log. The max() function aggregates the extracted value into a single numeric field, so the Single Value widget knows exactly which value to display:

Screenshot showing a single value widget displaying the number of failed tests as a single large number centered on a dark background with a time range indicator

Figure 250. Build Test Failure Count


Sample input data:

@timestampcommithostmessagepipeline
1970-01-01T00:00:0267686a1build-01Build started for commit 67686a1ci-build
1970-01-01T00:00:0267686a1build-01Running test suite: unitci-build
1970-01-01T00:00:0267686a1build-01Tests failed: 3ci-build
1970-01-01T00:00:0267686a1build-01Build completeci-build

Query:

logscale
commit = 67686a1
| /Tests failed: (?<tests_failed>\d+)/
| max(tests_failed, as=tests_failed)

Query breakdown:

  1. Filters events for the specific commit 67686a1, assuming one build per commit.

  2. Extracts the number of failed tests from the log message using a regex capture group, storing the result in the tests_failed field.

  3. Uses max() to aggregate the tests_failed values across all matching events, returning the highest value as a numeric field. Because the build always reports the same count, this produces a single numeric result that the Single Value widget can display.

Configuration:

  1. From the Search page, type your query in the Query Editor → click Run

  2. Choose Single Value in the Widget selector

  3. Click the style icon : this opens the Format panel on the side.

  4. In Text, enter a Label such as Failed Tests to describe the displayed value.

To customize this widget further, see Single Value Property Reference.