client

package
v0.0.0-...-d7678fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2022 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

aggregators.go contains the structs and methods for the implementation of /api/aggregators.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

annotation.go contains the structs and methods for the implementation of /api/annotation and /api/annotation/bulk.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

client.go contains the global interface and implementation struct definition of the OpenTSDB Client, as well as the common private and public methods used by all the rest-api implementation files, whose names are just like put.go, query.go, and so on.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

config.go contains the structs and methods for the implementation of /api/config and /api/config/filters.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

dropcaches.go contains the structs and methods for the implementation of /api/dropcaches.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

put.go contains the structs and methods for the implementation of /api/put.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

query.go contains the structs and methods for the implementation of /api/query.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

query_last.go contains the structs and methods for the implementation of /api/query/last, which is fully supported since v2.2 of opentsdb.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

serializers.go contains the structs and methods for the implementation of /api/serializers.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

stats.go contains the structs and methods for the implementation of /api/stats.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

suggest.go contains the structs and methods for the implementation of /api/suggest.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

Every metric, tag name and tag value is associated with a unique identifier (UID). Internally, the UID is a binary array assigned to a text value the first time it is encountered or via an explicit assignment request. This endpoint provides utilities for managing UIDs and their associated data. Please see the UID endpoint TOC below for information on what functions are implemented.

UIDs exposed via the API are encoded as hexadecimal strings. The UID 42 would be expressed as 00002A given the default UID width of 3 bytes. You may also edit meta data associated with timeseries or individual UID objects via the UID endpoint.

uid.go contains the structs and methods for the implementation of /api/uid/tsmeta, /api/uid/assign, /api/uid/uidmeta.

Copyright 2015 opentsdb-goclient authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package client defines the client and the corresponding rest api implementaion of OpenTSDB.

version.go contains the structs and methods for the implementation of /api/version.

Index

Constants

View Source
const (
	DefaultDialTimeout = 5 * time.Second
	KeepAliveTimeout   = 30 * time.Second
	GetMethod          = "GET"
	PostMethod         = "POST"
	PutMethod          = "PUT"
	DeleteMethod       = "DELETE"

	PutPath            = "/api/put"
	PutRespWithSummary = "summary"
	PutRespWithDetails = "details"

	QueryPath     = "/api/query"
	QueryLastPath = "/api/query/last"
	// The three keys in the rateOption parameter of the QueryParam
	QueryRateOptionCounter    = "counter"    // The corresponding value type is bool
	QueryRateOptionCounterMax = "counterMax" // The corresponding value type is int,int64
	QueryRateOptionResetValue = "resetValue" // The corresponding value type is int,int64

	AggregatorPath  = "/api/aggregators"
	ConfigPath      = "/api/config"
	SerializersPath = "/api/serializers"
	StatsPath       = "/api/stats"
	SuggestPath     = "/api/suggest"
	// Only the one of the three query type can be used in SuggestParam, UIDMetaData:
	TypeMetrics = "metrics"
	TypeTagk    = "tagk"
	TypeTagv    = "tagv"

	VersionPath        = "/api/version"
	DropcachesPath     = "/api/dropcaches"
	AnnotationPath     = "/api/annotation"
	AnQueryStartTime   = "start_time"
	AnQueryTSUid       = "tsuid"
	BulkAnnotationPath = "/api/annotation/bulk"
	UIDMetaDataPath    = "/api/uid/uidmeta"
	UIDAssignPath      = "/api/uid/assign"
	TSMetaDataPath     = "/api/uid/tsmeta"

	// The above three constants are used in /put
	DefaultMaxPutPointsNum = 75
	DefaultDetectDeltaNum  = 3
	// Unit is bytes, and assumes that config items of 'tsd.http.request.enable_chunked = true'
	// and 'tsd.http.request.max_chunk = 40960' are all in the opentsdb.conf:
	DefaultMaxContentLength = 40960
)

Variables

View Source
var (
	DefaultTransport = &http.Transport{
		MaxIdleConnsPerHost: 10,
		Dial: (&net.Dialer{
			Timeout:   DefaultDialTimeout,
			KeepAlive: KeepAliveTimeout,
		}).Dial,
	}
)

Functions

func HandleResponseBody

func HandleResponseBody(r Response, method, url string, body io.ReadCloser) error

Types

type AggregatorsResponse

type AggregatorsResponse struct {
	StatusCode  int
	Aggregators []string `json:"aggregators"`
}

AggregatorsResponse acts as the implementation of Response in the /api/aggregators scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/aggregators.html).

func (*AggregatorsResponse) GetCustomParser

func (aggreResp *AggregatorsResponse) GetCustomParser() func(respCnt []byte) error

func (*AggregatorsResponse) SetStatus

func (aggreResp *AggregatorsResponse) SetStatus(code int)

func (*AggregatorsResponse) String

func (aggreResp *AggregatorsResponse) String() string

type Annotation

type Annotation struct {
	// A Unix epoch timestamp, in seconds, marking the time when the annotation event should be recorded.
	// The value is required with non-zero value.
	StartTime int64 `json:"startTime,omitempty"`

	// An optional end time for the event if it has completed or been resolved.
	EndTime int64 `json:"endTime,omitempty"`

	// A TSUID if the annotation is associated with a timeseries.
	// This may be optional if the note was for a global event
	Tsuid string `json:"tsuid,omitempty"`

	// An optional brief description of the event. As this may appear on GnuPlot graphs,
	// the description should be very short, ideally less than 25 characters.
	Description string `json:"description,omitempty"`

	// An optional detailed notes about the event
	Notes string `json:"notes,omitempty"`

	// An optional key/value map to store custom fields and values
	Custom map[string]string `json:"custom,omitempty"`
}

Annotation is the structure used to hold the querying parameters when calling /api/annotation. Each attributes in Annotation matches the definition in (http://opentsdb.net/docs/build/html/api_http/annotation/index.html).

Annotations are very basic objects used to record a note of an arbitrary event at some point, optionally associated with a timeseries. Annotations are not meant to be used as a tracking or event based system, rather they are useful for providing links to such systems by displaying a notice on graphs or via API query calls.

type AnnotationResponse

type AnnotationResponse struct {
	StatusCode int
	Annotation
	ErrorInfo map[string]interface{} `json:"error,omitempty"`
}

AnnotationResponse acts as the implementation of Response in the /api/annotation scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/aggregators.html).

func (*AnnotationResponse) GetCustomParser

func (annotResp *AnnotationResponse) GetCustomParser() func(respCnt []byte) error

func (*AnnotationResponse) SetStatus

func (annotResp *AnnotationResponse) SetStatus(code int)

func (*AnnotationResponse) String

func (annotResp *AnnotationResponse) String() string

type BulkAnnoDeleteInfo

type BulkAnnoDeleteInfo struct {
	// A list of TSUIDs with annotations that should be deleted. This may be empty
	// or null (for JSON) in which case the global flag should be set.
	Tsuids []string `json:"tsuids,omitempty"`

	// A timestamp for the start of the request.
	StartTime int64 `json:"startTime,omitempty"`

	// An optional end time for the event if it has completed or been resolved.
	EndTime int64 `json:"endTime,omitempty"`

	// An optional flag indicating whether or not global annotations should be deleted for the range
	Global bool `json:"global,omitempty"`
}

type BulkAnnotatResponse

type BulkAnnotatResponse struct {
	StatusCode        int
	UpdateAnnotations []Annotation           `json:"InvolvedAnnotations,omitempty"`
	ErrorInfo         map[string]interface{} `json:"error,omitempty"`
	BulkDeleteResp
}

BulkAnnotatResponse acts as the implementation of Response in the /api/annotation/bulk scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/annotation/bulk.html) for both bulk update and delete scenes.

func (*BulkAnnotatResponse) GetCustomParser

func (bulkAnnotResp *BulkAnnotatResponse) GetCustomParser() func(respCnt []byte) error

func (*BulkAnnotatResponse) SetStatus

func (bulkAnnotResp *BulkAnnotatResponse) SetStatus(code int)

func (*BulkAnnotatResponse) String

func (bulkAnnotResp *BulkAnnotatResponse) String() string

type BulkDeleteResp

type BulkDeleteResp struct {
	BulkAnnoDeleteInfo

	// Total number of annotations to be deleted successfully for current bulk
	// delete operation. The value is only used in the reponse of bulk deleting,
	// not in the bulk deleting parameters.
	TotalDeleted int64 `json:"totalDeleted,omitempty"`
}

type Client

type Client interface {

	// Ping detects whether the target OpenTSDB is reachable or not.
	// If error occurs during the detection, an error instance will be returned, or nil otherwise.
	Ping() error

	// Put is the implementation of 'POST /api/put' endpoint.
	// This endpoint allows for storing data in OpenTSDB over HTTP as an alternative to the Telnet interface.
	//
	// datas is a slice of DataPoint holding at least one instance.
	// queryParam can only be github.com/bluebreezecf/opentsdb-goclient/client.PutRespWithSummary,
	// github.com/bluebreezecf/opentsdb-goclient/client.PutRespWithDetails or the empty string "";
	// It means get put summary response info by using PutRespWithSummary, and
	// with PutRespWithDetails means get put detailed response.
	//
	// When put operation is successful, a pointer of PutResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when the given parameters
	// are invalid, it failed to parese the response, or OpenTSDB is un-connectable right now.
	Put(datas []DataPoint, queryParam string) (*PutResponse, error)

	// Query is the implementation of 'GET /api/query' endpoint.
	// It is probably the most useful endpoint in the API, /api/query enables extracting data from the storage
	// system in various formats determined by the serializer selected.
	//
	// param is a instance of QueryParam holding current query parameters.
	//
	// When query operation is successful, a pointer of QueryResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when the given parameter
	// is invalid, it failed to parese the response, or OpenTSDB is un-connectable right now.
	Query(param QueryParam) (*QueryResponse, error)

	// QueryStream is the streaming implementation of 'GET /api/query'.
	// It will return results over the channel, as they are parsed, resulting in
	// more predictable memory usage.
	QueryStream(param QueryParam, outCh chan<- *QueryRespItem) error

	// QueryLast is the implementation of 'GET /api/query/last' endpoint.
	// It is introduced firstly in v2.1, and fully supported in v2.2. So it should be aware that this api works
	// well since v2.2 of opentsdb.
	//
	// param is a instance of QueryLastParam holding current query parameters.
	//
	// When query operation is successful, a pointer of QueryLastResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when the given parameter
	// is invalid, it failed to parese the response, or OpenTSDB is un-connectable right now.
	QueryLast(param QueryLastParam) (*QueryLastResponse, error)

	// Aggregators is the implementation of 'GET /api/aggregators' endpoint.
	// It simply lists the names of implemented aggregation functions used in timeseries queries.
	//
	// When query operation is successful, a pointer of AggregatorsResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Aggregators() (*AggregatorsResponse, error)

	// Config is the implementation of 'GET /api/config' endpoint.
	// It returns information about the running configuration of the TSD.
	// It is read only and cannot be used to set configuration options.
	//
	// When query operation is successful, a pointer of ConfigResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Config() (*ConfigResponse, error)

	// Serializers is the implementation of 'GET /api/serializers' endpoint.
	// It lists the serializer plugins loaded by the running TSD. Information given includes the name,
	// implemented methods, content types and methods.
	//
	// When query operation is successful, a pointer of SerialResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Serializers() (*SerialResponse, error)

	// Stats is the implementation of 'GET /api/stats' endpoint.
	// It provides a list of statistics for the running TSD. These statistics are automatically recorded
	// by a running TSD every 5 minutes but may be accessed via this endpoint. All statistics are read only.
	//
	// When query operation is successful, a pointer of StatsResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Stats() (*StatsResponse, error)

	// Suggest is the implementation of 'GET /api/suggest' endpoint.
	// It provides a means of implementing an "auto-complete" call that can be accessed repeatedly as a user
	// types a request in a GUI. It does not offer full text searching or wildcards, rather it simply matches
	// the entire string passed in the query on the first characters of the stored data.
	// For example, passing a query of type=metrics&q=sys will return the top 25 metrics in the system that start with sys.
	// Matching is case sensitive, so sys will not match System.CPU. Results are sorted alphabetically.
	//
	// sugParm is an instance of SuggestParam storing parameters by invoking /api/suggest.
	//
	// When query operation is successful, a pointer of SuggestResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	Suggest(sugParm SuggestParam) (*SuggestResponse, error)

	// Version is the implementation of 'GET /api/version' endpoint.
	// It returns information about the running version of OpenTSDB.
	//
	// When query operation is successful, a pointer of VersionResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Version() (*VersionResponse, error)

	// Dropcaches is the implementation of 'GET /api/dropcaches' endpoint.
	// It purges the in-memory data cached in OpenTSDB. This includes all UID to name
	// and name to UID maps for metrics, tag names and tag values.
	//
	// When query operation is successful, a pointer of DropcachesResponse will be returned with the corresponding
	// status code and response info. Otherwise, an error instance will be returned, when it failed to parese the
	// response, or OpenTSDB is un-connectable right now.
	Dropcaches() (*DropcachesResponse, error)

	// QueryAnnotation is the implementation of 'GET /api/annotation' endpoint.
	// It retrieves a single annotation stored in the OpenTSDB backend.
	//
	// queryAnnoParam is a map storing parameters of a target queried annotation.
	// The key can be such as client.AnQueryStartTime, client.AnQueryTSUid.
	//
	// When query operation is handlering properly by the OpenTSDB backend, a pointer of AnnotationResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	QueryAnnotation(queryAnnoParam map[string]interface{}) (*AnnotationResponse, error)

	// UpdateAnnotation is the implementation of 'POST /api/annotation' endpoint.
	// It creates or modifies an annotation stored in the OpenTSDB backend.
	//
	// annotation is an annotation to be processed in the OpenTSDB backend.
	//
	// When modification operation is handlering properly by the OpenTSDB backend, a pointer of AnnotationResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	UpdateAnnotation(annotation Annotation) (*AnnotationResponse, error)

	// DeleteAnnotation is the implementation of 'DELETE /api/annotation' endpoint.
	// It deletes an annotation stored in the OpenTSDB backend.
	//
	// annotation is an annotation to be deleted in the OpenTSDB backend.
	//
	// When deleting operation is handlering properly by the OpenTSDB backend, a pointer of AnnotationResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	DeleteAnnotation(annotation Annotation) (*AnnotationResponse, error)

	// BulkUpdateAnnotations is the implementation of 'POST /api/annotation/bulk' endpoint.
	// It creates or modifies a list of annotation stored in the OpenTSDB backend.
	//
	// annotations is a list of annotations to be processed (to be created or modified) in the OpenTSDB backend.
	//
	// When bulk modification operation is handlering properly by the OpenTSDB backend, a pointer of BulkAnnotatResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	BulkUpdateAnnotations(annotations []Annotation) (*BulkAnnotatResponse, error)

	// BulkDeleteAnnotations is the implementation of 'DELETE /api/annotation/bulk' endpoint.
	// It deletes a list of annotation stored in the OpenTSDB backend.
	//
	// bulkDelParam contains the bulk deleting info in current invoking 'DELETE /api/annotation/bulk'.
	//
	// When bulk deleting operation is handlering properly by the OpenTSDB backend, a pointer of BulkAnnotatResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	BulkDeleteAnnotations(bulkDelParam BulkAnnoDeleteInfo) (*BulkAnnotatResponse, error)

	// QueryUIDMetaData is the implementation of 'GET /api/uid/uidmeta' endpoint.
	// It retrieves a single UIDMetaData stored in the OpenTSDB backend with the given query parameters.
	//
	// metaQueryParam is a map storing parameters of a target queried UIDMetaData.
	// It must contain two key/value pairs with the key "uid" and "type".
	// "type" should be one of client.TypeMetrics ("metric"), client.TypeTagk ("tagk"), and client.TypeTagv ("tagv")
	//
	// When query operation is handlering properly by the OpenTSDB backend, a pointer of UIDMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	QueryUIDMetaData(metaQueryParam map[string]string) (*UIDMetaDataResponse, error)

	// UpdateUIDMetaData is the implementation of 'POST /api/uid/uidmeta' endpoint.
	// It modifies a UIDMetaData.
	//
	// uidMetaData is an instance of UIDMetaData to be modified
	//
	// When update operation is handlering properly by the OpenTSDB backend, a pointer of UIDMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	UpdateUIDMetaData(uidMetaData UIDMetaData) (*UIDMetaDataResponse, error)

	// DeleteUIDMetaData is the implementation of 'DELETE /api/uid/uidmeta' endpoint.
	// It deletes a target UIDMetaData.
	//
	// uidMetaData is an instance of UIDMetaData whose correspance is to be deleted.
	// The values of uid and type in uidMetaData is required.
	//
	// When delete operation is handlering properly by the OpenTSDB backend, a pointer of UIDMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	DeleteUIDMetaData(uidMetaData UIDMetaData) (*UIDMetaDataResponse, error)

	// AssignUID is the implementation of 'POST /api/uid/assigin' endpoint.
	// It enables assigning UIDs to new metrics, tag names and tag values. Multiple types and names can be provided
	// in a single call and the API will process each name individually, reporting which names were assigned UIDs
	// successfully, along with the UID assigned, and which failed due to invalid characters or had already been assigned.
	// Assignment can be performed via query string or content data.
	//
	// assignParam is an instance of UIDAssignParam holding the parameters to invoke 'POST /api/uid/assigin'.
	//
	// When assigin operation is handlering properly by the OpenTSDB backend, a pointer of UIDAssignResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	AssignUID(assignParam UIDAssignParam) (*UIDAssignResponse, error)

	// QueryTSMetaData is the implementation of 'GET /api/uid/tsmeta' endpoint.
	// It retrieves a single TSMetaData stored in the OpenTSDB backend with the given query parameters.
	//
	// tsuid is a tsuid of a target queried TSMetaData.
	//
	// When query operation is handlering properly by the OpenTSDB backend, a pointer of TSMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, if the given parameter is invalid,
	// or when it failed to parese the response, or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	QueryTSMetaData(tsuid string) (*TSMetaDataResponse, error)

	// UpdateTSMetaData is the implementation of 'POST /api/uid/tsmeta' endpoint.
	// It modifies a target TSMetaData with the given fields.
	//
	// tsMetaData is an instance of UIDMetaData whose correspance is to be modified
	//
	// When update operation is handlering properly by the OpenTSDB backend, a pointer of TSMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, when it failed to parese the response,
	// or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	UpdateTSMetaData(tsMetaData TSMetaData) (*TSMetaDataResponse, error)

	// DeleteTSMetaData is the implementation of 'DELETE /api/uid/tsmeta' endpoint.
	// It deletes a target TSMetaData.
	//
	// tsMetaData is an instance of UIDMetaData whose correspance is to be deleted
	//
	// When delete operation is handlering properly by the OpenTSDB backend, a pointer of TSMetaDataResponse
	// will be returned with the corresponding status code and response info (including the potential error
	// messages replied by OpenTSDB).
	//
	// Otherwise, an error instance will be returned, when it failed to parese the response,
	// or OpenTSDB is un-connectable right now.
	//
	// Note that: the returned non-nil error instance is only responsed by opentsdb-client, not the OpenTSDB backend.
	DeleteTSMetaData(tsMetaData TSMetaData) (*TSMetaDataResponse, error)
}

Client defines the sdk methods, by which other go applications can commnicate with the OpenTSDB via the pre-defined rest-apis. Each method defined in the interface of Client is in the correspondance a rest-api definition in (http://opentsdb.net/docs/build/html/api_http/index.html#api-endpoints).

func NewClient

func NewClient(opentsdbCfg config.OpenTSDBConfig) (Client, error)

NewClient creates an instance of http client which implements the pre-defined rest apis of OpenTSDB. A non-nil error instance returned means currently the target OpenTSDB designated with the given endpoint is not connectable.

type ClientContext

type ClientContext interface {
	// WithContext returns a Client that is associated with the given context.
	// Use this to pass a context to underlying transport (e.g. to specify a
	// deadline).
	WithContext(ctx context.Context) Client
	Client
}

ClientContext implements the Client interface and additionally provides a way to return a client that is associated with the given context.

func NewClientContext

func NewClientContext(opentsdbCfg config.OpenTSDBConfig) (ClientContext, error)

type ConfigResponse

type ConfigResponse struct {
	StatusCode int
	Configs    map[string]string `json:"configs"`
}

func (*ConfigResponse) GetCustomParser

func (cfgResp *ConfigResponse) GetCustomParser() func(respCnt []byte) error

func (*ConfigResponse) SetStatus

func (cfgResp *ConfigResponse) SetStatus(code int)

func (*ConfigResponse) String

func (cfgResp *ConfigResponse) String() string

type DataPoint

type DataPoint struct {
	// The name of the metric which is about to be stored, and is required with non-empty value.
	Metric string `json:"metric"`

	// A Unix epoch style timestamp in seconds or milliseconds.
	// The timestamp must not contain non-numeric characters.
	// One can use time.Now().Unix() to set this attribute.
	// This attribute is also required with non-zero value.
	Timestamp int64 `json:"timestamp"`

	// The real type of Value only could be int, int64, float64, or string, and is required.
	Value interface{} `json:"value"`

	// A map of tag name/tag value pairs. At least one pair must be supplied.
	// Don't use too many tags, keep it to a fairly small number, usually up to 4 or 5 tags
	// (By default, OpenTSDB supports a maximum of 8 tags, which can be modified by add
	// configuration item 'tsd.storage.max_tags' in opentsdb.conf).
	Tags map[string]string `json:"tags"`
}

DataPoint is the structure used to hold the values of a metric item. Each attributes in DataPoint matches the definition in (http://opentsdb.net/docs/build/html/api_http/put.html).

func (*DataPoint) String

func (data *DataPoint) String() string

type DataPointByTimestamp

type DataPointByTimestamp []*DataPoint

DataPointByTimestamp implements sort.Interface for sorting by timestamp.

func (DataPointByTimestamp) Len

func (dp DataPointByTimestamp) Len() int

func (DataPointByTimestamp) Less

func (dp DataPointByTimestamp) Less(i, j int) bool

func (DataPointByTimestamp) Swap

func (dp DataPointByTimestamp) Swap(i, j int)

type DataPoints

type DataPoints struct {
	// contains filtered or unexported fields
}

func (*DataPoints) UnmarshalJSON

func (dps *DataPoints) UnmarshalJSON(json []byte) error

type DropcachesResponse

type DropcachesResponse struct {
	StatusCode     int
	DropcachesInfo map[string]string `json:"DropcachesInfo"`
}

func (*DropcachesResponse) GetCustomParser

func (dropResp *DropcachesResponse) GetCustomParser() func(respCnt []byte) error

func (*DropcachesResponse) SetStatus

func (dropResp *DropcachesResponse) SetStatus(code int)

func (*DropcachesResponse) String

func (dropResp *DropcachesResponse) String() string

type Filter

type Filter struct {
	// The name of the filter to invoke. The value is required with a non-empty
	// value in the range of calling /api/config/filters.
	Type string `json:"type"`

	// The tag key to invoke the filter on, required with a non-empty value
	Tagk string `json:"tagk"`

	// The filter expression to evaluate and depends on the filter being used, required with a non-empty value
	FilterExp string `json:"filter"`

	// An optional value to show whether or not to group the results by each value matched by the filter.
	// By default all values matching the filter will be aggregated into a single series.
	GroupBy bool `json:"groupBy"`
}

Filter is the structure used to hold the filter parameters when calling /api/query. Each attributes in Filter matches the definition in (http://opentsdb.net/docs/build/html/api_http/query/index.html).

type MetricInfo

type MetricInfo struct {
	Metric    string            `json:"metric"`
	Timestamp int64             `json:"timestamp"`
	Value     interface{}       `json:"value"`
	Tags      map[string]string `json:"tags"`
}

type PutError

type PutError struct {
	Data     DataPoint `json:"datapoint"`
	ErrorMsg string    `json:"error"`
}

PutError holds the error message for each putting DataPoint instance. Only calling PUT() with "details" query parameter, the reponse of the failed put data operation can contain an array PutError instance to show the details for each failure.

func (*PutError) String

func (putErr *PutError) String() string

type PutResponse

type PutResponse struct {
	StatusCode int
	Failed     int64      `json:"failed"`
	Success    int64      `json:"success"`
	Errors     []PutError `json:"errors,omitempty"`
}

PutResponse acts as the implementation of Response in the /api/put scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/put.html).

func (*PutResponse) GetCustomParser

func (putResp *PutResponse) GetCustomParser() func(respCnt []byte) error

func (*PutResponse) SetStatus

func (putResp *PutResponse) SetStatus(code int)

func (*PutResponse) String

func (putResp *PutResponse) String() string

type QueryError

type QueryError map[string]interface{}

QueryError is the OpenTSDB error reply. Fields are 'code', 'message', etc.

func (QueryError) Error

func (qe QueryError) Error() string

type QueryLastParam

type QueryLastParam struct {
	// One or more sub queries used to select the time series to return.
	// These may be metric m or TSUID tsuids queries
	// The value is required with at least one element
	Queries []SubQueryLast `json:"queries"`

	// An optional flag is used to determine whether or not to resolve the TSUIDs of results to
	// their metric and tag names. The default value is false.
	ResolveNames bool `json:"resolveNames"`

	// An optional number of hours is used to search in the past for data. If set to 0 then the
	// timestamp of the meta data counter for the time series is used.
	BackScan int `json:"backScan"`
}

QueryLastParam is the structure used to hold the querying parameters when calling /api/query/last. Each attributes in QueryLastParam matches the definition in (http://opentsdb.net/docs/build/html/api_http/query/last.html).

func (*QueryLastParam) String

func (query *QueryLastParam) String() string

type QueryLastResponse

type QueryLastResponse struct {
	StatusCode    int
	QueryRespCnts []QueryRespLastItem    `json:"queryRespCnts,omitempty"`
	ErrorMsg      map[string]interface{} `json:"error"`
}

QueryLastResponse acts as the implementation of Response in the /api/query/last scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/query/last.html).

func (*QueryLastResponse) GetCustomParser

func (queryLastResp *QueryLastResponse) GetCustomParser() func(respCnt []byte) error

func (*QueryLastResponse) SetStatus

func (queryLastResp *QueryLastResponse) SetStatus(code int)

func (*QueryLastResponse) String

func (queryLastResp *QueryLastResponse) String() string

type QueryParam

type QueryParam struct {
	// The start time for the query. This can be a relative or absolute timestamp.
	// The data type can only be string, int, or int64.
	// The value is required with non-zero value of the target type.
	Start interface{} `json:"start"`

	// An end time for the query. If not supplied, the TSD will assume the local
	// system time on the server. This may be a relative or absolute timestamp.
	// The data type can only be string, or int64.
	// The value is optional.
	End interface{} `json:"end,omitempty"`

	// One or more sub queries used to select the time series to return.
	// These may be metric m or TSUID tsuids queries
	// The value is required with at least one element
	Queries []SubQuery `json:"queries"`

	// An optional value is used to show whether or not to return annotations with a query.
	// The default is to return annotations for the requested timespan but this flag can disable the return.
	// This affects both local and global notes and overrides globalAnnotations
	NoAnnotations bool `json:"noAnnotations,omitempty"`

	// An optional value is used to show whether or not the query should retrieve global
	// annotations for the requested timespan.
	GlobalAnnotations bool `json:"globalAnnotations,omitempty"`

	// An optional value is used to show whether or not to output data point timestamps in milliseconds or seconds.
	// If this flag is not provided and there are multiple data points within a second,
	// those data points will be down sampled using the query's aggregation function.
	MsResolution bool `json:"msResolution,omitempty"`

	// An optional value is used to show whether or not to output the TSUIDs associated with timeseries in the results.
	// If multiple time series were aggregated into one set, multiple TSUIDs will be returned in a sorted manner.
	ShowTSUIDs bool `json:"showTSUIDs,omitempty"`

	// An optional value is used to show whether or not to return the original sub query with the query results.
	// If the request contains many sub queries then this is a good way to determine which results belong to which sub query.
	// Note that in the case of a * or wildcard query, this can produce a lot of duplicate output.
	ShowQuery bool `json:"showQuery,omitempty"`

	// An optional value is used to show whether or not can be paased to the JSON with a POST to delete any data point
	// that match the given query.
	Delete bool `json:"delete,omitempty"`
}

QueryParam is the structure used to hold the querying parameters when calling /api/query. Each attributes in QueryParam matches the definition in (http://opentsdb.net/docs/build/html/api_http/query/index.html).

func (*QueryParam) String

func (query *QueryParam) String() string

type QueryRespItem

type QueryRespItem struct {
	// Name of the metric retreived for the time series
	Metric string `json:"metric"`

	// A list of tags only returned when the results are for a single time series.
	// If results are aggregated, this value may be null or an empty map
	Tags map[string]string `json:"tags"`

	// If more than one timeseries were included in the result set, i.e. they were aggregated,
	// this will display a list of tag names that were found in common across all time series.
	// Note that: Api Doc uses 'aggreatedTags', but actual response uses 'aggregateTags'
	AggregatedTags []string `json:"aggregateTags"`

	// Retrieved datapoints after being processed by the aggregators. Each data point consists
	// of a timestamp and a value, the format determined by the serializer.
	// For the JSON serializer, the timestamp will always be a Unix epoch style integer followed
	// by the value as an integer or a floating point.
	// For example, the default output is "dps"{"<timestamp>":<value>}.
	// By default the timestamps will be in seconds. If the msResolution flag is set, then the
	// timestamps will be in milliseconds.
	//
	// Use '(qri *QueryRespItem) GetDataPoints() []*DataPoint' to acquire the real
	// ascending datapoints.
	Dps DataPoints `json:"dps"`

	// If the query retrieved annotations for timeseries over the requested timespan, they will
	// be returned in this group. Annotations for every timeseries will be merged into one set
	// and sorted by start_time. Aggregator functions do not affect annotations, all annotations
	// will be returned for the span.
	// The value is optional.
	Annotations []Annotation `json:"annotations,omitempty"`

	// If requested by the user, the query will scan for global annotations during
	// the timespan and the results returned in this group.
	// The value is optional.
	GlobalAnnotations []Annotation `json:"globalAnnotations,omitempty"`

	// The query that this result is in relation to.
	Query SubQuery `json:"query"`

	// If an error occurred (only used for QueryStream, if the data is malformed while parsing).
	Error error
}

QueryRespItem acts as the implementation of Response in the /api/query scene. It holds the response item defined in the (http://opentsdb.net/docs/build/html/api_http/query/index.html).

func (*QueryRespItem) GetDataPoints

func (qri *QueryRespItem) GetDataPoints() []*DataPoint

GetDataPoints returns the real ascending datapoints from the information of the related QueryRespItem.

func (*QueryRespItem) GetLatestDataPoint

func (qri *QueryRespItem) GetLatestDataPoint() *DataPoint

GetLatestDataPoint returns latest datapoint for the related QueryRespItem instance.

type QueryRespLastItem

type QueryRespLastItem struct {
	// Name of the metric retreived for the time series.
	// Only returned if resolve was set to true.
	Metric string `json:"metric"`

	// A list of tags only returned when the results are for a single time series.
	// If results are aggregated, this value may be null or an empty map.
	// Only returned if resolve was set to true.
	Tags map[string]string `json:"tags"`

	// A Unix epoch timestamp, in milliseconds, when the data point was written.
	Timestamp int64 `json:"timestamp"`

	// The value of the data point enclosed in quotation marks as a string
	Value string `json:"value"`

	// The hexadecimal TSUID for the time series
	Tsuid string `json:"tsuid"`
}

QueryRespLastItem acts as the implementation of Response in the /api/query/last scene. It holds the response item defined in the (http://opentsdb.net/docs/build/html/api_http/query/last.html).

type QueryResponse

type QueryResponse struct {
	StatusCode    int
	QueryRespCnts []QueryRespItem `json:"queryRespCnts"`
	ErrorMsg      QueryError      `json:"error"`
}

QueryResponse acts as the implementation of Response in the /api/query scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/query/index.html).

func (*QueryResponse) GetCustomParser

func (queryResp *QueryResponse) GetCustomParser() func(respCnt []byte) error

func (*QueryResponse) SetStatus

func (queryResp *QueryResponse) SetStatus(code int)

func (*QueryResponse) String

func (queryResp *QueryResponse) String() string

type QueryStreamResponse

type QueryStreamResponse struct {
	// contains filtered or unexported fields
}

func (*QueryStreamResponse) HandleBody

func (qs *QueryStreamResponse) HandleBody(body io.ReadCloser) error

func (*QueryStreamResponse) SetStatus

func (qs *QueryStreamResponse) SetStatus(code int)

type Response

type Response interface {
	ResponseBase

	// GetCustomParser can be used to retrive a custom-defined parser.
	// Returning nil means current specific Response instance doesn't
	// need a custom-defined parse process, and just uses the default
	// json unmarshal method to parse the contents of the http response.
	GetCustomParser() func(respCnt []byte) error

	// Return the contents of the specific Response instance with
	// the string format
	String() string
}

Response defines the common behaviours all the specific response for different rest-apis shound obey. For lower level access ResponseStream is available which makes the body directly available. Currently it is an abstraction used in (*clientImpl).sendRequest() to stored the different kinds of response contents for all the rest-apis.

type ResponseBase

type ResponseBase interface {
	// SetStatus can be used to set the actual http status code of
	// the related http response for the specific Response instance
	SetStatus(code int)
}

type ResponseStream

type ResponseStream interface {
	ResponseBase

	// HandleBody is given the response.Body. It must call Close on the ReadCloser
	// when finished (which can be after the method returns).
	HandleBody(io.ReadCloser) error
}

ResponseStream represents a streaming response.

type SerialResponse

type SerialResponse struct {
	StatusCode  int
	Serializers []Serializer `json:"Serializers"`
}

func (*SerialResponse) GetCustomParser

func (serialResp *SerialResponse) GetCustomParser() func(respCnt []byte) error

func (*SerialResponse) SetStatus

func (serialResp *SerialResponse) SetStatus(code int)

func (*SerialResponse) String

func (serialResp *SerialResponse) String() string

type Serializer

type Serializer struct {
	SerializerName string   `json:"serializer"`
	Formatters     []string `json:"formatters"`
	Parsers        []string `json:"parsers"`
	Class          string   `json:"class,omitempty"`
	ResContType    string   `json:"response_content_type,omitempty"`
	ReqContType    string   `json:"request_content_type,omitempty"`
}

type StatsResponse

type StatsResponse struct {
	StatusCode int
	Metrics    []MetricInfo `json:"Metrics"`
}

func (*StatsResponse) GetCustomParser

func (statsResp *StatsResponse) GetCustomParser() func(respCnt []byte) error

func (*StatsResponse) SetStatus

func (statsResp *StatsResponse) SetStatus(code int)

func (*StatsResponse) String

func (statsResp *StatsResponse) String() string

type SubQuery

type SubQuery struct {
	// The name of an aggregation function to use.
	// The value is required with non-empty one in the range of
	// the response of calling /api/aggregators.
	//
	// By default, the potential values and corresponding descriptions are as followings:
	//   "sum": Adds all of the data points for a timestamp.
	//   "min": Picks the smallest data point for each timestamp.
	//   "max": Picks the largest data point for each timestamp.
	//   "avg": Averages the values for the data points at each timestamp.
	Aggregator string `json:"aggregator"`

	// The name of a metric stored in the system.
	// The value is reqiured with non-empty value.
	Metric string `json:"metric"`

	// An optional value is used to show whether or not the data should be
	// converted into deltas before returning. This is useful if the metric is a
	// continously incrementing counter and you want to view the rate of change between data points.
	Rate bool `json:"rate,omitempty"`

	// rateOptions represents monotonically increasing counter handling options.
	// The value is optional.
	// Currently there is only three kind of value can be set to this map:
	// Only three keys can be set into the rateOption parameter of the QueryParam is
	// QueryRateOptionCounter (value type is bool),  QueryRateOptionCounterMax (value type is int,int64)
	// QueryRateOptionResetValue (value type is int,int64)
	RateParams map[string]interface{} `json:"rateOptions,omitempty"`

	// An optional value downsampling function to reduce the amount of data returned.
	Downsample string `json:"downsample,omitempty"`

	// An optional value to drill down to specific timeseries or group results by tag,
	// supply one or more map values in the same format as the query string. Tags are converted to filters in 2.2.
	// Note that if no tags are specified, all metrics in the system will be aggregated into the results.
	// It will be deprecated in OpenTSDB 2.2.
	Tags map[string]string `json:"tags,omitempty"`

	// An optional value used to filter 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.
	Filters []Filter `json:"filters,omitempty"`
}

SubQuery is the structure used to hold the subquery parameters when calling /api/query. Each attributes in SubQuery matches the definition in (http://opentsdb.net/docs/build/html/api_http/query/index.html).

type SubQueryLast

type SubQueryLast struct {
	// The name of a metric stored in the system.
	// The value is reqiured with non-empty value.
	Metric string `json:"metric"`

	// An optional value to drill down to specific timeseries or group results by tag,
	// supply one or more map values in the same format as the query string. Tags are converted to filters in 2.2.
	// Note that if no tags are specified, all metrics in the system will be aggregated into the results.
	// It will be deprecated in OpenTSDB 2.2.
	Tags map[string]string `json:"tags,omitempty"`
}

SubQueryLast is the structure used to hold the subquery parameters when calling /api/query/last. Each attributes in SubQueryLast matches the definition in (http://opentsdb.net/docs/build/html/api_http/query/last.html).

type SuggestParam

type SuggestParam struct {
	// The type of data to auto complete on.
	// Must be one of the following: metrics, tagk or tagv.
	// It is required.
	// Only the one of the three query type can be used:
	// TypeMetrics, TypeTagk, TypeTagv
	Type string `json:"type"`

	// An optional string value to match on for the given type
	Q string `json:"q,omitempty"`

	// An optional integer value presenting the maximum number of suggested
	// results to return. If it is set, it must be greater than 0.
	MaxResultNum int `json:"max,omitempty"`
}

SuggestParam is the structure used to hold the querying parameters when calling /api/suggest. Each attributes in SuggestParam matches the definition in (http://opentsdb.net/docs/build/html/api_http/suggest.html).

func (*SuggestParam) String

func (sugParam *SuggestParam) String() string

type SuggestResponse

type SuggestResponse struct {
	StatusCode int
	ResultInfo []string `json:"ResultInfo"`
}

func (*SuggestResponse) GetCustomParser

func (sugResp *SuggestResponse) GetCustomParser() func(respCnt []byte) error

func (*SuggestResponse) SetStatus

func (sugResp *SuggestResponse) SetStatus(code int)

func (*SuggestResponse) String

func (sugResp *SuggestResponse) String() string

type TSMetaData

type TSMetaData struct {
	// A required hexadecimal representation of the timeseries UID
	Tsuid string `json:"tsuid,omitempty"`

	// An optional brief description of what the UID represents
	Description string `json:"description,omitempty"`

	// An optional short name that can be displayed in GUIs instead of the default name
	DisplayName string `json:"displayName,omitempty"`

	// An optional detailed notes about what the UID represents
	Notes string `json:"notes,omitempty"`

	// An optional key/value map to store custom fields and values
	Custom map[string]string `json:"custom,omitempty"`

	// An optional value reflective of the data stored in the timeseries, may be used in GUIs or calculations
	Units string `json:"units,omitempty"`

	// The kind of data stored in the timeseries such as counter, gauge, absolute, etc.
	// These may be defined later but they should be similar to Data Source Types in an RRD.
	// Its value is optional
	DataType string `json:"dataType,omitempty"`

	// The number of days of data points to retain for the given timeseries. Not Implemented.
	// When set to 0, the default, data is retained indefinitely.
	// Its value is optional
	Retention int64 `json:"retention,omitempty"`

	// An optional maximum value for this timeseries that may be used in calculations such as
	// percent of maximum. If the default of NaN is present, the value is ignored.
	Max float64 `json:"max,omitempty"`

	// An optional minimum value for this timeseries that may be used in calculations such as
	// percent of minimum. If the default of NaN is present, the value is ignored.
	Min float64 `json:"min,omitempty"`
}

TSMetaData is the structure used to hold the parameters when calling (POST,PUT,DELETE) /api/uid/tsmeta. Each attributes in TSMetaData matches the definition in (http://opentsdb.net/docs/build/html/api_http/uid/tsmeta.html).

type TSMetaDataResponse

type TSMetaDataResponse struct {
	StatusCode int
	TSMetaData
	Metric          UIDMetaData            `json:"metric,omitempty"`
	Tags            []UIDMetaData          `json:"tags,omitempty"`
	Created         int64                  `json:"created,omitempty"`
	LastReceived    int64                  `json:"lastReceived,omitempty"`
	TotalDatapoints int64                  `json:"totalDatapoints,omitempty"`
	ErrorInfo       map[string]interface{} `json:"error,omitempty"`
}

func (*TSMetaDataResponse) GetCustomParser

func (tsMetaDataResp *TSMetaDataResponse) GetCustomParser() func(respCnt []byte) error

func (*TSMetaDataResponse) SetStatus

func (tsMetaDataResp *TSMetaDataResponse) SetStatus(code int)

func (*TSMetaDataResponse) String

func (tsMetaDataResp *TSMetaDataResponse) String() string

type UIDAssignParam

type UIDAssignParam struct {
	// An optional list of metric names for assignment
	Metric []string `json:"metric,omitempty"`

	// An optional list of tag names for assignment
	Tagk []string `json:"tagk,omitempty"`

	// An optional list of tag values for assignment
	Tagv []string `json:"tagv,omitempty"`
}

UIDAssignParam is the structure used to hold the parameters when calling POST /api/uid/assign. Each attributes in UIDAssignParam matches the definition in (http://opentsdb.net/docs/build/html/api_http/uid/assign.html).

type UIDAssignResponse

type UIDAssignResponse struct {
	StatusCode   int
	Metric       map[string]string `json:"metric"`
	MetricErrors map[string]string `json:"metric_errors,omitempty"`
	Tagk         map[string]string `json:"tagk"`
	TagkErrors   map[string]string `json:"tagk_errors,omitempty"`
	Tagv         map[string]string `json:"tagv"`
	TagvErrors   map[string]string `json:"tagv_errors,omitempty"`
}

UIDAssignResponse acts as the implementation of Response in the POST /api/uid/assign scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/uid/assign.html).

func (*UIDAssignResponse) GetCustomParser

func (uidAssignResp *UIDAssignResponse) GetCustomParser() func(respCnt []byte) error

func (*UIDAssignResponse) SetStatus

func (uidAssignResp *UIDAssignResponse) SetStatus(code int)

func (*UIDAssignResponse) String

func (uidAssignResp *UIDAssignResponse) String() string

type UIDMetaData

type UIDMetaData struct {
	// A required hexadecimal representation of the UID
	Uid string `json:"uid,omitempty"`

	// A required type of UID, must be metric, tagk or tagv
	Type string `json:"type,omitempty"`

	// An optional brief description of what the UID represents
	Description string `json:"description,omitempty"`

	// An optional short name that can be displayed in GUIs instead of the default name
	DisplayName string `json:"displayName,omitempty"`

	// An optional detailed notes about what the UID represents
	Notes string `json:"notes,omitempty"`

	// An optional key/value map to store custom fields and values
	Custom map[string]string `json:"custom,omitempty"`
}

UIDMetaData is the structure used to hold the parameters when calling (POST,PUT) /api/uid/uidmeta. Each attributes in UIDMetaData matches the definition in (http://opentsdb.net/docs/build/html/api_http/uid/uidmeta.html).

type UIDMetaDataResponse

type UIDMetaDataResponse struct {
	UIDMetaData

	StatusCode int

	// The name of the UID as given when the data point was stored or the UID assigned
	Name string `json:"name,omitempty"`

	// A Unix epoch timestamp in seconds when the UID was first created.
	// If the meta data was not stored when the UID was assigned, this value may be 0.
	Created int64 `json:"created,omitempty"`

	ErrorInfo map[string]interface{} `json:"error,omitempty"`
}

UIDMetaDataResponse acts as the implementation of Response in the /api/uid/uidmeta scene. It holds the status code and the response values defined in the (http://opentsdb.net/docs/build/html/api_http/uid/uidmeta.html).

func (*UIDMetaDataResponse) GetCustomParser

func (uidMetaDataResp *UIDMetaDataResponse) GetCustomParser() func(respCnt []byte) error

func (*UIDMetaDataResponse) SetStatus

func (uidMetaDataResp *UIDMetaDataResponse) SetStatus(code int)

func (*UIDMetaDataResponse) String

func (uidMetaDataResp *UIDMetaDataResponse) String() string

type VersionResponse

type VersionResponse struct {
	StatusCode  int
	VersionInfo map[string]string `json:"VersionInfo"`
}

func (*VersionResponse) GetCustomParser

func (verResp *VersionResponse) GetCustomParser() func(respCnt []byte) error

func (*VersionResponse) SetStatus

func (verResp *VersionResponse) SetStatus(code int)

func (*VersionResponse) String

func (verResp *VersionResponse) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL