api

package
v1.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MPL-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoutePrefix             = "/api/"
	EndpointMetric          = "metric"
	EndpointMetricList      = "metrics-list"
	EndpointMetricTagValues = "metric-tag-values"
	EndpointQuery           = "query"
	EndpointRender          = "render"
	EndpointResetFlood      = "reset-flood"
	EndpointLegacyRedirect  = "legacy-redirect"
	EndpointDashboard       = "dashboard"
	EndpointDashboardList   = "dashboards-list"
	EndpointGroup           = "group"
	EndpointGroupList       = "group-list"
	EndpointPrometheus      = "prometheus"
)
View Source
const (
	ParamVersion    = "v"
	ParamNumResults = "n"
	ParamMetric     = "s"
	ParamID         = "id"

	ParamTagID        = "k"
	ParamFromTime     = "f"
	ParamToTime       = "t"
	ParamWidth        = "w"
	ParamWidthAgg     = "g" // supported only for better compatibility between UI and API URLs
	ParamTimeShift    = "ts"
	ParamQueryWhat    = "qw"
	ParamQueryBy      = "qb"
	ParamQueryFilter  = "qf"
	ParamQueryVerbose = "qv"

	Version1 = "1"
	Version2 = "2"

	// TODO: querySelectTimeout must be longer than the longest normal query.
	FastQueryTimeInterval = (86400 + 3600) * 2
)
View Source
const (
	ParamQueryFnCount                = "count"
	ParamQueryFnCountNorm            = "count_norm"
	ParamQueryFnCumulCount           = "cu_count"
	ParamQueryFnCardinality          = "cardinality"
	ParamQueryFnCardinalityNorm      = "cardinality_norm"
	ParamQueryFnCumulCardinality     = "cu_cardinality"
	ParamQueryFnMin                  = "min"
	ParamQueryFnMax                  = "max"
	ParamQueryFnAvg                  = "avg"
	ParamQueryFnCumulAvg             = "cu_avg"
	ParamQueryFnSum                  = "sum"
	ParamQueryFnSumNorm              = "sum_norm"
	ParamQueryFnCumulSum             = "cu_sum"
	ParamQueryFnStddev               = "stddev"
	ParamQueryFnP25                  = "p25"
	ParamQueryFnP50                  = "p50"
	ParamQueryFnP75                  = "p75"
	ParamQueryFnP90                  = "p90"
	ParamQueryFnP95                  = "p95"
	ParamQueryFnP99                  = "p99"
	ParamQueryFnP999                 = "p999"
	ParamQueryFnUnique               = "unique"
	ParamQueryFnUniqueNorm           = "unique_norm"
	ParamQueryFnMaxHost              = "max_host"
	ParamQueryFnMaxCountHost         = "max_count_host"
	ParamQueryFnDerivativeCount      = "dv_count"
	ParamQueryFnDerivativeCountNorm  = "dv_count_norm"
	ParamQueryFnDerivativeSum        = "dv_sum"
	ParamQueryFnDerivativeSumNorm    = "dv_sum_norm"
	ParamQueryFnDerivativeAvg        = "dv_avg"
	ParamQueryFnDerivativeMin        = "dv_min"
	ParamQueryFnDerivativeMax        = "dv_max"
	ParamQueryFnDerivativeUnique     = "dv_unique"
	ParamQueryFnDerivativeUniqueNorm = "dv_unique_norm"
)

Variables

This section is empty.

Functions

func CalcUTCOffset

func CalcUTCOffset(location *time.Location, weekStartsAt time.Weekday) int64

func CurrentChunksCount

func CurrentChunksCount(brs *BigResponseStorage) func(*statlogs.Registry)

func MetaToLabel

func MetaToLabel(meta QuerySeriesMetaV2, uniqueWhatLength int) string

XXX: keep in sync with TypeScript

func WhatToWhatDesc

func WhatToWhatDesc(what queryFn) string

XXX: keep in sync with TypeScript

Types

type BigResponseEntry

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

type BigResponseStorage

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

func NewBigResponseStorage

func NewBigResponseStorage(maxInMemoryChunksCount int, flushInterval time.Duration) *BigResponseStorage

func (*BigResponseStorage) Close

func (brs *BigResponseStorage) Close()

func (*BigResponseStorage) Count

func (brs *BigResponseStorage) Count() int

func (*BigResponseStorage) Get

func (brs *BigResponseStorage) Get(id int64) (*BigResponseEntry, bool)

func (*BigResponseStorage) Release

func (brs *BigResponseStorage) Release(id int64) int

func (*BigResponseStorage) Set

func (brs *BigResponseStorage) Set(ctx context.Context, rid int64, owner string, chunks []tlstatshouseApi.Series, lifeDuration time.Duration) error

type DashboardInfo

type DashboardInfo struct {
	Dashboard DashboardMetaInfo `json:"dashboard"`
	Delete    bool              `json:"delete_mark"`
}

func (DashboardInfo) MarshalEasyJSON

func (v DashboardInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*DashboardInfo) UnmarshalEasyJSON

func (v *DashboardInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type DashboardMetaInfo

type DashboardMetaInfo struct {
	DashboardID int32                  `json:"dashboard_id"`
	Name        string                 `json:"name"`
	Version     int64                  `json:"version,omitempty"`
	UpdateTime  uint32                 `json:"update_time"`
	DeletedTime uint32                 `json:"deleted_time"`
	Description string                 `json:"description"`
	JSONData    map[string]interface{} `json:"data"`
}

type GetDashboardListResp

type GetDashboardListResp struct {
	Dashboards []dashboardShortInfo `json:"dashboards"`
}

func (GetDashboardListResp) MarshalEasyJSON

func (v GetDashboardListResp) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*GetDashboardListResp) UnmarshalEasyJSON

func (v *GetDashboardListResp) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type GetGroupListResp

type GetGroupListResp struct {
	Groups []groupShortInfo `json:"groups"`
}

func (GetGroupListResp) MarshalEasyJSON

func (v GetGroupListResp) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*GetGroupListResp) UnmarshalEasyJSON

func (v *GetGroupListResp) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type GetMetricTagValuesResp

type GetMetricTagValuesResp struct {
	TagValues     []MetricTagValueInfo `json:"tag_values"`
	TagValuesMore bool                 `json:"tag_values_more"`
}

func (GetMetricTagValuesResp) MarshalEasyJSON

func (v GetMetricTagValuesResp) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*GetMetricTagValuesResp) UnmarshalEasyJSON

func (v *GetMetricTagValuesResp) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type GetMetricsListResp

type GetMetricsListResp struct {
	Metrics []metricShortInfo `json:"metrics"`
}

func (GetMetricsListResp) MarshalEasyJSON

func (v GetMetricsListResp) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*GetMetricsListResp) UnmarshalEasyJSON

func (v *GetMetricsListResp) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type GetQueryResp

type GetQueryResp struct {
	Series                   querySeries             `json:"series"`
	ReceiveErrorsLegacy      float64                 `json:"receive_errors_legacy"`       // sum of average, legacy
	SamplingFactorSrc        float64                 `json:"sampling_factor_src"`         // average
	SamplingFactorAgg        float64                 `json:"sampling_factor_agg"`         // average
	MappingFloodEventsLegacy float64                 `json:"mapping_flood_events_legacy"` // sum of average, legacy
	ReceiveErrors            float64                 `json:"receive_errors"`              // count/sec
	MappingErrors            float64                 `json:"mapping_error"`               // count/sec
	DebugQueries             []string                `json:"__debug_queries"`             // private, unstable: SQL queries executed
	MetricMeta               *format.MetricMetaValue `json:"-"`
	// contains filtered or unexported fields
}

func (GetQueryResp) MarshalEasyJSON

func (v GetQueryResp) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*GetQueryResp) UnmarshalEasyJSON

func (v *GetQueryResp) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Handler

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

func NewHandler

func NewHandler(verbose bool, staticDir fs.FS, jsSettings JSSettings, protectedPrefixes []string, showInvisible bool, utcOffsetSec int64, approxCacheMaxSize int, chV1 *util.ClickHouse, chV2 *util.ClickHouse, metadataClient *tlmetadata.Client, diskCache *pcache.DiskCache, jwtHelper *vkuth.JWTHelper, location *time.Location, localMode, readOnly, insecureMode bool) (*Handler, error)

func (*Handler) Close

func (h *Handler) Close() error

func (*Handler) HandleGetDashboard

func (h *Handler) HandleGetDashboard(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetDashboardList

func (h *Handler) HandleGetDashboardList(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetGroup

func (h *Handler) HandleGetGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetGroupsList

func (h *Handler) HandleGetGroupsList(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetMetric

func (h *Handler) HandleGetMetric(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetMetricTagValues

func (h *Handler) HandleGetMetricTagValues(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetMetricsList

func (h *Handler) HandleGetMetricsList(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetPromConfig

func (h *Handler) HandleGetPromConfig(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetQuery

func (h *Handler) HandleGetQuery(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleGetRender

func (h *Handler) HandleGetRender(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleLegacyRedirect

func (h *Handler) HandleLegacyRedirect(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePostMetric

func (h *Handler) HandlePostMetric(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePostPromConfig

func (h *Handler) HandlePostPromConfig(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePostResetFlood

func (h *Handler) HandlePostResetFlood(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePromInstantQuery

func (h *Handler) HandlePromInstantQuery(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePromLabelValuesQuery

func (h *Handler) HandlePromLabelValuesQuery(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePromRangeQuery

func (h *Handler) HandlePromRangeQuery(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePutPostDashboard

func (h *Handler) HandlePutPostDashboard(w http.ResponseWriter, r *http.Request)

func (*Handler) HandlePutPostGroup

func (h *Handler) HandlePutPostGroup(w http.ResponseWriter, r *http.Request)

func (*Handler) HandleStatic

func (h *Handler) HandleStatic(w http.ResponseWriter, r *http.Request)

type JSSettings

type JSSettings struct {
	VkuthAppName             string              `json:"vkuth_app_name"`
	DefaultMetric            string              `json:"default_metric"`
	DefaultMetricFilterIn    map[string][]string `json:"default_metric_filter_in"`
	DefaultMetricFilterNotIn map[string][]string `json:"default_metric_filter_not_in"`
	DefaultMetricWhat        []string            `json:"default_metric_what"`
	DefaultMetricGroupBy     []string            `json:"default_metric_group_by"`
	DisableV1                bool                `json:"disabled_v1"`
}

type MetricInfo

type MetricInfo struct {
	Metric format.MetricMetaValue `json:"metric"`
}

func (MetricInfo) MarshalEasyJSON

func (v MetricInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*MetricInfo) UnmarshalEasyJSON

func (v *MetricInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type MetricTagValueInfo

type MetricTagValueInfo struct {
	Value string  `json:"value"`
	Count float64 `json:"count"`
}

type MetricsGroupInfo

type MetricsGroupInfo struct {
	Group   format.MetricsGroup `json:"group"`
	Metrics []string            `json:"metrics"`
	Delete  bool                `json:"delete_mark"`
}

func (MetricsGroupInfo) MarshalEasyJSON

func (v MetricsGroupInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*MetricsGroupInfo) UnmarshalEasyJSON

func (v *MetricsGroupInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type PromConfigInfo

type PromConfigInfo struct {
	Config  string `json:"config"`
	Version int64  `json:"version"`
}

func (PromConfigInfo) MarshalEasyJSON

func (v PromConfigInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*PromConfigInfo) UnmarshalEasyJSON

func (v *PromConfigInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type QuerySeriesMeta

type QuerySeriesMeta struct {
	TimeShift int64             `json:"time_shift"`
	Tags      map[string]string `json:"tags"`
	MaxHosts  []string          `json:"max_hosts"` // max_host for now
	What      queryFn           `json:"what"`
}

type QuerySeriesMetaV2

type QuerySeriesMetaV2 struct {
	TimeShift int64                    `json:"time_shift"`
	Tags      map[string]SeriesMetaTag `json:"tags"`
	MaxHosts  []string                 `json:"max_hosts"` // max_host for now
	What      queryFn                  `json:"what"`
}

type RPCHandler

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

func NewRpcHandler

func NewRpcHandler(
	ah *Handler,
	brs *BigResponseStorage,
	jwtHelper *vkuth.JWTHelper,
	protectedPrefixes []string,
	localMode bool,
	insecureMode bool,
) *RPCHandler

func (*RPCHandler) GetQuery

type Response

type Response struct {
	Data  interface{} `json:"data,omitempty"`
	Error string      `json:"error,omitempty"`
}

func (Response) MarshalEasyJSON

func (v Response) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Response) UnmarshalEasyJSON

func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type SeriesMetaTag

type SeriesMetaTag struct {
	Value   string `json:"value"`
	Comment string `json:"comment,omitempty"`
	Raw     bool   `json:"raw,omitempty"`
	RawKind string `json:"raw_kind,omitempty"`
}

Jump to

Keyboard shortcuts

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