Documentation ¶
Index ¶
- type BoolWrapper
- type DSoptions
- type DataOperations
- type Downsample
- type EsNested
- type EsNestedQuery
- type EsRegexp
- type EsRespHitsMeta
- type EsRespHitsMetric
- type EsRespHitsTag
- type EsRespHitsTagKey
- type EsRespHitsTagValue
- type EsRespHitsWrapperMeta
- type EsRespHitsWrapperMetric
- type EsRespHitsWrapperTag
- type EsRespHitsWrapperTagKey
- type EsRespHitsWrapperTagValue
- type EsRespShards
- type EsResponseMeta
- type EsResponseMetric
- type EsResponseTag
- type EsResponseTagKey
- type EsResponseTagValue
- type ExpParse
- type ExpQuery
- type FilterValueOperation
- type Key
- type Merge
- type MetaInfo
- type MetricName
- type OperatorWrapper
- type Plot
- func (plot *Plot) ExpressionCheck(w http.ResponseWriter, expQuery ExpQuery)
- func (plot *Plot) ExpressionCheckGET(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (plot *Plot) ExpressionCheckPOST(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (plot *Plot) ExpressionCompile(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (plot *Plot) ExpressionExpandGET(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ExpressionExpandPOST(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ExpressionParseGET(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (plot *Plot) ExpressionParsePOST(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (plot *Plot) ExpressionQueryGET(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ExpressionQueryPOST(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot Plot) GetGroups(filters []structs.TSDBfilter, tsobs []TSDBobj) (groups [][]TSDBobj)
- func (plot *Plot) GetTextSeries(keyspace string, keys []string, start, end int64, mergeType string, ...) (serie TST, gerr gobol.Error)
- func (plot *Plot) GetTimeSeries(keyspace string, keys []string, start, end int64, opers structs.DataOperations, ...) (serie TS, gerr gobol.Error)
- func (plot Plot) ListMeta(keyspace, esType, metric string, tags map[string]string, onlyids bool, ...) ([]TsMetaInfo, int, gobol.Error)
- func (plot *Plot) ListMetaNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ListMetaText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot Plot) ListMetrics(keyspace, esType, metricName string, size, from int64) ([]string, int, gobol.Error)
- func (plot *Plot) ListMetricsNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ListMetricsText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ListPoints(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot Plot) ListTagKey(keyspace, tagKname string, size, from int64) ([]string, int, gobol.Error)
- func (plot Plot) ListTagValue(keyspace, tagVname string, size, from int64) ([]string, int, gobol.Error)
- func (plot Plot) ListTags(keyspace, esType, tagKey string, size, from int64) ([]string, int, gobol.Error)
- func (plot *Plot) ListTagsNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) ListTagsText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) Lookup(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) MetaFilterOpenTSDB(keyspace, id, metric string, filters []structs.TSDBfilter, size int64) ([]TSDBobj, int, gobol.Error)
- func (plot *Plot) MetaOpenTSDB(keyspace, id, metric string, tags map[string][]string, size, from int64) ([]TSDBobj, int, gobol.Error)
- func (plot *Plot) Query(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (plot *Plot) SetConsistencies(consistencies []gocql.Consistency)
- func (plot *Plot) Suggest(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Pnt
- type Pnts
- type QueryWrapper
- type RateOperation
- type Response
- type Series
- type SeriesType
- type TS
- type TSDBfilter
- type TSDBlookup
- type TSDBobj
- type TSDBrateOptions
- type TSDBresponse
- type TSDBresponses
- type TST
- type TSmeta
- type Tag
- type TagKey
- type TagValue
- type Term
- type TextPnt
- type TextPnts
- type TsMetaInfo
- type TsQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolWrapper ¶
type BoolWrapper struct {
Bool OperatorWrapper `json:"bool"`
}
type DataOperations ¶
type DataOperations struct { Downsample Downsample Merge string Rate RateOperation Order []string FilterValue FilterValueOperation }
type Downsample ¶
type EsNested ¶
type EsNested struct { Path string `json:"path"` ScoreMode string `json:"score_mode,omitempty"` Query BoolWrapper `json:"filter"` }
type EsNestedQuery ¶
type EsNestedQuery struct {
Nested EsNested `json:"nested"`
}
type EsRespHitsMeta ¶
type EsRespHitsMetric ¶
type EsRespHitsTag ¶
type EsRespHitsTagKey ¶
type EsRespHitsTagValue ¶
type EsRespHitsWrapperMeta ¶
type EsRespHitsWrapperMeta struct { Total int `json:"total"` MaxScore float32 `json:"max_score"` Hits []EsRespHitsMeta `json:"hits"` }
type EsRespHitsWrapperMetric ¶
type EsRespHitsWrapperMetric struct { Total int `json:"total"` MaxScore float32 `json:"max_score"` Hits []EsRespHitsMetric `json:"hits"` }
type EsRespHitsWrapperTag ¶
type EsRespHitsWrapperTag struct { Total int `json:"total"` MaxScore float32 `json:"max_score"` Hits []EsRespHitsTag `json:"hits"` }
type EsRespHitsWrapperTagKey ¶
type EsRespHitsWrapperTagKey struct { Total int `json:"total"` MaxScore float32 `json:"max_score"` Hits []EsRespHitsTagKey `json:"hits"` }
type EsRespHitsWrapperTagValue ¶
type EsRespHitsWrapperTagValue struct { Total int `json:"total"` MaxScore float32 `json:"max_score"` Hits []EsRespHitsTagValue `json:"hits"` }
type EsRespShards ¶
type EsResponseMeta ¶
type EsResponseMeta struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards EsRespShards `json:"_shards"` Hits EsRespHitsWrapperMeta `json:"hits"` }
type EsResponseMetric ¶
type EsResponseMetric struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards EsRespShards `json:"_shards"` Hits EsRespHitsWrapperMetric `json:"hits"` }
type EsResponseTag ¶
type EsResponseTag struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards EsRespShards `json:"_shards"` Hits EsRespHitsWrapperTag `json:"hits"` }
type EsResponseTagKey ¶
type EsResponseTagKey struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards EsRespShards `json:"_shards"` Hits EsRespHitsWrapperTagKey `json:"hits"` }
type EsResponseTagValue ¶
type EsResponseTagValue struct { Took int `json:"took"` TimedOut bool `json:"timed_out"` Shards EsRespShards `json:"_shards"` Hits EsRespHitsWrapperTagValue `json:"hits"` }
type ExpParse ¶
type FilterValueOperation ¶
type MetricName ¶
type MetricName struct {
Name string `json:"name"`
}
type OperatorWrapper ¶
type OperatorWrapper struct { Must []interface{} `json:"must,omitempty"` MustNot []interface{} `json:"must_not,omitempty"` Should []interface{} `json:"should,omitempty"` }
type Plot ¶
type Plot struct { MaxTimeseries int LogQueryThreshold int // contains filtered or unexported fields }
func (*Plot) ExpressionCheck ¶
func (plot *Plot) ExpressionCheck(w http.ResponseWriter, expQuery ExpQuery)
func (*Plot) ExpressionCheckGET ¶
func (plot *Plot) ExpressionCheckGET(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Plot) ExpressionCheckPOST ¶
func (plot *Plot) ExpressionCheckPOST(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Plot) ExpressionCompile ¶
func (plot *Plot) ExpressionCompile(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Plot) ExpressionExpandGET ¶
func (plot *Plot) ExpressionExpandGET(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ExpressionExpandPOST ¶
func (plot *Plot) ExpressionExpandPOST(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ExpressionParseGET ¶
func (plot *Plot) ExpressionParseGET(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Plot) ExpressionParsePOST ¶
func (plot *Plot) ExpressionParsePOST(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Plot) ExpressionQueryGET ¶
func (plot *Plot) ExpressionQueryGET(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ExpressionQueryPOST ¶
func (plot *Plot) ExpressionQueryPOST(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (Plot) GetGroups ¶
func (plot Plot) GetGroups(filters []structs.TSDBfilter, tsobs []TSDBobj) (groups [][]TSDBobj)
func (*Plot) GetTextSeries ¶
func (*Plot) GetTimeSeries ¶
func (*Plot) ListMetaNumber ¶
func (plot *Plot) ListMetaNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ListMetaText ¶
func (plot *Plot) ListMetaText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (Plot) ListMetrics ¶
func (*Plot) ListMetricsNumber ¶
func (plot *Plot) ListMetricsNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ListMetricsText ¶
func (plot *Plot) ListMetricsText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ListPoints ¶
func (plot *Plot) ListPoints(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (Plot) ListTagKey ¶
func (Plot) ListTagValue ¶
func (*Plot) ListTagsNumber ¶
func (plot *Plot) ListTagsNumber(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) ListTagsText ¶
func (plot *Plot) ListTagsText(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) Lookup ¶
func (plot *Plot) Lookup(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) MetaFilterOpenTSDB ¶
func (*Plot) MetaOpenTSDB ¶
func (*Plot) Query ¶
func (plot *Plot) Query(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Plot) SetConsistencies ¶
func (plot *Plot) SetConsistencies(consistencies []gocql.Consistency)
func (*Plot) Suggest ¶
func (plot *Plot) Suggest(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type QueryWrapper ¶
type QueryWrapper struct { Size int64 `json:"size,omitempty"` From int64 `json:"from,omitempty"` Query BoolWrapper `json:"filter"` Fields []string `json:"fields,omitempty"` }
type RateOperation ¶
type RateOperation struct { Enabled bool Options TSDBrateOptions }
type Response ¶
type Response struct { TotalRecords int `json:"totalRecords,omitempty"` Payload interface{} `json:"payload,omitempty"` Message interface{} `json:"message,omitempty"` }
type Series ¶
type Series struct { Text interface{} `json:"text,omitempty"` Trend interface{} `json:"trend,omitempty"` Points interface{} `json:"points,omitempty"` }
type SeriesType ¶
type TSDBfilter ¶
type TSDBlookup ¶
type TSDBrateOptions ¶
type TSDBresponse ¶
type TSDBresponses ¶
type TSDBresponses []TSDBresponse
type TSDBquery struct { Aggregator string `json:"aggregator"` Downsample string `json:"downsample,omitempty"` Metric string `json:"metric"` Tags map[string]string `json:"tags"` Rate bool `json:"rate,omitempty"` RateOptions TSDBrateOptions `json:"rateOptions,omitempty"` Order []string `json:"order,omitempty"` FilterValue string `json:"filterValue,omitempty"` Filters []TSDBfilter `json:"filters,omitempty"` }
type TSDBqueryPayload struct { Start int64 `json:"start,omitempty"` End int64 `json:"end,omitempty"` Relative string `json:"relative,omitempty"` Queries []structs.TSDBquery `json:"queries"` ShowTSUIDs bool `json:"showTSUIDs"` MsResolution bool `json:"msResolution"` }
func (query TSDBqueryPayload) Validate() gobol.Error {
if query.Relative != "" { if err := query.checkDuration(query.Relative); err != nil { return err } } if len(query.Queries) == 0 { return errTSDBquery(fmt.Errorf("At least one quey should be present")) } for i, q := range query.Queries { if err := query.checkField("metric", q.Metric); err != nil { return err } if err := query.checkAggregator(q.Aggregator); err != nil { return err } if q.Downsample != "" { ds := strings.Split(q.Downsample, "-") if len(ds) < 2 { return errTSDBquery(fmt.Errorf("invalid downsample format")) } if err := query.checkDuration(ds[0]); err != nil { return err } if err := query.checkDownsampler(ds[1]); err != nil { return err } if len(ds) > 2 { if err := query.checkFiller(ds[2]); err != nil { return err } } } if q.Rate { if err := query.checkRate(q.RateOptions); err != nil { return err } } if q.FilterValue != "" { q.FilterValue = strings.Replace(q.FilterValue, " ", "", -1) query.Queries[i].FilterValue = q.FilterValue if len(q.FilterValue) < 2 { return errTSDBquery(fmt.Errorf("invalid filter value %s", q.FilterValue)) } if q.FilterValue[:2] == ">=" || q.FilterValue[:2] == "<=" || q.FilterValue[:2] == "==" { _, err := strconv.ParseFloat(q.FilterValue[2:], 64) if err != nil { return errTSDBquery(err) } } else if q.FilterValue[:1] == ">" || q.FilterValue[:1] == "<" { _, err := strconv.ParseFloat(q.FilterValue[1:], 64) if err != nil { return errTSDBquery(err) } } else { return errTSDBquery(fmt.Errorf("invalid filter value %s", q.FilterValue)) } } if len(q.Order) == 0 { if q.FilterValue != "" { query.Queries[i].Order = append(query.Queries[i].Order, "filterValue") } if q.Downsample != "" { query.Queries[i].Order = append(query.Queries[i].Order, "downsample") } query.Queries[i].Order = append(query.Queries[i].Order, "aggregation") if q.Rate { query.Queries[i].Order = append(query.Queries[i].Order, "rate") } } else { orderCheck := make([]string, len(q.Order)) copy(orderCheck, q.Order) k := 0 occur := 0 for j, order := range orderCheck { if order == "aggregation" { k = j occur++ } } if occur == 0 { return errTSDBquery( fmt.Errorf("aggregation configured but no aggregation found in order array"), ) } if occur > 1 { return errTSDBquery(fmt.Errorf("more than one aggregation found in order array")) } if occur == 1 { orderCheck = append(orderCheck[:k], orderCheck[k+1:]...) } k = 0 occur = 0 for j, order := range orderCheck { if order == "filterValue" { k = j occur++ } } if q.FilterValue != "" && occur == 0 { return errTSDBquery( fmt.Errorf("filterValue configured but no filterValue found in order array"), ) } if occur > 1 { return errTSDBquery(fmt.Errorf("more than one filterValue found in order array")) } if occur == 1 { orderCheck = append(orderCheck[:k], orderCheck[k+1:]...) } k = 0 occur = 0 for j, order := range orderCheck { if order == "downsample" { k = j occur++ } } if q.Downsample != "" && occur == 0 { return errTSDBquery( fmt.Errorf( "downsample configured but no downsample found in order array", ), ) } if occur > 1 { return errTSDBquery(fmt.Errorf("more than one downsample found in order array")) } if occur == 1 { orderCheck = append(orderCheck[:k], orderCheck[k+1:]...) } k = 0 occur = 0 for j, order := range orderCheck { if order == "rate" { k = j occur++ } } if q.Rate && occur == 0 { return errTSDBquery(fmt.Errorf("rate configured but no rate found in order array")) } if occur > 1 { return errTSDBquery(fmt.Errorf("more than one rate found in order array")) } if occur == 1 { orderCheck = append(orderCheck[:k], orderCheck[k+1:]...) } if len(orderCheck) != 0 { return errTSDBquery(fmt.Errorf("invalid operations in order array %v", orderCheck)) } } if err := query.checkFilter(q.Filters); err != nil { return err } } return nil }
func (query TSDBqueryPayload) checkRate(opts TSDBrateOptions) gobol.Error {
if opts.CounterMax != nil && *opts.CounterMax < 0 { return errRate("counter max needs to be a positive integer") } return nil }
func (query TSDBqueryPayload) checkAggregator(aggr string) gobol.Error {
ok := false for _, vAggr := range config.GetAggregators() { if vAggr == aggr { ok = true break } } if !ok { return errAggregator("unkown aggregation value") } return nil }
func (query TSDBqueryPayload) checkDownsampler(DSr string) gobol.Error {
ok := false for _, vDSr := range config.GetDownsamplers() { if vDSr == DSr { ok = true break } } if !ok { return errDownsampler("Invalid downsample") } return nil }
func (query TSDBqueryPayload) checkFiller(DSf string) gobol.Error {
ok := false for _, vDSf := range config.GetFillers() { if vDSf == DSf { ok = true break } } if !ok { return errFiller("Invalid fill value") } return nil }
func (query TSDBqueryPayload) checkFilter(filters []TSDBfilter) gobol.Error {
vFilters := config.GetFilters() for _, filter := range filters { ok := false ft := filter.Ftype if ft == "iliteral_or" { ft = "literal_or" } else if ft == "not_iliteral_or" { ft = "not_literal_or" } else if ft == "iwildcard" { ft = "wildcard" } for _, vFilter := range vFilters { if ft == vFilter { ok = true break } } if !ok { return errFilter(fmt.Sprintf("Invalid filter type %s", filter.Ftype)) } if err := query.checkField("tagk", filter.Tagk); err != nil { return err } if err := query.checkFilterField("filter", ft, filter.Filter); err != nil { return err } } return nil }
func (query TSDBqueryPayload) checkDuration(s string) gobol.Error {
if len(s) < 2 { return errCheckDuration(fmt.Errorf("Invalid time interval")) } var n int var err error if string(s[len(s)-2:]) == "ms" { n, err = strconv.Atoi(string(s[:len(s)-2])) if err != nil { return errCheckDuration(err) } return nil } switch s[len(s)-1:] { case "s", "m", "h", "d", "w", "n", "y": n, err = strconv.Atoi(string(s[:len(s)-1])) if err != nil { return errCheckDuration(err) } default: return errCheckDuration(fmt.Errorf("Invalid unit")) } if n < 1 { return errCheckDuration(fmt.Errorf("interval needs to be bigger than 0")) } return nil }
func (query TSDBqueryPayload) checkField(n, f string) gobol.Error {
if !validFields.MatchString(f) { return errField(fmt.Sprintf("Invalid characters in field %s: %s", n, f)) } return nil }
func (query TSDBqueryPayload) checkFilterField(n, tf, f string) gobol.Error {
match := false switch tf { case "wildcard": match = validFwild.MatchString(f) case "literal_or", "not_literal_or": match = validFor.MatchString(f) case "regexp": match = true } if !match { return errFilterField(fmt.Sprintf("Invalid characters in field %s: %s", n, f)) } return nil }
func (TSDBresponses) Len ¶
func (r TSDBresponses) Len() int
func (TSDBresponses) Less ¶
func (r TSDBresponses) Less(i, j int) bool
func (TSDBresponses) Swap ¶
func (r TSDBresponses) Swap(i, j int)