Package jenkins.metrics.api
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
MetricsRootAction.AccessKeyPseudoservlet
Web binding for the access keysclass
MetricsRootAction.CurrentUserPseudoservlet
Web binding for the current user.class
MetricsRootAction.Pseudoservlet
A binding of the standard dropwizard metrics servlet into the stapler APIstatic class
MetricsRootAction.Sampler
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 TimeUnit
DURATION_UNIT
The time unit to express durations in, that is all durations are in seconds.static TimeUnit
RATE_UNIT
The time units to express rates in, that is all rates are events per minute.
-
Constructor Summary
Constructors Constructor Description MetricsRootAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.kohsuke.stapler.HttpResponse
doHealthcheck(org.kohsuke.stapler.StaplerRequest req, String key)
Binds the health checks to the CORS aware URL/metrics/healthcheck
where the metrics access key is provided in the form fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
headerorg.kohsuke.stapler.HttpResponse
doHealthcheckOk(org.kohsuke.stapler.StaplerRequest req)
Condense the health check into one bit of information for frontend reverse proxies like haproxy.org.kohsuke.stapler.HttpResponse
doMetrics(org.kohsuke.stapler.StaplerRequest req, String key)
Binds the metrics to the CORS aware URL/metrics/metrics
where the metrics access key is provided in the form fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
headerorg.kohsuke.stapler.HttpResponse
doMetricsHistory(org.kohsuke.stapler.StaplerRequest req, String key)
Binds the metrics history to the CORS aware URL/metrics/metricsHistory
where the metrics access key is provided in the form fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
headerorg.kohsuke.stapler.HttpResponse
doPing(org.kohsuke.stapler.StaplerRequest req, String key)
Binds the ping check to the CORS aware URL/metrics/ping
where the metrics access key is provided in the form fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
headerorg.kohsuke.stapler.HttpResponse
doThreads(org.kohsuke.stapler.StaplerRequest req, String key)
Binds the thread dump to the CORS aware URL/metrics/threads
where the metrics access key is provided in the form fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
headerObject
getCurrentUser()
Binds theMetricsRootAction.Pseudoservlet
for the current user to the URL/metrics/currentUser
String
getDisplayName()
Object
getDynamic(String key)
Binds theMetricsRootAction.Pseudoservlet
for a metric access keys to the URL/metrics/{key}
String
getIconFileName()
String
getUrlName()
-
-
-
Method Detail
-
getIconFileName
public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
public String getUrlName()
- Specified by:
getUrlName
in interfaceAction
-
getDynamic
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getDynamic(String key)
Binds theMetricsRootAction.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 theMetricsRootAction.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.StaplerRequest 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 fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
header- Parameters:
req
- the requestkey
- 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.StaplerRequest 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.StaplerRequest 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 fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
header- Parameters:
req
- the requestkey
- 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.StaplerRequest 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 fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
header- Parameters:
req
- the requestkey
- 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.StaplerRequest 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 fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
header- Parameters:
req
- the requestkey
- 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.StaplerRequest 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 fieldkey
or anAuthorization: Jenkins-Metrics-Key {key}
header- Parameters:
req
- the requestkey
- the key from the form field.- Returns:
- the
HttpResponse
- Throws:
IllegalAccessException
- if the access attempt is invalid.
-
-