Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAggregator(aggregator string) (string, error)
- func CheckOrder(order string) (string, error)
- func DecodeRequest(r *http.Request, entity interface{}) error
- func GetIPFromConnAddr(addr string) string
- func MethodNotSupport(w http.ResponseWriter)
- func SerializeMetricValues(values []MetricValue) ([]byte, error)
- func TransferDownSample(downSample string) (int64, error)
- func WriteQueryResp(w http.ResponseWriter, code int, data interface{})
- type CurveData
- type MetricReq
- type MetricValue
- type PduHeader
- type QueryResp
- type TimeSeriesDataRequest
- type TimeValuePoint
- type TopNData
- type TopNRequest
Constants ¶
View Source
const ( // MetricUrl API for TSDB MetricUrl = "/server/api/metrics" TagKeyUrl = "/server/api/tagKeys" TagValueUrl = "/server/api/tagValues" CurveUrl = "/server/api/curves" RangeUrl = "/server/api/range" TopNUrl = "/server/api/topn" ChartDataUrl = "/server/api/chartData" // AlarmRuleUrl API for MySQL AlarmRuleUrl = "/server/api/alarmRule" ContactUrl = "/server/api/contact" MetricWhiteListUrl = "/server/api/metricWhiteList" DashboardUrl = "/server/api/dashboard" ChartUrl = "/server/api/chart" ChartListUrl = "/server/api/chartList" PutMetricsUrl = "/server/api/putMetrics" )
View Source
const ( CodeOK = 0 CodeApiNotFound = 1 CodeMethodNotFound = 2 CodeJsonDecodeError = 3 CodeInvalidParamError = 4 CodeGetConnPoolError = 5 CodeExecTSDBSqlError = 6 CodeSplitTagsError = 7 CodeStarKeysError = 8 CodeMaxQueryRangeError = 9 CodeAggregatorError = 10 CodeDownSampleError = 11 CodeMetricError = 12 CodeTagCountError = 13 CodeOrderError = 14 CodeExecMySQLError = 15 )
View Source
const ( MagicNumber = 0x1F2E3C4D PduVersion = 0x01 PduHeadSize = 16 PduTypeMetrics = 1 )
View Source
const MaxExpireTime = 3600
Variables ¶
View Source
var CodeMsg = map[int]string{ CodeOK: "ok", CodeApiNotFound: "api not found", CodeMethodNotFound: "http method not found", CodeJsonDecodeError: "json decode error", CodeInvalidParamError: "invalid parameter error", CodeGetConnPoolError: "get conn pool error", CodeExecTSDBSqlError: "TSDB SQL execution error", CodeSplitTagsError: "split tags error", CodeStarKeysError: "star keys error", CodeMaxQueryRangeError: "max query range error", CodeAggregatorError: "aggregator error", CodeDownSampleError: "down sample error", CodeMetricError: "metric error", CodeTagCountError: "too many tag count error", CodeOrderError: "no such order for topN query", CodeExecMySQLError: "MySQL execution error", }
View Source
var (
Json = jsoniter.ConfigFastest
)
Functions ¶
func CheckAggregator ¶
func CheckOrder ¶
func DecodeRequest ¶
DecodeRequest decode and write err log in one place
func GetIPFromConnAddr ¶
GetIPFromConnAddr get ip from the following format: ipv4 format: "192.0.2.1:25", ipv6 format: "[2001:db8::1]:80"
func MethodNotSupport ¶
func MethodNotSupport(w http.ResponseWriter)
func SerializeMetricValues ¶
func SerializeMetricValues(values []MetricValue) ([]byte, error)
func TransferDownSample ¶
func WriteQueryResp ¶
func WriteQueryResp(w http.ResponseWriter, code int, data interface{})
Types ¶
type CurveData ¶
type CurveData struct { Metric string `json:"metric"` Tags map[string]string `json:"tags"` DPS []TimeValuePoint `json:"dps"` }
type MetricValue ¶
type MetricValue struct { Metric string `json:"metric"` Tags map[string]string `json:"tags"` Timestamp uint64 `json:"timestamp"` Value float64 `json:"value"` }
func CollectHttpMetrics ¶
func CollectHttpMetrics(w http.ResponseWriter, req *http.Request) ([]MetricValue, error)
func UnmarshalPayload ¶
func UnmarshalPayload(data []byte) ([]MetricValue, error)
func (*MetricValue) IsValid ¶
func (m *MetricValue) IsValid() bool
type PduHeader ¶
type PduHeader struct { Magic uint32 Version uint16 Protocol uint16 Sequence uint32 PayloadLength uint32 }
func DeserializePduHeader ¶
type TimeSeriesDataRequest ¶
type TimeValuePoint ¶
type TopNRequest ¶
type TopNRequest struct { Token string `json:"token"` Start int64 `json:"start"` End int64 `json:"end"` Last int64 `json:"last"` Aggregator string `json:"aggregator"` DownSample int64 `json:"down_sample"` Limit int `json:"limit"` Order string `json:"order"` // desc/asc Metric string `json:"metric"` Tags map[string]string `json:"tags"` Filters map[string][]string // extracted from tags with "||" in the value Field string // extracted from tags with value of "*" }
Click to show internal directories.
Click to hide internal directories.