Class Metrics

java.lang.Object
org.restheart.metrics.Metrics

public class Metrics extends Object
Utility class for metrics
Author:
Andrea Di Cesare <andrea@softinstigate.com>
  • Constructor Details

    • Metrics

      public Metrics()
  • Method Details

    • failedAuthHistogramName

      public static String failedAuthHistogramName(io.undertow.server.HttpServerExchange exchange)
      Parameters:
      exchange -
      Returns:
      the name of the histogram that stores the percentage of failed auth requests in the last 10 seconds
    • xffValue

      public static String xffValue(String xff, int rindex)
      handles the case where the X_Forwarded_For header is set as "invalid input: '<'client-suppied-value>, ..., invalid input: '<'proxy-supplied-value>"
      Parameters:
      xff -
      rindex - @see useXForwaderdedElement()
      Returns:
      the rindex-th element of a comma separated list
    • collectFailedAuthBy

      public static void collectFailedAuthBy(Metrics.FAILED_AUTH_KEY key)
      Set the key used to collect failed auth requests, REMOTE_IP (default) or X_FORWARDED_FOR
      Parameters:
      key - the key to use
    • xffValueRIndex

      public static void xffValueRIndex(int ridx)
      Set the xffReverseIndex, i.e. if X-ForwardedFor header has multiple values, take into account the n-th value from last e.g. with [x.x.x.x, y.y.y.y., z.z.z.z, k.k.k.k] 0 -> k.k.k.k 2 -> y.y.y.y
      Parameters:
      ridx - the reverse index (element from last)
    • attachMetricLabels

      public static void attachMetricLabels(Request<?> request, List<MetricLabel> labels)
      attach metrics labels to request RequestsMetricsCollector adds labels to the collected metrics
      Parameters:
      request -
      labels -
    • attachMetricLabel

      public static void attachMetricLabel(Request<?> request, MetricLabel label)
      attach metrics labels to request RequestsMetricsCollector adds labels to the collected metrics
      Parameters:
      request -
      labels -
    • getMetricLabels

      public static List<MetricLabel> getMetricLabels(Request<?> request)
      retrives the metrics labels attached to request
      Parameters:
      request -
      labels -