Class MetricsRootAction

java.lang.Object
jenkins.metrics.api.MetricsRootAction
All Implemented Interfaces:
ExtensionPoint, Action, ModelObject, RootAction, UnprotectedRootAction

@Extension public class MetricsRootAction extends Object implements UnprotectedRootAction
Root action that exposes the metrics via the REST UI.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Web binding for the access keys
    class 
    Web binding for the current user.
    class 
    A binding of the standard dropwizard metrics servlet into the stapler API
    static class 
    Sampler that captures an exponential sample of metrics snapshots.

    Nested classes/interfaces inherited from interface hudson.ExtensionPoint

    ExtensionPoint.LegacyInstancesAreScopedToHudson
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TimeUnit
    The time unit to express durations in, that is all durations are in seconds.
    static final TimeUnit
    The time units to express rates in, that is all rates are events per minute.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.kohsuke.stapler.HttpResponse
    doHealthcheck(org.kohsuke.stapler.StaplerRequest2 req, String key)
    Binds the health checks to the CORS aware URL /metrics/healthcheck where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
    org.kohsuke.stapler.HttpResponse
    doHealthcheckOk(org.kohsuke.stapler.StaplerRequest2 req)
    Condense the health check into one bit of information for frontend reverse proxies like haproxy.
    org.kohsuke.stapler.HttpResponse
    doMetrics(org.kohsuke.stapler.StaplerRequest2 req, String key)
    Binds the metrics to the CORS aware URL /metrics/metrics where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
    org.kohsuke.stapler.HttpResponse
    doMetricsHistory(org.kohsuke.stapler.StaplerRequest2 req, String key)
    Binds the metrics history to the CORS aware URL /metrics/metricsHistory where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
    org.kohsuke.stapler.HttpResponse
    doPing(org.kohsuke.stapler.StaplerRequest2 req, String key)
    Binds the ping check to the CORS aware URL /metrics/ping where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
    org.kohsuke.stapler.HttpResponse
    doThreads(org.kohsuke.stapler.StaplerRequest2 req, String key)
    Binds the thread dump to the CORS aware URL /metrics/threads where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
    Binds the MetricsRootAction.Pseudoservlet for the current user to the URL /metrics/currentUser
    Binds the MetricsRootAction.Pseudoservlet for a metric access keys to the URL /metrics/{key}

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RATE_UNIT

      public static final TimeUnit RATE_UNIT
      The time units to express rates in, that is all rates are events per minute.
    • DURATION_UNIT

      public static final TimeUnit DURATION_UNIT
      The time unit to express durations in, that is all durations are in seconds.
  • Constructor Details

    • MetricsRootAction

      public MetricsRootAction()
  • Method Details

    • getIconFileName

      public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • getDynamic

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getDynamic(String key)
      Binds the MetricsRootAction.Pseudoservlet for a metric access keys to the URL /metrics/{key}
      Parameters:
      key - the key.
      Returns:
      the MetricsRootAction.Pseudoservlet
    • getCurrentUser

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getCurrentUser()
      Binds the MetricsRootAction.Pseudoservlet for the current user to the URL /metrics/currentUser
      Returns:
      the MetricsRootAction.Pseudoservlet
    • doHealthcheck

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doHealthcheck(org.kohsuke.stapler.StaplerRequest2 req, @QueryParameter("key") String key) throws IllegalAccessException
      Binds the health checks to the CORS aware URL /metrics/healthcheck where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
      Parameters:
      req - the request
      key - the key from the form field.
      Returns:
      the HttpResponse
      Throws:
      IllegalAccessException - if the access attempt is invalid.
    • doHealthcheckOk

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doHealthcheckOk(org.kohsuke.stapler.StaplerRequest2 req)
      Condense the health check into one bit of information for frontend reverse proxies like haproxy. Other health check calls requires authentication, which is not suitable for the haproxy use. But this endpoint only exposes one bit information, it's deemed OK to be exposed unsecurely. return status 200 if everything is OK, 503 (service unavailable) otherwise
      Parameters:
      req - the request
      Returns:
      the HTTP response
    • doMetrics

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doMetrics(org.kohsuke.stapler.StaplerRequest2 req, @QueryParameter("key") String key) throws IllegalAccessException
      Binds the metrics to the CORS aware URL /metrics/metrics where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
      Parameters:
      req - the request
      key - the key from the form field.
      Returns:
      the HttpResponse
      Throws:
      IllegalAccessException - if the access attempt is invalid.
    • doMetricsHistory

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doMetricsHistory(org.kohsuke.stapler.StaplerRequest2 req, @QueryParameter("key") String key) throws IllegalAccessException
      Binds the metrics history to the CORS aware URL /metrics/metricsHistory where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
      Parameters:
      req - the request
      key - the key from the form field.
      Returns:
      the HttpResponse
      Throws:
      IllegalAccessException - if the access attempt is invalid.
    • doPing

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doPing(org.kohsuke.stapler.StaplerRequest2 req, @QueryParameter("key") String key) throws IllegalAccessException
      Binds the ping check to the CORS aware URL /metrics/ping where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
      Parameters:
      req - the request
      key - the key from the form field.
      Returns:
      the HttpResponse
      Throws:
      IllegalAccessException - if the access attempt is invalid.
    • doThreads

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doThreads(org.kohsuke.stapler.StaplerRequest2 req, @QueryParameter("key") String key) throws IllegalAccessException
      Binds the thread dump to the CORS aware URL /metrics/threads where the metrics access key is provided in the form field key or an Authorization: Jenkins-Metrics-Key {key} header
      Parameters:
      req - the request
      key - the key from the form field.
      Returns:
      the HttpResponse
      Throws:
      IllegalAccessException - if the access attempt is invalid.