Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new metric for Quiet Mode status #687

Merged
merged 2 commits into from
Jul 27, 2024

Conversation

sstafford
Copy link

This pull request introduces a new "default_jenkins_quietdown" metric to indicate whether Jenkins is in quiet mode. It can be used to monitor whether Jenkins is processing new jobs. It uses the Jenkins.isQuietingDown method to determine the status of the server:

This is a fix for Issue #686

This metric exposes the Jenkins isQuietingDown status as a gauge.
When Jenkins is in quiet mode, the new metric will represent this
as a '1', otherwise the value will be '0'

Exposing this metric allows Prometheus to determine whether Jenkins
is in quiet mode.  This can be useful in cases where an alert should
be triggered if quiet mode has been enabled for too long or falls
outside of a maintenance window.

Fixes issue jenkinsci#686
@@ -40,6 +40,7 @@
| default_jenkins_up | Shows if jenkins ready to receive requests | gauge |
| default_jenkins_uptime | Shows time since Jenkins was initialized | gauge |
| default_jenkins_nodes_online | Shows Nodes online status | gauge |
| default_jenkins_quietdown | Shows if jenkins is in quiet mode | gauge |

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 95 Warning documentation

Expected: 80; Actual: 95


@Test
public void testCollectResultForJenkinsQuietModeEnabled() {

Check notice

Code scanning / Pmd (reported by Codacy)

JUnit tests should include assert() or fail() Note test

JUnit tests should include assert() or fail()
}

@Test
public void testJenkinsIsNull() {

Check notice

Code scanning / Pmd (reported by Codacy)

JUnit tests should include assert() or fail() Note test

JUnit tests should include assert() or fail()


@Test
public void testCollectResultForJenkinsQuietModeDisabled() {

Check notice

Code scanning / Pmd (reported by Codacy)

JUnit tests should include assert() or fail() Note test

JUnit tests should include assert() or fail()
@Waschndolos
Copy link

@sstafford - Thanks for the PR. The code looks good. Could you fix the test org.jenkinsci.plugins.prometheus.JenkinsStatusCollectorTest.shouldProduceNodeMetrics then I'll test it functionally and merge it to master. Thank you

The unit test checks the number of status metrics.
Adding a new metric caused this test to fail.
The number of metrics needed to be incremented to fix the test.
@Waschndolos Waschndolos merged commit 7c50ad2 into jenkinsci:master Jul 27, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants