public class OpenTsdbMetric extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
OpenTsdbMetric.Builder |
| Modifier and Type | Method and Description |
|---|---|
static String |
encodeTagsInName(String name,
Map<String,String> tags)
Add TSDB tags to a CodaHale metric name.
|
static String |
encodeTagsInName(String name,
String tags)
Add TSDB tags to a CodaHale metric name.
|
boolean |
equals(Object o) |
static String |
fixEncodedTagsInNameAfterPrefix(String name)
Call this function whenever a potentially tag-encoded name is prefixed.
|
static String |
formatTags(Map<String,String> tagMap)
Convert a tag map into a space-delimited string.
|
String |
getMetric() |
Map<String,String> |
getTags() |
Long |
getTimestamp() |
Object |
getValue() |
static boolean |
hasEncodedTagInName(String name)
Tests whether a name has been processed with
encodeTagsInName. |
int |
hashCode() |
static OpenTsdbMetric.Builder |
named(String name)
Creates a Builder for a metric name.
|
static Map<String,String> |
parseTags(String tagString)
Convert a tag string into a tag map.
|
static String |
sanitize(String name)
Sanitizes a metric name, tag key, or tag value by removing characters not allowed by TSDB.
|
String |
toString()
Returns a JSON string version of this metric compatible with the HTTP API reporter.
|
String |
toTelnetPutString()
Returns a put string version of this metric compatible with the telnet-style reporter.
|
public static Map<String,String> parseTags(String tagString) throws IllegalArgumentException
tagString - a space-delimited string of key-value pairs. For example, "key1=value1 key_n=value_n"MapIllegalArgumentException - if the tag string is corrupted.public static String formatTags(Map<String,String> tagMap)
tagMap - "key1=value1 key_n=value_n"public static String encodeTagsInName(String name, String tags) throws IllegalArgumentException
name - CodaHale metric nametags - A space-delimited string of TSDB key-value pair tagsIllegalArgumentException - if the tag string is invalidpublic static String encodeTagsInName(String name, Map<String,String> tags)
name - CodaHale metric nametags - a Map of TSDB tagspublic static boolean hasEncodedTagInName(String name)
encodeTagsInName.name - a metric nametrue if name has tags encoded, false otherwise.public static String fixEncodedTagsInNameAfterPrefix(String name)
name - a metric name with encoded tag strings that has been prefixed.public static OpenTsdbMetric.Builder named(String name)
name - name can contain either a pure CodaHale metric name, or a string returned by encodeTagsInName.
If it's the latter, the tags are parsed out and passed to withTags.OpenTsdbMetric.Builderpublic String toString()
{
"metric": "sys.cpu.nice",
"timestamp": 1346846400,
"value": 18,
"tags": {
"host": "web01",
"dc": "lga"
}
}
public static String sanitize(String name)
a-z A-Z 0-9 - _ . / name - a metric name, tag key, or tag valuename where unsupported characters are replaced with "-".public String toTelnetPutString()
put (metric-name) (timestamp) (value) (tags)
Example:
put sys.cpu.nice 1346846400 18 host=web01 dc=lga
public String getMetric()
public Long getTimestamp()
public Object getValue()
Copyright © 2016. All rights reserved.