dbwriter

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPartition           = ckdb.TimeFuncTwoHour
	MAX_APP_LABEL_COLUMN_INDEX = 256
)
View Source
const (
	QUEUE_BATCH_SIZE = 1024
	PROMETHEUS_DB    = "prometheus"
	PROMETHEUS_TABLE = "samples"
)

Variables

This section is empty.

Functions

func ReleasePrometheusSample

func ReleasePrometheusSample(p *PrometheusSample)

func ReleasePrometheusSampleMini

func ReleasePrometheusSampleMini(p *PrometheusSampleMini)

Types

type ClusterNode

type ClusterNode struct {
	Addr string
	Port uint16
}

type Counter

type Counter struct {
	MetricsCount int64 `statsd:"metrics-count"`
	WriteErr     int64 `statsd:"write-err"`
}

type PrometheusSample

type PrometheusSample struct {
	PrometheusSampleMini
	UniversalTag zerodoc.UniversalTag
}

func AcquirePrometheusSample

func AcquirePrometheusSample() *PrometheusSample

func (*PrometheusSample) Columns

func (m *PrometheusSample) Columns(appLabelColumnCount int) []*ckdb.Column

Note: The order of append() must be consistent with the order of Write() in WriteBlock.

func (*PrometheusSample) DatabaseName

func (m *PrometheusSample) DatabaseName() string

func (*PrometheusSample) GenCKTable

func (m *PrometheusSample) GenCKTable(cluster, storagePolicy string, ttl int, coldStorage *ckdb.ColdStorage, appLabelColumnCount int) *ckdb.Table

func (*PrometheusSample) GenerateNewFlowTags

func (m *PrometheusSample) GenerateNewFlowTags(cache *flow_tag.FlowTagCache, metricName string, timeSeries *prompb.TimeSeries, extraLabels []prompb.Label, tsLabelNameIDs, tsLabelValueIDs []uint32)

Check if there is a TagName/TagValue/MetricsName not in fieldCache or fieldValueCache, and store the newly appeared item in cache.

func (*PrometheusSample) PodNsId

func (m *PrometheusSample) PodNsId() uint16

func (*PrometheusSample) Release

func (m *PrometheusSample) Release()

func (*PrometheusSample) TableName

func (m *PrometheusSample) TableName() string

func (*PrometheusSample) VpcId

func (m *PrometheusSample) VpcId() int32

func (*PrometheusSample) WriteBlock

func (m *PrometheusSample) WriteBlock(block *ckdb.Block)

Note: The order of Write() must be consistent with the order of append() in Columns.

type PrometheusSampleInterface

type PrometheusSampleInterface interface {
	DatabaseName() string
	TableName() string
	WriteBlock(*ckdb.Block)
	Columns(int) []*ckdb.Column
	AppLabelLen() int
	GenCKTable(string, string, int, *ckdb.ColdStorage, int) *ckdb.Table
	GenerateNewFlowTags(*flow_tag.FlowTagCache, string, *prompb.TimeSeries, []prompb.Label, []uint32, []uint32)
	VpcId() int32
	PodNsId() uint16
	Release()
}

type PrometheusSampleMini

type PrometheusSampleMini struct {
	Timestamp        uint32 // s
	MetricID         uint32
	TargetID         uint32
	AppLabelValueIDs []uint32

	Value float64
}

func AcquirePrometheusSampleMini

func AcquirePrometheusSampleMini() *PrometheusSampleMini

func (*PrometheusSampleMini) AppLabelLen

func (m *PrometheusSampleMini) AppLabelLen() int

func (*PrometheusSampleMini) Columns

func (m *PrometheusSampleMini) Columns(appLabelColumnCount int) []*ckdb.Column

Note: The order of append() must be consistent with the order of Write() in WriteBlock.

func (*PrometheusSampleMini) DatabaseName

func (m *PrometheusSampleMini) DatabaseName() string

func (*PrometheusSampleMini) GenCKTable

func (m *PrometheusSampleMini) GenCKTable(cluster, storagePolicy string, ttl int, coldStorage *ckdb.ColdStorage, appLabelColumnCount int) *ckdb.Table

func (*PrometheusSampleMini) GenerateNewFlowTags

func (m *PrometheusSampleMini) GenerateNewFlowTags(cache *flow_tag.FlowTagCache, metricName string, timeSeries *prompb.TimeSeries, extraLabels []prompb.Label, tsLabelNameIDs, tsLabelValueIDs []uint32)

Check if there is a TagName/TagValue/MetricsName not in fieldCache or fieldValueCache, and store the newly appeared item in cache.

func (*PrometheusSampleMini) PodNsId

func (m *PrometheusSampleMini) PodNsId() uint16

func (*PrometheusSampleMini) Release

func (m *PrometheusSampleMini) Release()

func (*PrometheusSampleMini) TableName

func (m *PrometheusSampleMini) TableName() string

func (*PrometheusSampleMini) VpcId

func (m *PrometheusSampleMini) VpcId() int32

func (*PrometheusSampleMini) WriteBlock

func (m *PrometheusSampleMini) WriteBlock(block *ckdb.Block)

Note: The order of Write() must be consistent with the order of append() in Columns.

type PrometheusWriter

type PrometheusWriter struct {
	utils.Closable
	// contains filtered or unexported fields
}

func NewPrometheusWriter

func NewPrometheusWriter(
	decoderIndex int,
	initAppLabelCount int,
	name string,
	db string,
	config *config.Config) (*PrometheusWriter, error)

func (*PrometheusWriter) GetCounter

func (w *PrometheusWriter) GetCounter() interface{}

func (*PrometheusWriter) InitTable

func (w *PrometheusWriter) InitTable(appLabelCount int) error

func (*PrometheusWriter) WriteBatch

func (w *PrometheusWriter) WriteBatch(batch []interface{}, metricName string, timeSeries *prompb.TimeSeries, extraLabels []prompb.Label, tsLabelNameIDs, tsLabelValueIDs []uint32)

This function can be called when the FlowTags in the batch are the same (e.g. Prometheus metrics).

Jump to

Keyboard shortcuts

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