Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalTime(v interface{}) (string, error)
- func Clean(s string) (string, error)
- func FilterTags(r *Request, tr ResponseSet)
- func MustReplace(s, replacement string) string
- func ParseAbsTime(s string) (time.Time, error)
- func ParseTime(v interface{}) (time.Time, error)
- func Replace(s, replacement string) (string, error)
- func ReplaceTags(text string, group TagSet) string
- func TryParseAbsTime(v interface{}) interface{}
- func ValidTag(s string) bool
- type Cache
- type Context
- type DataPoint
- type Duration
- type Host
- type MultiDataPoint
- type Point
- type Query
- type RateOptions
- type Request
- func (r *Request) AutoDownsample(l int) error
- func (r *Request) Query(host string) (ResponseSet, error)
- func (r *Request) QueryResponse(host string, client *http.Client) (*http.Response, error)
- func (r *Request) Search() string
- func (r *Request) SetTime(t time.Time) error
- func (r *Request) String() string
- type RequestError
- type Response
- type ResponseSet
- type TagSet
Constants ¶
const TSDBTimeFormat = "2006/01/02-15:04:05"
Variables ¶
var DefaultClient = &http.Client{ Timeout: time.Minute, }
DefaultClient is the default http client for requests.
Functions ¶
func CanonicalTime ¶
CanonicalTime converts v to a string for use with OpenTSDB's `/` route.
func FilterTags ¶
func FilterTags(r *Request, tr ResponseSet)
FilterTags removes tagks in tr not present in r. Does nothing in the event of multiple queries in the request.
func MustReplace ¶
MustReplace is like Replace, but returns an empty string on error.
func ParseAbsTime ¶
ParseAbsTime returns the time of s, which must be of any non-relative (not "X-ago") format supported by OpenTSDB.
func Replace ¶
Replace removes characters from s that are invalid for OpenTSDB metric and tag values and replaces them. See: http://opentsdb.net/docs/build/html/user_guide/writing.html#metrics-and-tags
func ReplaceTags ¶
ReplaceTags replaces all tag-like strings with tags from the given group. For example, given the string "test.metric{host=*}" and a TagSet with host=test.com, this returns "test.metric{host=test.com}".
func TryParseAbsTime ¶
func TryParseAbsTime(v interface{}) interface{}
Types ¶
type Cache ¶
type Context ¶
type Context interface {
Query(*Request) (ResponseSet, error)
}
type DataPoint ¶
type DataPoint struct { Metric string `json:"metric"` Timestamp int64 `json:"timestamp"` Value interface{} `json:"value"` Tags TagSet `json:"tags"` }
func (*DataPoint) MarshalJSON ¶
type Duration ¶
func GetDuration ¶
GetDuration returns the duration from the request's start to end.
func ParseDuration ¶
ParseDuration is equivalent to time.ParseDuration, but supports time units specified at http://opentsdb.net/docs/build/html/user_guide/query/dates.html.
type MultiDataPoint ¶
type MultiDataPoint []*DataPoint
type Query ¶
type Query struct { Aggregator string `json:"aggregator"` Metric string `json:"metric"` Rate bool `json:"rate,omitempty"` RateOptions RateOptions `json:"rateOptions,omitempty"` Downsample string `json:"downsample,omitempty"` Tags TagSet `json:"tags,omitempty"` }
func ParseQuery ¶
ParseQuery parses OpenTSDB queries of the form: avg:rate:cpu{k=v}. Validation errors will be returned along with a valid Query.
type RateOptions ¶
type Request ¶
type Request struct { Start interface{} `json:"start"` End interface{} `json:"end,omitempty"` Queries []*Query `json:"queries"` NoAnnotations bool `json:"noAnnotations,omitempty"` GlobalAnnotations bool `json:"globalAnnotations,omitempty"` MsResolution bool `json:"msResolution,omitempty"` ShowTSUIDs bool `json:"showTSUIDs,omitempty"` }
func ParseRequest ¶
ParsesRequest parses OpenTSDB requests of the form: start=1h-ago&m=avg:cpu.
func RequestFromJSON ¶
func (*Request) AutoDownsample ¶
AutoDownsample sets the avg downsample aggregator to produce l points.
func (*Request) Query ¶
func (r *Request) Query(host string) (ResponseSet, error)
Query performs a v2 OpenTSDB request to the given host. host should be of the form hostname:port. Uses DefaultClient. Can return a RequestError.
func (*Request) QueryResponse ¶
Query performs a v2 OpenTSDB request to the given host. host should be of the form hostname:port. A nil client uses DefaultClient.
type RequestError ¶
type RequestError struct { Request string Err struct { Code int `json:"code"` Message string `json:"message"` Details string `json:"details"` } `json:"error"` }
func (*RequestError) Error ¶
func (r *RequestError) Error() string
type ResponseSet ¶
type ResponseSet []*Response
type TagSet ¶
func ParseTags ¶
ParseTags parses OpenTSDB tagk=tagv pairs of the form: k=v,m=o. Validation errors do not stop processing, and will return a non-nil TagSet.
func (TagSet) Clean ¶
Clean removes characters from t that are invalid for OpenTSDB metric and tag values. An error is returned if a resulting tag is empty.
func (TagSet) Intersection ¶
Intersection returns the intersection of t and o.
func (TagSet) String ¶
String converts t to an OpenTSDB-style {a=b,c=b} string, alphabetized by key.