Class QueryBuilder


  • public class QueryBuilder
    extends AbstractQueryBuilder<QueryBuilder>
    Builder used to create the JSON to query KairosDB.

    The query returns the data points for the given metrics for the specified time range. The time range can be specified as absolute or relative. Absolute times are a given point in time. Relative times are relative to now. The end time is not required and defaults to now.

    For example, if you specify a relative start time of 30 minutes, all matching data points for the last 30 minutes will be returned. If you specify a relative start time of 30 minutes and a relative end time of 10 minutes, then all matching data points that occurred between the last 30 minutes up to and including the last 10 minutes are returned.
    • Method Detail

      • setCacheTime

        public QueryBuilder setCacheTime​(int cacheTime)
        How long to cache this exact query. The default is to never cache.
        Parameters:
        cacheTime - cache time in milliseconds
        Returns:
        the builder
      • addMetric

        public QueryMetric addMetric​(QueryMetric metric)
        Adds a QueryMetric object to the QueryBuilder
        Parameters:
        metric - a QueryMetric object
        Returns:
        the builder
      • getInstance

        public static QueryBuilder getInstance()
        Returns a new query builder.
        Returns:
        new query builder
      • addMetric

        public QueryMetric addMetric​(String name)
        The metric to query for.
        Parameters:
        name - metric name
        Returns:
        the builder
      • getCacheTime

        public int getCacheTime()
        Returns the cache time.
        Returns:
        cache time
      • getMetrics

        public List<QueryMetric> getMetrics()
        Returns the list metrics to query for.
        Returns:
        metrics
      • getTimeZone

        public TimeZone getTimeZone()
        Returns the time zone. The default time zone is UTC.
        Returns:
        time zone