metrics

package
v0.0.0-...-b4e7bf2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AggregationInterval1m = "1m" // minutely
	AggregationInterval1h = "1h" // hourly
	AggregationInterval1d = "1d" // daily
)
View Source
const (
	GroupByAttributesAll    string = "*"
	GroupByAttributesBucket string = "bucket"
)

Variables

Functions

This section is empty.

Types

type AggregateBucket

type AggregateBucket string
const (
	Raw      AggregateBucket = "main"
	Minutely AggregateBucket = "1m"
	Hourly   AggregateBucket = "1h"
	Daily    AggregateBucket = "1d"
)

type AggregateFunction

type AggregateFunction string
const (
	AggregateFunctionSum   AggregateFunction = "sum"
	AggregateFunctionAvg   AggregateFunction = "avg"
	AggregateFunctionMin   AggregateFunction = "min"
	AggregateFunctionMax   AggregateFunction = "max"
	AggregateFunctionCount AggregateFunction = "count"
	AggregateFunctionP50   AggregateFunction = "p50"
	AggregateFunctionP75   AggregateFunction = "p75"
	AggregateFunctionP90   AggregateFunction = "p90"
	AggregateFunctionP95   AggregateFunction = "p95"
	AggregateFunctionP99   AggregateFunction = "p99"
)

type AggregationInterval

type AggregationInterval string

type ByMetricName

type ByMetricName []MetricName

func (ByMetricName) Len

func (s ByMetricName) Len() int

func (ByMetricName) Less

func (s ByMetricName) Less(i, j int) bool

func (ByMetricName) Swap

func (s ByMetricName) Swap(i, j int)

type CounterMetricsResponse

type CounterMetricsResponse struct {
	StartTimestamp int64       `json:"start_ts"`
	EndTimestamp   int64       `json:"end_ts"`
	Results        []QueryData `json:"results"`
}

type Filter

type Filter struct {
	Key      string
	Value    string
	Operator string
}

type FilterOp

type FilterOp string
const (
	FilterOpNoOp     FilterOp = "noop"
	FilterOpEqual    FilterOp = "eq"
	FilterOpNotEqual FilterOp = "neq"
	FilterOpLike     FilterOp = "re"
	FilterOpNotLike  FilterOp = "nre"
)

type GaugeMetricsResponse

type GaugeMetricsResponse struct {
	StartTimestamp int64       `json:"start_ts"`
	EndTimestamp   int64       `json:"end_ts"`
	Results        []QueryData `json:"results"`
}

type GaugeRow

type GaugeRow struct {
	MetricName        string            `ch:"MetricName"`
	MetricDescription string            `ch:"MetricDescription"`
	MetricUnit        string            `ch:"MetricUnit"`
	Fingerprint       string            `ch:"Fingerprint"`
	Attributes        map[string]string `ch:"Attributes"`
	Values            []float64         `ch:"Values"`
	LastValues        []float64         `ch:"LastValues"`
	Times             []time.Time       `ch:"Times"`
}

type HistogramDistributionData

type HistogramDistributionData struct {
	MetricName        string                  `json:"name"`
	MetricDescription string                  `json:"description"`
	MetricUnit        string                  `json:"unit"`
	MetricType        string                  `json:"type"`
	Fingerprint       string                  `json:"fingerprint"`
	Data              []PerBucketDistribution `json:"data"`
}

type HistogramDistributionResponse

type HistogramDistributionResponse struct {
	StartTimestamp int64                       `json:"start_ts"`
	EndTimestamp   int64                       `json:"end_ts"`
	Results        []HistogramDistributionData `json:"results"`
}

type HistogramDistributionRow

type HistogramDistributionRow struct {
	ProjectID         string    `ch:"ProjectId"`
	MetricName        string    `ch:"MetricName"`
	MetricDescription string    `ch:"MetricDescription"`
	MetricUnit        string    `ch:"MetricUnit"`
	Fingerprint       string    `ch:"Fingerprint"`
	StartTimeUnix     time.Time `ch:"StartTimeUnix"`
	AggTimeUnix       time.Time `ch:"AggTimeUnix"`
	AggTemp           int32     `ch:"AggTemp"`
	Min               float64   `ch:"Min"`
	Max               float64   `ch:"Max"`
	Count             uint64    `ch:"Count"`
	Sum               float64   `ch:"Sum"`
	Bounds            []float64 `ch:"Bounds"`
	BoundsHash        uint64    `ch:"BoundsHash"`
	SamplesCount      uint64    `ch:"SamplesCount"`
	Delta             []uint64  `ch:"Delta"`
	Cumulative        []uint64  `ch:"Cumulative"`
}

type MetricName

type MetricName struct {
	Name           string   `json:"name"`
	Description    string   `json:"description"`
	Attributes     []string `json:"attributes"`
	Type           string   `json:"type"`
	LastIngestedAt int64    `json:"last_ingested_at"`
}

type MetricNameFilters

type MetricNameFilters struct {
	ProjectID  int64    `uri:"project_id" binding:"required,numeric,min=1"`
	StartsWith string   `form:"starts_with"`
	Search     string   `form:"search"`
	Limit      int      `form:"limit" binding:"numeric"`
	Attributes []string `form:"attributes"`
}

type MetricNameGetFn

type MetricNameGetFn func(context.Context) ([]MetricName, error)

type MetricNameResponse

type MetricNameResponse struct {
	Metrics []MetricName `json:"metrics"`
}

type MetricNameRow

type MetricNameRow struct {
	ProjectID      string    `ch:"ProjectId"`
	Name           string    `ch:"MetricName"`
	Description    string    `ch:"MetricDescription"`
	Attributes     []string  `ch:"Attributes"`
	LastIngestedAt time.Time `ch:"LastIngestedAt"`
}

type MetricRow

type MetricRow struct {
	MetricName        string            `ch:"MetricName"`
	MetricDescription string            `ch:"MetricDescription"`
	MetricUnit        string            `ch:"MetricUnit"`
	Fingerprint       string            `ch:"Fingerprint"`
	Attributes        map[string]string `ch:"Attributes"`
	Values            []float64         `ch:"Values"`
	Times             []time.Time       `ch:"Times"`
}

type MetricSearchMetadataResponse

type MetricSearchMetadataResponse struct {
	MetricName               string   `json:"name"`
	MetricType               string   `json:"type"`
	MetricDescription        string   `json:"description"`
	AttributeKeys            []string `json:"attribute_keys"`
	LastIngestedAt           int64    `json:"last_ingested_at"`
	SupportedAggregations    []string `json:"supported_aggregations"`
	SupportedFunctions       []string `json:"supported_functions"`
	DefaultGroupByAttributes []string `json:"default_group_by_attributes"`
	DefaultGroupByFunction   string   `json:"default_group_by_function"`
}

type MetricSearchMetadataRow

type MetricSearchMetadataRow struct {
	MetricName        string    `ch:"MetricName"`
	MetricDescription string    `ch:"MetricDescription"`
	AttributeKeys     []string  `ch:"AttributeKeys"`
	LastIngestedAt    time.Time `ch:"LastIngestedAt"`
}

type MetricsResponse

type MetricsResponse struct {
	StartTimestamp int64 `json:"start_ts"`
	EndTimestamp   int64 `json:"end_ts"`

	Results []QueryData `json:"results"`
}

type MockQuerier

type MockQuerier struct{}

func (*MockQuerier) GetMetricNames

func (*MockQuerier) GetMetrics

func (*MockQuerier) GetMetrics(_ context.Context, _ *QueryContext) (interface{}, error)

func (*MockQuerier) GetSearchMetadata

func (*MockQuerier) GetSearchMetadata(_ context.Context, _ *QueryContext) (interface{}, error)

type PerBucketDistribution

type PerBucketDistribution struct {
	BucketsHash  uint64         `json:"bucketsHash"`
	Buckets      []string       `json:"buckets"`
	Distribution [][]QueryPoint `json:"distribution"`
}

type Querier

type Querier interface {
	GetMetricNames(context.Context, *MetricNameFilters) (*MetricNameResponse, error)
	GetMetrics(context.Context, *QueryContext) (interface{}, error)
	GetSearchMetadata(context.Context, *QueryContext) (interface{}, error)
}

func NewQuerier

func NewQuerier(
	clickHouseDSN string,
	clickHouseCloudDSN string,
	opts *clickhouse.Options,
	logger *zap.Logger,
) (Querier, error)

type Query

type Query struct {
	TargetMetric string   `json:"mname"`
	TargetType   string   `json:"mtype"`
	TargetVisual string   `json:"mvisual"`
	Filters      []Filter `json:"filters"`
}

type QueryContext

type QueryContext struct {
	ProjectID int64 `json:"project_id"`

	Queries    map[string]*Query `json:"queries,omitempty"`
	Expression string            `json:"expression,omitempty"`

	StartTimestamp time.Time `json:"start_time"`
	EndTimestamp   time.Time `json:"end_time"`
}

type QueryData

type QueryData struct {
	MetricName        string            `json:"name"`
	MetricDescription string            `json:"description"`
	MetricUnit        string            `json:"unit"`
	MetricType        string            `json:"type"`
	Attributes        map[string]string `json:"attributes"`
	Values            []QueryPoint      `json:"values,omitempty"`
}

type QueryPoint

type QueryPoint [2]float64 // time, value

type SumMetricsResponse

type SumMetricsResponse struct {
	StartTimestamp int64       `json:"start_ts"`
	EndTimestamp   int64       `json:"end_ts"`
	Results        []QueryData `json:"results"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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