Package org.kairosdb.client.builder
Class QueryMetric
- java.lang.Object
-
- org.kairosdb.client.builder.QueryMetric
-
public class QueryMetric extends Object
Query request for a metric. If a metric is queried by name only then all data points for all tags are returned. You can narrow down the query by adding tags so only data points associated with those tags are returned.
Aggregators may be added to the metric. An aggregator performs an operation on the data such as summing or averaging. If multiple aggregators are added, the output of the first is sent to the input of the next, and so forth until all aggregators have been processed, These are processed in the order they were added.
The results of the query can be grouped in various ways using a grouper. For example, if you had a metric with a customer tag, the resulting data points could be grouped by the different customers. Multiple groupers can be used so you could, for example, group by tag and value.
Note that aggregation is very fast but grouping can slow down the query.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueryMetric.Order
-
Constructor Summary
Constructors Constructor Description QueryMetric(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryMetricaddAggregator(Aggregator aggregator)Adds an aggregator to the metric.QueryMetricaddGrouper(Grouper grouper)Add a grouper to the metric.QueryMetricaddMultiValuedTags(Map<String,List<String>> tags)Add a map of tags.QueryMetricaddTag(String name, String... values)Adds a tag with multiple values.QueryMetricaddTags(Map<String,String> tags)Add a map of tags.booleanequals(Object o)List<Aggregator>getAggregators()List<Grouper>getGroupers()IntegergetLimit()StringgetName()QueryMetric.OrdergetOrder()com.google.common.collect.ListMultimap<String,String>getTags()inthashCode()booleanisExcludeTags()voidsetExcludeTags(boolean exclude)If true removes tags from the query response.voidsetLimit(int limit)Limits the number of data point returned from the query.voidsetOrder(QueryMetric.Order order)Orders the data points.StringtoString()
-
-
-
Constructor Detail
-
QueryMetric
public QueryMetric(String name)
-
-
Method Detail
-
addMultiValuedTags
public QueryMetric addMultiValuedTags(Map<String,List<String>> tags)
Add a map of tags.- Parameters:
tags- tags to add- Returns:
- the metric
-
addTags
public QueryMetric addTags(Map<String,String> tags)
Add a map of tags. This narrows the query to only show data points associated with the tags' values.- Parameters:
tags- tags to add- Returns:
- the metric
-
addTag
public QueryMetric addTag(String name, String... values)
Adds a tag with multiple values. This narrows the query to only show data points associated with the tag's values.- Parameters:
name- tag namevalues- tag values- Returns:
- the metric
-
addAggregator
public QueryMetric addAggregator(Aggregator aggregator)
Adds an aggregator to the metric.- Parameters:
aggregator- aggregator to add- Returns:
- the metric
-
addGrouper
public QueryMetric addGrouper(Grouper grouper)
Add a grouper to the metric.- Parameters:
grouper- grouper to add- Returns:
- the metric
-
setLimit
public void setLimit(int limit)
Limits the number of data point returned from the query. The limit is done before aggregators are executed.- Parameters:
limit- maximum number of data points to return
-
setOrder
public void setOrder(QueryMetric.Order order)
Orders the data points. The server default is ascending.- Parameters:
order- how data points are sorted
-
getName
public String getName()
-
getAggregators
public List<Aggregator> getAggregators()
-
getLimit
public Integer getLimit()
-
getOrder
public QueryMetric.Order getOrder()
-
isExcludeTags
public boolean isExcludeTags()
-
setExcludeTags
public void setExcludeTags(boolean exclude)
If true removes tags from the query response. The default is to include tags.- Parameters:
exclude- exclude tags
-
-