Package org.kairosdb.client.builder
Class Metric
- java.lang.Object
-
- org.kairosdb.client.builder.Metric
-
public class Metric extends Object
A metric contains measurements or data points. Each data point has a time stamp of when the measurement occurred and a value that is either a long or double and optionally contains tags. Tags are labels that can be added to better identify the metric. For example, if the measurement was done on server1 then you might add a tag named "host" with a value of "server1". Note that a metric must have at least one tag.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MetricaddDataPoint(double value)Adds the data point to the metric with a timestamp of now.MetricaddDataPoint(long value)Adds the data point to the metric with a timestamp of now.MetricaddDataPoint(long timestamp, double value)Adds the data point to the metric.MetricaddDataPoint(long timestamp, long value)Adds the data point to the metric.MetricaddDataPoint(long timestamp, Object value)MetricaddTag(String name, String value)Adds a tag to the data point.MetricaddTags(Map<String,String> tags)Adds tags to the data point.MetricaddTtl(int ttl)Adds a time-to-live for this metric specified in seconds.booleanequals(Object o)List<DataPoint>getDataPoints()StringgetName()Returns the metric name.Map<String,String>getTags()Returns the tags associated with the data point.intgetTtl()Returns the time-to-live.StringgetType()Returns the custom type name.inthashCode()
-
-
-
Method Detail
-
addTag
public Metric addTag(String name, String value)
Adds a tag to the data point.- Parameters:
name- tag identifiervalue- tag value- Returns:
- the metric the tag was added to
-
addTags
public Metric addTags(Map<String,String> tags)
Adds tags to the data point.- Parameters:
tags- map of tags- Returns:
- the metric the tags were added to
-
addDataPoint
public Metric addDataPoint(long timestamp, long value)
Adds the data point to the metric.- Parameters:
timestamp- when the measurement occurredvalue- the measurement value- Returns:
- the metric
-
addDataPoint
public Metric addDataPoint(long value)
Adds the data point to the metric with a timestamp of now.- Parameters:
value- the measurement value- Returns:
- the metric
-
addDataPoint
public Metric addDataPoint(long timestamp, double value)
Adds the data point to the metric.- Parameters:
timestamp- when the measurement occurredvalue- the measurement value- Returns:
- the metric
-
addDataPoint
public Metric addDataPoint(double value)
Adds the data point to the metric with a timestamp of now.- Parameters:
value- the measurement value- Returns:
- the metric
-
addTtl
public Metric addTtl(int ttl)
Adds a time-to-live for this metric specified in seconds. TTL is off by default. Setting ttl to 0 turns it off.- Parameters:
ttl- number of seconds that the metric will live- Returns:
- the metric
-
getTtl
public int getTtl()
Returns the time-to-live. If zero, the metric lives forever.- Returns:
- time to live
-
getName
public String getName()
Returns the metric name.- Returns:
- metric name
-
getTags
public Map<String,String> getTags()
Returns the tags associated with the data point.- Returns:
- tag for the data point
-
getType
public String getType()
Returns the custom type name. Null if the type is a number.- Returns:
- custom type name
-
-