Class AggregatorFactory


  • public class AggregatorFactory
    extends Object
    • Constructor Detail

      • AggregatorFactory

        public AggregatorFactory()
    • Method Detail

      • createMinAggregator

        public static SamplingAggregator createMinAggregator​(long value,
                                                             TimeUnit unit)
        Creates an aggregator that returns the minimum values for each time period as specified. For example, "5 minutes" would returns the minimum value for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        min aggregator
      • createMaxAggregator

        public static SamplingAggregator createMaxAggregator​(long value,
                                                             TimeUnit unit)
        Creates an aggregator that returns the maximum values for each time period as specified. For example, "5 minutes" would returns the maximum value for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        max aggregator
      • createAverageAggregator

        public static SamplingAggregator createAverageAggregator​(long value,
                                                                 TimeUnit unit)
        Creates an aggregator that returns the average values for each time period as specified. For example, "5 minutes" would returns the average value for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        average aggregator
      • createStandardDeviationAggregator

        public static SamplingAggregator createStandardDeviationAggregator​(long value,
                                                                           TimeUnit unit)
        Creates an aggregator that returns the standard deviation values for each time period as specified. For example, "5 minutes" would returns the standard deviation for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        standard deviation aggregator
      • createSumAggregator

        public static SamplingAggregator createSumAggregator​(long value,
                                                             TimeUnit unit)
        Creates an aggregator that returns the sum of all values over each time period as specified. For example, "5 minutes" would returns the sum of data points for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        sum aggregator
      • createCountAggregator

        public static SamplingAggregator createCountAggregator​(long value,
                                                               TimeUnit unit)
        Creates an aggregator that returns the count of all values over each time period as specified. For example, "5 minutes" would returns the count of data points for each 5 minute period.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        count aggregator
      • createPercentileAggregator

        public static PercentileAggregator createPercentileAggregator​(double percentile,
                                                                      long value,
                                                                      TimeUnit unit)
        Creates an aggregator that returns the percentile value for a given percentage of all values over each time period as specified. For example, "0.5" and "5 minutes" would returns the median of data points for each 5 minute period.
        Parameters:
        percentile - percentage
        value - value for time period
        unit - unit of time
        Returns:
        percentile aggregator
      • createDivAggregator

        public static CustomAggregator createDivAggregator​(double divisor)
        Creates an aggregator that divides each value by the divisor.
        Parameters:
        divisor - divisor.
        Returns:
        div aggregator
      • createLastAggregator

        public static SamplingAggregator createLastAggregator​(long value,
                                                              TimeUnit unit)
        Creates an aggregator that returns the last data point for the time range.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        last aggregator
      • createFirstAggregator

        public static SamplingAggregator createFirstAggregator​(long value,
                                                               TimeUnit unit)
        Creates an aggregator that returns the first data point for the time range.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        first aggregator
      • createDataGapsMarkingAggregator

        public static SamplingAggregator createDataGapsMarkingAggregator​(long value,
                                                                         TimeUnit unit)
        Creates an aggregator that marks gaps in data according to sampling rate with a null data point.
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        gap marking aggregator
      • createLeastSquaresAggregator

        public static SamplingAggregator createLeastSquaresAggregator​(long value,
                                                                      TimeUnit unit)
        Creates an aggregator that returns a best fit line through the datapoints using the least squares algorithm..
        Parameters:
        value - value for time period.
        unit - unit of time
        Returns:
        least squares aggregator
      • createDiffAggregator

        public static Aggregator createDiffAggregator()
        Creates an aggregator that computes the difference between successive data points.
        Returns:
        diff aggregator
      • createSamplerAggregator

        public static Aggregator createSamplerAggregator()
        Creates an aggregator that computes the sampling rate of change for the data points.
        Returns:
        sampler aggregator
      • createSimpleMovingAverage

        public static CustomAggregator createSimpleMovingAverage​(int numPeriods)
        Creates an aggregator that calculates a simple moving average for the number of specified periods.
        Parameters:
        numPeriods - number of periods
        Returns:
        simple moving average aggregator
      • createScaleAggregator

        public static CustomAggregator createScaleAggregator​(double factor)
        Creates an aggregator that scales each data point by a factor.
        Parameters:
        factor - factor to scale by
        Returns:
        sampler aggregator
      • createCustomAggregator

        public static CustomAggregator createCustomAggregator​(String name,
                                                              String json)
        Creates an aggregator with a custom json fragment. This method is used for custom aggregators that have been added to KairosDB. This does not create an aggregator on the server. The name must match the custom aggregator on the server.
        Example:

              Aggregator aggregator = AggregatorFactory.createCustomAggregator("scale", "\"factor\": 0.75");
         


        This produces aggregator JSON that looks like this:

              "name":"scale",
              "factor": 0.75
         
        Parameters:
        name - name of the aggregator.
        json - aggregator JSON fragment
        Returns:
        customer aggregator
      • createRateAggregator

        public static RateAggregator createRateAggregator​(TimeUnit unit)
        Creates an aggregator that returns the rate of change between each pair of data points
        Parameters:
        unit - unit of time
        Returns:
        rate aggregator
      • createSaveAsAggregator

        public static CustomAggregator createSaveAsAggregator​(String newMetricName)
        Creates an aggregator that saves the results of the query to a new metric.
        Parameters:
        newMetricName - metric to save results to
        Returns:
        save as aggregator
      • createTrimAggregator

        public static CustomAggregator createTrimAggregator​(AggregatorFactory.Trim trim)
        Creates an aggregator that trim of the first, last, or both data points returned by the query.
        Parameters:
        trim - what to trim
        Returns:
        trim aggregator
      • createFilterAggregator

        public static CustomAggregator createFilterAggregator​(AggregatorFactory.FilterOperation operation,
                                                              double threshold)
        Creates an aggregator that filters datapoints according to the filter operation.
        Parameters:
        operation - what to filter on
        threshold - the value the operation is performed on. If the operation is lt, then a null data point is returned if the data point is less than the threshold.
        Returns:
        filter aggregator