Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeDuration(value string, unit string) time.Duration
- func DecodeRequestParams(w http.ResponseWriter, r *http.Request, dst interface{}) error
- func GetAggregators() []string
- func ParseOpenTsdbTimeStamp(str string) int64
- func WarpResultByteCount(response *QueryResponse) int
- type Filter
- type FilterSpec
- type IndexResponse
- type OpenTSDB
- func (o *OpenTSDB) GetReqCounter() prometheus.Counter
- func (c *OpenTSDB) HandleAggregators(responseWriter http.ResponseWriter, request *http.Request)
- func (c *OpenTSDB) HandleConfigFilters(responseWriter http.ResponseWriter, request *http.Request)
- func (c *OpenTSDB) HandleLookup(responseWriter http.ResponseWriter, request *http.Request)
- func (o *OpenTSDB) HandleQuery(w http.ResponseWriter, r *http.Request)
- func (o *OpenTSDB) HandleQueryLast(responseWriter http.ResponseWriter, request *http.Request)
- func (c *OpenTSDB) HandleSuggest(w http.ResponseWriter, r *http.Request)
- type Query
- type QueryRequest
- type QueryResponse
- type RateOptions
- type Response
- type SuggestQuery
- type TSDBTime
- type Translator
- type Validatable
Constants ¶
const ( // WildCard keyword for OpenTSDB filters WildCard = "wildcard" // LiteralOr keyword for OpenTSDB filters LiteralOr = "literal_or" // RegExp keyword for OpenTSDB filters RegExp = "regexp" )
Variables ¶
var OpenTsdbDecoder = schema.NewDecoder()
OpenTsdbDecoder openTSDB schema decoder
Functions ¶
func DecodeDuration ¶
DecodeDuration convert a ts + unit into Duration
func DecodeRequestParams ¶
func DecodeRequestParams(w http.ResponseWriter, r *http.Request, dst interface{}) error
DecodeRequestParams parse a request into a query structure. This handles the fact that OpenTSDB accepts request parameters both at GET query string parameters and as a POSTed JSON structure
func GetAggregators ¶
func GetAggregators() []string
GetAggregators returns the list of supported aggregators
func ParseOpenTsdbTimeStamp ¶
ParseOpenTsdbTimeStamp parse OpenTSDB times
func WarpResultByteCount ¶
func WarpResultByteCount(response *QueryResponse) int
WarpResultByteCount returns the bytes count of a response
Types ¶
type Filter ¶
type Filter struct { Examples string `json:"examples"` Description string `json:"description"` Translator Translator `json:"-"` }
Filter OpenTSDB filters
type FilterSpec ¶
type FilterSpec struct { Type string `json:"type"` TagKey string `json:"tagk"` Expression string `json:"filter"` GroupBy bool `json:"groupBy"` }
FilterSpec the time series emitted in the results. Note that if no filters are specified, all time series for the given metric will be aggregated into the results.
type IndexResponse ¶
type IndexResponse struct {
Index int `json:"index"`
}
IndexResponse query struct containing the query index
type OpenTSDB ¶
type OpenTSDB struct { ReqCounter prometheus.Counter ErrCounter prometheus.Counter WarnCounter prometheus.Counter }
OpenTSDB endpoint
func (*OpenTSDB) GetReqCounter ¶
func (o *OpenTSDB) GetReqCounter() prometheus.Counter
GetReqCounter satisfies the protocol interface
func (*OpenTSDB) HandleAggregators ¶
func (c *OpenTSDB) HandleAggregators(responseWriter http.ResponseWriter, request *http.Request)
HandleAggregators Handle OpenTSDB aggregators
func (*OpenTSDB) HandleConfigFilters ¶
func (c *OpenTSDB) HandleConfigFilters(responseWriter http.ResponseWriter, request *http.Request)
HandleConfigFilters Filters handling
func (*OpenTSDB) HandleLookup ¶
func (c *OpenTSDB) HandleLookup(responseWriter http.ResponseWriter, request *http.Request)
HandleLookup handle OpenTSDB response nolint: golint
func (*OpenTSDB) HandleQuery ¶
func (o *OpenTSDB) HandleQuery(w http.ResponseWriter, r *http.Request)
HandleQuery Entry point of an OpenTSDB request
func (*OpenTSDB) HandleQueryLast ¶
func (o *OpenTSDB) HandleQueryLast(responseWriter http.ResponseWriter, request *http.Request)
HandleQueryLast is the handler for /api/query/last
func (*OpenTSDB) HandleSuggest ¶
func (c *OpenTSDB) HandleSuggest(w http.ResponseWriter, r *http.Request)
HandleSuggest main /suggest handler nolint: gocyclo
type Query ¶
type Query struct { // The name of an aggregation function to use Aggregator string `json:"aggregator"` // The name of a metric stored in the system Metric string `json:"metric"` // Whether or not the data should be converted into deltas before returning Rate *bool `json:"rate"` // Monotonically increasing counter handling options RateOptions *RateOptions `json:"rateOptions"` // An optional downsampling function to reduce the amount of data returned Downsample *string `json:"downsample"` // To drill down to specific timeseries or group results by tag Tags map[string]string `json:"tags"` // Filters the timeseries emitted in the results Filters []FilterSpec `json:"filters"` // Returns the series that include only the tag keys provided in the filters. ExplicitTags bool `json:"explicitTags"` }
Query an OpenTSDB single query
type QueryRequest ¶
type QueryRequest struct { // The start time for the query Start *TSDBTime `json:"start"` // An end time for the query. Default value = time.Now() End *TSDBTime `json:"end"` NoTimeRange bool `json:"-"` // One or more sub queries used to select the time series to return Queries []*Query `json:"queries"` // Whether or not to output data point timestamps in milliseconds or seconds MSResolution *bool `json:"msResolution"` Delete bool `json:"delete"` }
QueryRequest an OpenTSDB valid request
func (*QueryRequest) Validate ¶
func (handler *QueryRequest) Validate() error
Validate is the implementation of Validate for QueryRequest
type QueryResponse ¶
type QueryResponse struct { Metric string `json:"metric"` Tags map[string]string `json:"tags"` Query IndexResponse `json:"query"` AggregateTags []string `json:"aggregateTags"` DPs map[string]float64 `json:"dps"` }
QueryResponse an OpenTSDB Query response
type RateOptions ¶
type RateOptions struct { // Whether or not the underlying data is a monotonically increasing counter that may roll over Counter bool `json:"counter"` // A positive integer representing the maximum value for the counter CounterMax *int64 `json:"counterMax"` // An optional value that, when exceeded, will cause the aggregator to return // a 0 instead of the calculated rate ResetValue *int64 `json:"resetValue"` // Optional: Whether or not to simply drop rolled-over or reset data points. DropResets bool `json:"dropResets"` }
RateOptions monotonically increasing counter handling options
type Response ¶
type Response struct { PointsCount int `json:"pointsCount"` Buffer json.RawMessage `json:"series"` }
Response OpenTSDB response struct
type SuggestQuery ¶
type SuggestQuery struct { Type string `schema:"type" json:"type"` // "metric", "tagk" or "tagv" Q string `schema:"q" json:"q,omitempty"` Max int `schema:"max" json:"max,omitempty"` }
SuggestQuery is the OpenTSDB suggest query input
type TSDBTime ¶
TSDBTime is overloading json/schema time parsing to support opentsdb format
func (*TSDBTime) Parse ¶
Parse a string representing a date See http://opentsdb.net/docs/build/html/user_guide/query/dates.html
func (*TSDBTime) UnmarshalJSON ¶
UnmarshalJSON is a Custom json parser
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable is the interface for the Validate method