metrics

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 74 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableDatapointMinutes = "datapoint_minutes"
	TableDatapointHours   = "datapoint_hours"
)
View Source
const (
	MappingAny   = "any"
	MappingEqual = "eq"
	MappingLT    = "lt"
	MappingLTE   = "lte"
	MappingGT    = "gt"
	MappingGTE   = "gte"
)

Variables

This section is empty.

Functions

func AppendCHExpr

func AppendCHExpr(b []byte, key string) []byte

func CHExpr

func CHExpr(key string) ch.Safe

func DatapointTableForGrouping

func DatapointTableForGrouping(
	f *org.TimeFilter, groupingIntervalFn func(time.Time, time.Time) time.Duration,
) (string, time.Duration)

func DatapointTableForWhere

func DatapointTableForWhere(f *org.TimeFilter) string

func DecodeAttrFilter

func DecodeAttrFilter(app *bunapp.App, req bunrouter.Request, f *AttrFilter) error

func DecodeDashFilter added in v1.7.0

func DecodeDashFilter(req bunrouter.Request, f *DashFilter) error

func DecodeMetricFilter

func DecodeMetricFilter(req bunrouter.Request, f *MetricFilter) error

func DecodeQueryFilter

func DecodeQueryFilter(req bunrouter.Request, f *QueryFilter) error

func DeleteDashboard

func DeleteDashboard(ctx context.Context, db bun.IDB, id uint64) error

func Init

func Init(ctx context.Context, app *bunapp.App)

func InsertDashboard

func InsertDashboard(ctx context.Context, db bun.IDB, dash *Dashboard) error

func InsertDatapoints

func InsertDatapoints(ctx context.Context, app *bunapp.App, datapoints []*Datapoint) error

func InsertGridItems

func InsertGridItems(
	ctx context.Context, db bun.IDB, gridItems []GridItem,
) error

func InsertGridRow

func InsertGridRow(
	ctx context.Context, db bun.IDB, gridRow *GridRow,
) error

func SelectMetricMap

func SelectMetricMap(
	ctx context.Context, app *bunapp.App, projectID uint32,
) (map[string]*Metric, error)

func UpsertMetric

func UpsertMetric(ctx context.Context, app *bunapp.App, m *Metric) error

func UpsertMetrics

func UpsertMetrics(ctx context.Context, app *bunapp.App, metrics []Metric) error

Types

type AttrFilter

type AttrFilter struct {
	org.TimeFilter
	App *bunapp.App

	ProjectID uint32
	Metric    []string

	AttrKey         []string
	Instrument      []string
	OtelLibraryName []string
	SearchInput     string
}

func (*AttrFilter) UnmarshalValues

func (f *AttrFilter) UnmarshalValues(ctx context.Context, values url.Values) error

type AttrHandler

type AttrHandler struct {
	*bunapp.App
}

func NewAttrHandler

func NewAttrHandler(app *bunapp.App) *AttrHandler

func (*AttrHandler) AttrKeys

func (h *AttrHandler) AttrKeys(w http.ResponseWriter, req bunrouter.Request) error

func (*AttrHandler) AttrValues

func (h *AttrHandler) AttrValues(w http.ResponseWriter, req bunrouter.Request) error

type AttrKeyItem

type AttrKeyItem struct {
	Value  string `json:"value"`
	Count  uint64 `json:"count"`
	Pinned bool   `json:"pinned"`
}

type AttrMap

type AttrMap map[string]string

func (AttrMap) Merge

func (m AttrMap) Merge(other AttrMap)

type AttrName

type AttrName struct {
	Canonical string
	Alts      []string
}

type AttrValueItem

type AttrValueItem struct {
	Value string `json:"value"`
	Count uint64 `json:"count"`
}

type BaseGridItem

type BaseGridItem struct {
	bun.BaseModel `bun:"grid_items,alias:g"`

	ID       uint64   `json:"id" bun:",pk,autoincrement"`
	DashID   uint64   `json:"dashId"`
	DashKind DashKind `json:"dashKind"`
	RowID    uint64   `json:"rowId" bun:",nullzero"`

	Title       string `json:"title"`
	Description string `json:"description" bun:",nullzero"`

	Width  int `json:"width"`
	Height int `json:"height"`
	XAxis  int `json:"xAxis"`
	YAxis  int `json:"yAxis"`

	Type   GridItemType   `json:"type"`
	Params bunutil.Params `json:"params"`

	CreatedAt time.Time `json:"createdAt" bun:",nullzero"`
	UpdatedAt time.Time `json:"updatedAt" bun:",nullzero"`
}

func SelectBaseGridItems

func SelectBaseGridItems(
	ctx context.Context, app *bunapp.App, dashID uint64,
) ([]*BaseGridItem, error)

func (*BaseGridItem) Validate

func (item *BaseGridItem) Validate() error

type BaseGridItemTpl

type BaseGridItemTpl struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description,omitempty"`

	Width  int `yaml:"width,omitempty"`
	Height int `yaml:"height,omitempty"`
	XAxis  int `yaml:"x_axis,omitempty"`
	YAxis  int `yaml:"y_axis,omitempty"`

	Type GridItemType `yaml:"type"`
}

func (*BaseGridItemTpl) From

func (c *BaseGridItemTpl) From(gridItemType GridItemType, baseItem *BaseGridItem)

func (*BaseGridItemTpl) Populate

func (tpl *BaseGridItemTpl) Populate(item *BaseGridItem)

type BaseMonitorTpl added in v1.6.2

type BaseMonitorTpl struct {
	Name string `yaml:"name"`

	Type org.MonitorType `yaml:"type,omitempty"`

	NotifyEveryoneByEmail bool `yaml:"notify_everyone_by_email"`
}

func (*BaseMonitorTpl) Populate added in v1.6.2

func (tpl *BaseMonitorTpl) Populate(monitor *org.BaseMonitor) error

type CHStorage

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

func NewCHStorage

func NewCHStorage(ctx context.Context, db *ch.DB, conf *CHStorageConfig) *CHStorage

func (*CHStorage) SelectTimeseries

func (s *CHStorage) SelectTimeseries(f *mql.TimeseriesFilter) ([]*mql.Timeseries, error)

type CHStorageConfig

type CHStorageConfig struct {
	ProjectID uint32
	MetricMap map[string]*Metric
	Search    []chquery.Token
	TableName string
}

type ChartGridItem

type ChartGridItem struct {
	*BaseGridItem `bun:",inherit"`

	Params ChartGridItemParams `json:"params"`
}

func NewChartGridItem

func NewChartGridItem() *ChartGridItem

func (*ChartGridItem) Base

func (c *ChartGridItem) Base() *BaseGridItem

func (*ChartGridItem) Metrics

func (c *ChartGridItem) Metrics() []string

func (*ChartGridItem) Validate

func (c *ChartGridItem) Validate() error

type ChartGridItemParams

type ChartGridItemParams struct {
	ChartKind ChartKind         `json:"chartKind"`
	Metrics   []mql.MetricAlias `json:"metrics"`
	Query     string            `json:"query"`
	// Use ColumnMap instead of MetricMap for compatibility with TableGridItem.
	ColumnMap     map[string]*MetricColumn    `json:"columnMap"`
	TimeseriesMap map[string]*TimeseriesStyle `json:"timeseriesMap"`
	Legend        *ChartLegend                `json:"legend"`
}

type ChartGridItemTpl

type ChartGridItemTpl struct {
	BaseGridItemTpl `yaml:",inline"`

	ChartKind ChartKind                   `yaml:"chart"`
	Metrics   []string                    `yaml:"metrics"`
	Query     []string                    `yaml:"query"`
	Columns   map[string]*MetricColumn    `yaml:"columns,omitempty"`
	Styles    map[string]*TimeseriesStyle `yaml:"styles,omitempty"`
	Legend    *ChartLegend                `yaml:"legend,omitempty"`
}

func NewChartGridItemTpl

func NewChartGridItemTpl(item *ChartGridItem) *ChartGridItemTpl

func (*ChartGridItemTpl) Populate

func (tpl *ChartGridItemTpl) Populate(item *ChartGridItem) error

type ChartKind

type ChartKind string
const (
	ChartLine        ChartKind = "line"
	ChartArea        ChartKind = "area"
	ChartBar         ChartKind = "bar"
	ChartStackedArea ChartKind = "stacked-area"
	ChartStackedBar  ChartKind = "stacked-bar"
)

type ChartLegend

type ChartLegend struct {
	Type      LegendType      `json:"type" yaml:"type"`
	Placement LegendPlacement `json:"placement" yaml:"placement"`
	Values    []LegendValue   `json:"values" yaml:"values"`
}

type CloudwatchDatapoint

type CloudwatchDatapoint struct {
	MetricStreamName string            `json:"metric_stream_name"`
	AccountID        string            `json:"account_id"`
	Region           string            `json:"region"`
	Namespace        string            `json:"namespace"`
	MetricName       string            `json:"metric_name"`
	Dimensions       map[string]string `json:"dimensions"`
	Timestamp        int64             `json:"timestamp"`
	Value            struct {
		Min   float64 `json:"min"`
		Max   float64 `json:"max"`
		Sum   float64 `json:"sum"`
		Count float64 `json:"count"`
	} `json:"value"`
	Unit string `json:"unit"`
}

type ColumnInfo

type ColumnInfo struct {
	Name      string `json:"name"`
	Unit      string `json:"unit"`
	IsGroup   bool   `json:"isGroup"`
	TableFunc string `json:"tableFunc"`
}

type CumToDeltaConv

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

func NewCumToDeltaConv

func NewCumToDeltaConv(n int) *CumToDeltaConv

func (*CumToDeltaConv) Len

func (c *CumToDeltaConv) Len() int

func (*CumToDeltaConv) SwapPoint

func (c *CumToDeltaConv) SwapPoint(key DatapointKey, point any, time time.Time) any

type DashBuilder

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

func NewDashBuilder

func NewDashBuilder(
	tpl *DashboardTpl, projectID uint32, metricMap map[string]*Metric,
) *DashBuilder

func (*DashBuilder) Build

func (b *DashBuilder) Build() error

func (*DashBuilder) IsEmpty

func (b *DashBuilder) IsEmpty() bool

func (*DashBuilder) Save

func (b *DashBuilder) Save(
	ctx context.Context, tx bun.Tx, existingDash *Dashboard, withMonitors bool,
) error

func (*DashBuilder) Validate

func (b *DashBuilder) Validate() error

type DashFilter added in v1.7.0

type DashFilter struct {
	ProjectID uint32 `urlstruct:"-"`

	org.OrderByMixin

	Q      string
	Pinned bool
}

func (*DashFilter) PGOrder added in v1.7.0

func (f *DashFilter) PGOrder(q *bun.SelectQuery) *bun.SelectQuery

func (*DashFilter) UnmarshalValues added in v1.7.0

func (f *DashFilter) UnmarshalValues(ctx context.Context, values url.Values) error

func (*DashFilter) WhereClause added in v1.7.0

func (f *DashFilter) WhereClause(q *bun.SelectQuery) *bun.SelectQuery

type DashHandler

type DashHandler struct {
	*bunapp.App
}

func NewDashHandler

func NewDashHandler(app *bunapp.App) *DashHandler

func (*DashHandler) Clone

func (*DashHandler) Create

func (*DashHandler) CreateFromYAML added in v1.6.2

func (h *DashHandler) CreateFromYAML(w http.ResponseWriter, req bunrouter.Request) error

func (*DashHandler) Delete

func (*DashHandler) List

func (*DashHandler) Pin

func (*DashHandler) Reset

func (*DashHandler) Show

func (*DashHandler) ShowYAML

func (h *DashHandler) ShowYAML(w http.ResponseWriter, req bunrouter.Request) error

func (*DashHandler) Unpin

func (*DashHandler) Update

func (*DashHandler) UpdateGrid

func (h *DashHandler) UpdateGrid(w http.ResponseWriter, req bunrouter.Request) error

func (*DashHandler) UpdateTable

func (h *DashHandler) UpdateTable(w http.ResponseWriter, req bunrouter.Request) error

func (*DashHandler) UpdateYAML added in v1.7.0

func (h *DashHandler) UpdateYAML(w http.ResponseWriter, req bunrouter.Request) error

type DashKind

type DashKind string
const (
	DashKindGrid  DashKind = "grid"
	DashKindTable DashKind = "table"
)

type DashSyncer

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

func NewDashSyncer

func NewDashSyncer(app *bunapp.App) *DashSyncer

func (*DashSyncer) CreateDashboardsHandler

func (s *DashSyncer) CreateDashboardsHandler(ctx context.Context, projectID uint32) error

type DashTableTpl added in v1.7.0

type DashTableTpl struct {
	If      []MetricMatcher         `yaml:"if,omitempty"`
	Metrics []string                `yaml:"metrics"`
	Query   []string                `yaml:"query"`
	Columns map[string]*TableColumn `yaml:"columns,omitempty"`
}

func (*DashTableTpl) Populate added in v1.7.0

func (tpl *DashTableTpl) Populate(dash *Dashboard) error

type Dashboard

type Dashboard struct {
	bun.BaseModel `bun:"dashboards,alias:d"`

	ID         uint64 `json:"id" bun:",pk,autoincrement"`
	ProjectID  uint32 `json:"projectId"`
	TemplateID string `json:"templateId" bun:",nullzero"`

	Name   string `json:"name"`
	Pinned bool   `json:"pinned"`

	MinInterval       unixtime.Millis `json:"minInterval"`
	TimeOffset        unixtime.Millis `json:"timeOffset"`
	TooltipsConnected bool            `json:"tooltipsConnected"`

	GridQuery    string `json:"gridQuery" bun:",nullzero"`
	GridMaxWidth int    `json:"gridMaxWidth" bun:",nullzero"`

	TableMetrics   []mql.MetricAlias       `json:"tableMetrics" bun:",type:jsonb,nullzero"`
	TableQuery     string                  `json:"tableQuery" bun:",nullzero"`
	TableGrouping  []string                `json:"tableGrouping" bun:",type:jsonb,nullzero"`
	TableColumnMap map[string]*TableColumn `json:"tableColumnMap" bun:",type:jsonb,nullzero"`

	CreatedAt time.Time `json:"createdAt" bun:",nullzero"`
	UpdatedAt time.Time `json:"updatedAt" bun:",nullzero"`
}

func SelectDashboard

func SelectDashboard(ctx context.Context, app *bunapp.App, id uint64) (*Dashboard, error)

func (*Dashboard) Validate

func (d *Dashboard) Validate() error

type DashboardIn

type DashboardIn struct {
	Name         string          `json:"name"`
	MinInterval  unixtime.Millis `json:"minInterval"`
	TimeOffset   unixtime.Millis `json:"timeOffset"`
	GridMaxWidth int             `json:"gridMaxWidth"`
}

func (*DashboardIn) Populate

func (in *DashboardIn) Populate(dash *Dashboard) error

type DashboardTpl

type DashboardTpl struct {
	Schema string `yaml:"schema"`

	ID   string          `yaml:"id"`
	If   []MetricMatcher `yaml:"if,omitempty"`
	Name string          `yaml:"name"`

	MinInterval unixtime.Millis `yaml:"min_interval,omitempty"`
	TimeOffset  unixtime.Millis `yaml:"time_offset,omitempty"`
	GridQuery   string          `yaml:"grid_query,omitempty"`

	TableGridItems []*GridItemTpl `yaml:"table_grid_items,omitempty"`
	Table          []DashTableTpl `yaml:"table"`

	IncludeGridRows []string            `yaml:"include_grid_rows,omitempty"`
	GridRows        []*GridRowTpl       `yaml:"grid_rows"`
	Monitors        []*MetricMonitorTpl `yaml:"monitors,omitempty"`
}

func NewDashboardTpl

func NewDashboardTpl(
	dash *Dashboard, tableItems []GridItem, gridRows []*GridRow,
) (*DashboardTpl, error)

func (*DashboardTpl) Populate

func (tpl *DashboardTpl) Populate(dash *Dashboard) error

type Datapoint

type Datapoint struct {
	ch.CHModel `ch:"datapoint_minutes,insert:datapoint_minutes_buffer,alias:m"`

	ProjectID   uint32
	Metric      string     `ch:"metric,lc"`
	Description string     `ch:"-"`
	Unit        string     `ch:"-"`
	Instrument  Instrument `ch:",lc"`

	Time      time.Time `ch:"type:DateTime"`
	AttrsHash uint64

	Min       float64
	Max       float64
	Sum       float64
	Count     uint64
	Gauge     float64
	Histogram map[bfloat16.T]uint64 `ch:"type:AggregateFunction(quantilesBFloat16(0.5), Float32)"`

	Attrs        AttrMap  `ch:"-"`
	StringKeys   []string `ch:"type:Array(LowCardinality(String))"`
	StringValues []string

	OtelLibraryName    string `ch:",lc"`
	OtelLibraryVersion string `ch:",lc"`

	StartTimeUnixNano uint64 `ch:"-"`
	CumPoint          any    `ch:"-"`
}

type DatapointKey

type DatapointKey struct {
	ProjectID         uint32
	Metric            string
	AttrsHash         uint64
	StartTimeUnixNano uint64
}

type DatapointProcessor

type DatapointProcessor struct {
	*bunapp.App
	// contains filtered or unexported fields
}

func NewDatapointProcessor

func NewDatapointProcessor(app *bunapp.App) *DatapointProcessor

func (*DatapointProcessor) AddDatapoint

func (p *DatapointProcessor) AddDatapoint(ctx context.Context, datapoint *Datapoint)

type DatapointValue

type DatapointValue struct {
	Key   DatapointKey
	Point any
	Time  time.Time
}

type ErrorMonitorTpl added in v1.6.2

type ErrorMonitorTpl struct {
	BaseMonitorTpl `yaml:",inline"`

	NotifyOnNewErrors       bool              `yaml:"notify_on_new_errors"`
	NotifyOnRecurringErrors bool              `yaml:"notify_on_recurring_errors"`
	Matchers                []org.AttrMatcher `yaml:"matchers"`
}

func NewErrorMonitorTpl added in v1.6.2

func NewErrorMonitorTpl(monitor *org.ErrorMonitor) *ErrorMonitorTpl

func (*ErrorMonitorTpl) Populate added in v1.6.2

func (tpl *ErrorMonitorTpl) Populate(monitor *org.ErrorMonitor) error

type ExpHistogramPoint

type ExpHistogramPoint struct {
	Sum       float64
	Count     uint64
	Histogram map[bfloat16.T]uint64
}

type GaugeColumn

type GaugeColumn struct {
	Unit    string `json:"unit" yaml:"unit,omitempty"`
	AggFunc string `json:"aggFunc" yaml:"agg_func,omitempty"`
}

func (*GaugeColumn) Validate

func (c *GaugeColumn) Validate() error

type GaugeGridItem

type GaugeGridItem struct {
	*BaseGridItem `bun:",inherit"`

	Params GaugeGridItemParams `json:"params"`
}

func NewGaugeGridItem

func NewGaugeGridItem() *GaugeGridItem

func (*GaugeGridItem) Base

func (c *GaugeGridItem) Base() *BaseGridItem

func (*GaugeGridItem) Metrics

func (c *GaugeGridItem) Metrics() []string

func (*GaugeGridItem) Validate

func (c *GaugeGridItem) Validate() error

type GaugeGridItemParams

type GaugeGridItemParams struct {
	Metrics   []mql.MetricAlias       `json:"metrics"`
	Query     string                  `json:"query"`
	ColumnMap map[string]*GaugeColumn `json:"columnMap" bun:",nullzero"`

	Template      string         `json:"template" bun:",nullzero"`
	ValueMappings []ValueMapping `json:"valueMappings" bun:",nullzero"`
}

type GaugeGridItemTpl

type GaugeGridItemTpl struct {
	BaseGridItemTpl `yaml:",inline"`

	Metrics []string                `yaml:"metrics"`
	Query   []string                `yaml:"query"`
	Columns map[string]*GaugeColumn `yaml:"columns,omitempty"`

	Template      string         `yaml:"template,omitempty"`
	ValueMappings []ValueMapping `yaml:"value_mappings,omitempty"`
}

func NewGaugeGridItemTpl

func NewGaugeGridItemTpl(item *GaugeGridItem) *GaugeGridItemTpl

func (*GaugeGridItemTpl) Populate

func (tpl *GaugeGridItemTpl) Populate(item *GaugeGridItem) error

type GridItem

type GridItem interface {
	Base() *BaseGridItem
	Validate() error
	Metrics() []string
}

func SelectGridItem

func SelectGridItem(
	ctx context.Context, app *bunapp.App, itemID uint64,
) (GridItem, error)

func SelectGridItems

func SelectGridItems(
	ctx context.Context, app *bunapp.App, dashID uint64,
) ([]GridItem, error)

type GridItemHandler

type GridItemHandler struct {
	*bunapp.App
}

func NewGridItemHandler

func NewGridItemHandler(app *bunapp.App) *GridItemHandler

func (*GridItemHandler) Create

func (*GridItemHandler) Delete

func (*GridItemHandler) GridItemMiddleware

func (h *GridItemHandler) GridItemMiddleware(next bunrouter.HandlerFunc) bunrouter.HandlerFunc

func (*GridItemHandler) Update

func (*GridItemHandler) UpdateLayout

func (h *GridItemHandler) UpdateLayout(w http.ResponseWriter, req bunrouter.Request) error

type GridItemIn

type GridItemIn struct {
	DashKind DashKind `json:"dashKind"`

	Title       string `json:"title"`
	Description string `json:"description"`

	Width  int `json:"width"`
	Height int `json:"height"`

	Type   GridItemType    `json:"type"`
	Params json.RawMessage `json:"params"`
}

func (*GridItemIn) Populate

func (in *GridItemIn) Populate(baseItem *BaseGridItem) error

type GridItemPos

type GridItemPos struct {
	ID     uint64 `json:"id"`
	Width  int32  `json:"width"`
	Height int32  `json:"height"`
	XAxis  int32  `json:"xAxis"`
	YAxis  int32  `json:"yAxis"`
}

type GridItemTpl

type GridItemTpl struct {
	Value any
}

func NewGridItemTpl

func NewGridItemTpl(item GridItem) *GridItemTpl

func (*GridItemTpl) MarshalYAML

func (tpl *GridItemTpl) MarshalYAML() (interface{}, error)

func (*GridItemTpl) UnmarshalYAML

func (item *GridItemTpl) UnmarshalYAML(node *yaml.Node) error

type GridItemType

type GridItemType string
const (
	GridItemChart   GridItemType = "chart"
	GridItemTable   GridItemType = "table"
	GridItemHeatmap GridItemType = "heatmap"
	GridItemGauge   GridItemType = "gauge"
)

type GridRow

type GridRow struct {
	bun.BaseModel `bun:"grid_rows,alias:r"`

	ID     uint64 `json:"id" bun:",pk,autoincrement"`
	DashID uint64 `json:"dashId"`

	Title       string `json:"title"`
	Description string `json:"description" bun:",nullzero"`
	Expanded    bool   `json:"expanded"`
	Index       int    `json:"index"`

	Items []GridItem `json:"items" bun:"-"`

	CreatedAt time.Time `json:"createdAt" bun:",nullzero"`
	UpdatedAt time.Time `json:"updatedAt" bun:",nullzero"`
}

func SelectGridRow

func SelectGridRow(
	ctx context.Context, app *bunapp.App, rowID uint64,
) (*GridRow, error)

func SelectGridRows

func SelectGridRows(
	ctx context.Context, db bun.IDB, dashID uint64,
) ([]*GridRow, error)

func SelectOrCreateGridRow

func SelectOrCreateGridRow(ctx context.Context, app *bunapp.App, dashID uint64) (*GridRow, error)

func (*GridRow) Validate

func (row *GridRow) Validate() error

type GridRowHandler

type GridRowHandler struct {
	*bunapp.App
}

func NewGridRowHandler

func NewGridRowHandler(app *bunapp.App) *GridRowHandler

func (*GridRowHandler) Create

func (*GridRowHandler) Delete

func (*GridRowHandler) GridRowMiddleware

func (h *GridRowHandler) GridRowMiddleware(next bunrouter.HandlerFunc) bunrouter.HandlerFunc

func (*GridRowHandler) MoveDown

func (*GridRowHandler) MoveUp

func (*GridRowHandler) Show

func (*GridRowHandler) Update

type GridRowIn

type GridRowIn struct {
	Title       string `json:"title"`
	Description string `json:"description" bun:",nullzero"`
	Expanded    bool   `json:"expanded"`
}

func (*GridRowIn) Populate

func (in *GridRowIn) Populate(row *GridRow) error

type GridRowTpl

type GridRowTpl struct {
	Title string         `yaml:"title"`
	Items []*GridItemTpl `yaml:"items"`
}

func NewGridRowTpl

func NewGridRowTpl(row *GridRow) *GridRowTpl

func (*GridRowTpl) Populate

func (tpl *GridRowTpl) Populate(row *GridRow) error

type HeatmapGridItem

type HeatmapGridItem struct {
	*BaseGridItem `bun:",inherit"`

	Params HeatmapGridItemParams `json:"params"`
}

func NewHeatmapGridItem

func NewHeatmapGridItem() *HeatmapGridItem

func (*HeatmapGridItem) Base

func (c *HeatmapGridItem) Base() *BaseGridItem

func (*HeatmapGridItem) Metrics

func (c *HeatmapGridItem) Metrics() []string

func (*HeatmapGridItem) Validate

func (c *HeatmapGridItem) Validate() error

type HeatmapGridItemParams

type HeatmapGridItemParams struct {
	Metric string `json:"metric"`
	Unit   string `json:"unit"`
	Query  string `json:"query"`
}

type HeatmapGridItemTpl

type HeatmapGridItemTpl struct {
	BaseGridItemTpl `yaml:",inline"`

	Metric string   `yaml:"metric"`
	Unit   string   `yaml:"unit,omitempty"`
	Query  []string `yaml:"query"`
}

func NewHeatmapGridItemTpl

func NewHeatmapGridItemTpl(col *HeatmapGridItem) *HeatmapGridItemTpl

func (*HeatmapGridItemTpl) Populate

func (tpl *HeatmapGridItemTpl) Populate(item *HeatmapGridItem) error

type HistogramPoint

type HistogramPoint struct {
	Sum          float64
	Count        uint64
	Bounds       []float64
	BucketCounts []uint64
}

type Instrument

type Instrument string
const (
	InstrumentDeleted   Instrument = "deleted"
	InstrumentGauge     Instrument = "gauge"
	InstrumentAdditive  Instrument = "additive"
	InstrumentHistogram Instrument = "histogram"
	InstrumentCounter   Instrument = "counter"
	InstrumentSummary   Instrument = "summary"
)

type KinesisEvent

type KinesisEvent struct {
	RequestID string               `json:"requestId"`
	Records   []KinesisEventRecord `json:"records"`
}

type KinesisEventRecord

type KinesisEventRecord struct {
	Data []byte `json:"data"`
}

type KinesisHandler

type KinesisHandler struct {
	*bunapp.App
	// contains filtered or unexported fields
}

func NewKinesisHandler

func NewKinesisHandler(app *bunapp.App, mp *DatapointProcessor) *KinesisHandler

func (*KinesisHandler) Metrics

type LegendPlacement

type LegendPlacement string
const (
	LegendBottom LegendPlacement = "bottom"
	LegendRight  LegendPlacement = "right"
)

type LegendType

type LegendType string
const (
	LegendNone  LegendType = "none"
	LegendList  LegendType = "list"
	LegendTable LegendType = "table"
)

type LegendValue

type LegendValue string
const (
	LegendAvg LegendValue = "avg"
	LegendMin LegendValue = "min"
	LegendMax LegendValue = "max"
	LegenLast LegendValue = "last"
)

type MappingOp

type MappingOp string

type Metric

type Metric struct {
	bun.BaseModel `bun:"metrics,alias:m"`

	ID        uint64 `json:"id,string" bun:",pk,autoincrement"`
	ProjectID uint32 `json:"projectId"`

	Name        string     `json:"name"`
	Description string     `json:"description"`
	Instrument  Instrument `json:"instrument"`
	Unit        string     `json:"unit" bun:",nullzero"`

	AttrKeys           []string `json:"attrKeys" bun:",array"`
	OtelLibraryName    string   `json:"otelLibraryName" bun:",nullzero"`
	OtelLibraryVersion string   `json:"otelLibraryVersion" bun:",nullzero"`

	CreatedAt time.Time `json:"createdAt" bun:",nullzero"`
	UpdatedAt time.Time `json:"updatedAt" bun:",nullzero"`

	// Payload
	NumTimeseries uint64 `json:"numTimeseries" bun:",scanonly"`
}

func SelectMetric

func SelectMetric(ctx context.Context, app *bunapp.App, id uint64) (*Metric, error)

func SelectMetricByName

func SelectMetricByName(
	ctx context.Context, app *bunapp.App, projectID uint32, name string,
) (*Metric, error)

type MetricColumn

type MetricColumn struct {
	Unit  string `json:"unit" yaml:"unit,omitempty"`
	Color string `json:"color" yaml:"color,omitempty"`
}

func (*MetricColumn) Validate

func (c *MetricColumn) Validate() error

type MetricFilter

type MetricFilter struct {
	org.TimeFilter

	ProjectID uint32

	AttrKey         []string
	Instrument      []string
	OtelLibraryName []string
	SearchInput     string

	Query string
}

func (*MetricFilter) UnmarshalValues

func (f *MetricFilter) UnmarshalValues(ctx context.Context, values url.Values) error

type MetricHandler

type MetricHandler struct {
	*bunapp.App
}

func NewMetricHandler

func NewMetricHandler(app *bunapp.App) *MetricHandler

func (*MetricHandler) Describe

func (*MetricHandler) List

func (*MetricHandler) Stats

type MetricKey

type MetricKey struct {
	ProjectID uint32
	Metric    string
}

type MetricMatcher added in v1.7.0

type MetricMatcher struct {
	Metric          string `yaml:"metric"`
	Instrumentation string `yaml:"instrumentation"`
	State           string `yaml:"state"`
}

type MetricMonitorTpl added in v1.6.2

type MetricMonitorTpl struct {
	BaseMonitorTpl `yaml:",inline"`

	Metrics    []string `yaml:"metrics"`
	Query      []string `yaml:"query"`
	Column     string   `yaml:"column"`
	ColumnUnit string   `yaml:"column_unit,omitempty"`

	MinAllowedValue bunutil.NullFloat64 `yaml:"min_allowed_value,omitempty"`
	MaxAllowedValue bunutil.NullFloat64 `yaml:"max_allowed_value,omitempty"`

	CheckNumPoint int             `yaml:"check_num_point"`
	TimeOffset    unixtime.Millis `yaml:"time_offset,omitempty"`
}

func NewMetricMonitorTpl added in v1.6.2

func NewMetricMonitorTpl(monitor *org.MetricMonitor) *MetricMonitorTpl

func (*MetricMonitorTpl) Populate added in v1.6.2

func (tpl *MetricMonitorTpl) Populate(monitor *org.MetricMonitor) error

type MetricsServiceServer

type MetricsServiceServer struct {
	collectormetricspb.UnimplementedMetricsServiceServer

	*bunapp.App
	// contains filtered or unexported fields
}

func NewMetricsServiceServer

func NewMetricsServiceServer(app *bunapp.App, mp *DatapointProcessor) *MetricsServiceServer

func (*MetricsServiceServer) ExportHTTP

type Middleware

type Middleware struct {
	*org.Middleware
	App *bunapp.App
}

func NewMiddleware

func NewMiddleware(app *bunapp.App) Middleware

func (Middleware) Dashboard

type MonitorTpl

type MonitorTpl struct {
	Value any // *MetricMonitorTpl | *ErrorMonitorTpl
}

func NewMonitorTpl added in v1.6.2

func NewMonitorTpl(monitor org.Monitor) *MonitorTpl

func (*MonitorTpl) MarshalYAML added in v1.6.2

func (tpl *MonitorTpl) MarshalYAML() (interface{}, error)

func (*MonitorTpl) UnmarshalYAML added in v1.6.2

func (tpl *MonitorTpl) UnmarshalYAML(node *yaml.Node) error

type NumberPoint

type NumberPoint struct {
	Int    int64
	Double float64
}

func NewDoublePoint

func NewDoublePoint(n float64) *NumberPoint

func NewIntPoint

func NewIntPoint(n int64) *NumberPoint

type PromDatapoint

type PromDatapoint struct {
	Metric       string
	Value        float64
	StringKeys   []string
	StringValues []string
	Time         time.Time
}

type PrometheusHandler

type PrometheusHandler struct {
	*bunapp.App
	// contains filtered or unexported fields
}

func NewPrometheusHandler

func NewPrometheusHandler(app *bunapp.App, mp *DatapointProcessor) *PrometheusHandler

func (*PrometheusHandler) Read

func (*PrometheusHandler) Write

type QueryFilter

type QueryFilter struct {
	org.TimeFilter
	org.OrderByMixin
	urlstruct.Pager

	Project *org.Project `urlstruct:"-"`

	Metric []string
	Alias  []string
	Query  string

	Search string

	TableAgg map[string]string
	// contains filtered or unexported fields
}

func (*QueryFilter) Clone

func (f *QueryFilter) Clone() *QueryFilter

func (*QueryFilter) MetricMap

func (f *QueryFilter) MetricMap(ctx context.Context, app *bunapp.App) (map[string]*Metric, error)

func (*QueryFilter) UnmarshalValues

func (f *QueryFilter) UnmarshalValues(ctx context.Context, values url.Values) (err error)

type QueryHandler

type QueryHandler struct {
	*bunapp.App
}

func NewQueryHandler

func NewQueryHandler(app *bunapp.App) *QueryHandler

func (*QueryHandler) Gauge

func (*QueryHandler) Heatmap

func (*QueryHandler) Table

func (*QueryHandler) Timeseries

func (h *QueryHandler) Timeseries(w http.ResponseWriter, req bunrouter.Request) error

type TableColumn

type TableColumn struct {
	MetricColumn `yaml:",inline"`

	AggFunc           string `json:"aggFunc" yaml:"agg_func,omitempty"`
	SparklineDisabled bool   `json:"sparklineDisabled" yaml:"sparkline_disabled,omitempty"`
}

func (*TableColumn) Validate

func (c *TableColumn) Validate() error

type TableGridItem

type TableGridItem struct {
	*BaseGridItem `bun:",inherit"`

	Params TableGridItemParams `json:"params"`
}

func NewTableGridItem

func NewTableGridItem() *TableGridItem

func (*TableGridItem) Base

func (c *TableGridItem) Base() *BaseGridItem

func (*TableGridItem) Metrics

func (item *TableGridItem) Metrics() []string

func (*TableGridItem) Validate

func (item *TableGridItem) Validate() error

type TableGridItemParams

type TableGridItemParams struct {
	Metrics      []mql.MetricAlias        `json:"metrics"`
	Query        string                   `json:"query"`
	ColumnMap    map[string]*MetricColumn `json:"columnMap"`
	ItemsPerPage int                      `json:"itemsPerPage"`
	DenseTable   bool                     `json:"denseTable"`
}

type TableGridItemTpl

type TableGridItemTpl struct {
	BaseGridItemTpl `yaml:",inline"`

	Metrics []string                 `yaml:"metrics"`
	Query   []string                 `yaml:"query"`
	Columns map[string]*MetricColumn `yaml:"columns,omitempty"`
}

func NewTableGridItemTpl

func NewTableGridItemTpl(item *TableGridItem) *TableGridItemTpl

func (*TableGridItemTpl) Populate

func (tpl *TableGridItemTpl) Populate(item *TableGridItem) error

type Timeseries

type Timeseries struct {
	ID     uint64    `json:"id"`
	Name   string    `json:"name"`
	Metric string    `json:"metric"`
	Unit   string    `json:"unit"`
	Attrs  mql.Attrs `json:"attrs"`
	Value  []float64 `json:"value"`
}

type TimeseriesStyle

type TimeseriesStyle struct {
	Color      string  `json:"color" yaml:"color"`
	Opacity    int32   `json:"opacity" yaml:"opacity"`
	LineWidth  float32 `json:"lineWidth" yaml:"line_width"`
	Symbol     string  `json:"symbol" yaml:"symbol"`
	SymbolSize int32   `json:"symbolSize" yaml:"symbol_size"`
}

type ValueMapping

type ValueMapping struct {
	Op    MappingOp   `json:"op" yaml:"op"`
	Value json.Number `json:"value" yaml:"value"`
	Text  string      `json:"text" yaml:"text"`
	Color string      `json:"color" yaml:"color"`
}

func (*ValueMapping) Validate

func (m *ValueMapping) Validate() error

Directories

Path Synopsis
mql
ast

Jump to

Keyboard shortcuts

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