promtable

package module
v0.0.0-...-dbf8c57 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 31 Imported by: 0

README

Prometheus Cloud Bigtable remote storage supports both write and read.

Documentation

Index

Constants

View Source
const (

	// MetricNameLabel is the label name indicating the metric name of a
	// timeseries.
	MetricNameLabel = "__name__"
	// DefaultTableName -
	DefaultTableName = "metrics"

	// DefaultLongtermTableName -
	DefaultLongtermTableName = "metrics"

	// DefaultMetricMetaTableName -
	DefaultMetricMetaTableName = "metrics_meta"
	// DefaultBucketSizeHours -
	DefaultBucketSizeHours int64 = 24 // 24 hours

	// DefaultBucketSizeMilliSeconds - 24 hours.
	DefaultBucketSizeMilliSeconds int64 = 60 * 60 * 1000 // 1hr

)

Variables

This section is empty.

Functions

func BtRowToPromSamples

func BtRowToPromSamples(base int64, r bigtable.Row, startTs, endTs int64) []prompb.Sample

BtRowToPromSamples -

func EscapeLabelValue

func EscapeLabelValue(v string) string

EscapeLabelValue - # -> %23 , -> %2C

func Float64FromBytes

func Float64FromBytes(val []byte) float64

Float64FromBytes -

func Float64ToBytes

func Float64ToBytes(val float64) []byte

Float64ToBytes -

func Int32FromBytes

func Int32FromBytes(val []byte) int32

Int32FromBytes converts BigEdian bytes encoding to int32. bytes can be either 8 bytes or 10 bytes.

func Int32ToBytes

func Int32ToBytes(val int32) []byte

Int32ToBytes -

func Int64FromBytes

func Int64FromBytes(val []byte) int64

Int64FromBytes -

func Int64ToBytes

func Int64ToBytes(val int64) []byte

Int64ToBytes -

func LabelsFromString

func LabelsFromString(labelsString string) ([]prompb.Label, error)

LabelsFromString -

func LabelsToRowKeyComponents

func LabelsToRowKeyComponents(labels []prompb.Label) (name, labelsString string, err error)

LabelsToRowKeyComponents - labels must be sorted

func NewMetricRowRange

func NewMetricRowRange(name, hashedLabelsString, baseStart, baseEnd string) *btpb.RowRange

NewMetricRowRange - generate bigtable.RowRange

func QueryToBigtableMetaRowRange

func QueryToBigtableMetaRowRange(name string, startTs, endTs int64) (*btpb.RowRange, error)

QueryToBigtableMetaRowRange -

func QueryToBigtableTimeFilter

func QueryToBigtableTimeFilter(startMs, endMs int64) bigtable.Filter

QueryToBigtableTimeFilter -

func TimeMs

func TimeMs(tm time.Time) int64

TimeMs -

func TimestampToColumn

func TimestampToColumn(ts int64) string

TimestampToColumn column is the delta within the range.

func UnescapeLabelValue

func UnescapeLabelValue(v string) string

UnescapeLabelValue -

Types

type BT

type BT struct {
	TablePrefix string
	Instance    string
	ProjectID   string
	KeyPath     string
	Expiration  time.Duration
}

BT -

type Config

type Config struct {
	EnsureTables bool

	HashMetricName bool

	Bigtable BT

	EnableLongtermStorage bool
	LongtermBigtable      BT

	Web struct {
		Listen string
	}

	Metric struct {
		Enable bool
		Listen string
	}
}

Config -

func ParseFlags

func ParseFlags() *Config

ParseFlags -

type LabelsMatcher

type LabelsMatcher []*labelMatcher

LabelsMatcher - labelTester is sorted by name

func QueryMatchersToLabelsMatcher

func QueryMatchersToLabelsMatcher(qm []*prompb.LabelMatcher) (lsm LabelsMatcher, err error)

QueryMatchersToLabelsMatcher - qm must be sorted

func (LabelsMatcher) Len

func (m LabelsMatcher) Len() int

func (LabelsMatcher) Less

func (m LabelsMatcher) Less(i, j int) bool

func (LabelsMatcher) Match

func (m LabelsMatcher) Match(labels []prompb.Label) (ok bool)

Match - labels must be sorted

func (LabelsMatcher) Swap

func (m LabelsMatcher) Swap(i, j int)

type SeriesRange

type SeriesRange struct {
	// StartMs and EndMs are for filter metric sample columns.
	StartMs, EndMs int64
	// BaseStart and BaseEnd are for filter rowkey of metric samples.
	BaseStart, BaseEnd string
	Name, LabelsString string
	Labels             []prompb.Label
}

SeriesRange - represent a continues row range for a series. this allows pinpoint read of metric of the series.

func (*SeriesRange) String

func (s *SeriesRange) String() string

String -

type Server

type Server struct {
	Logger *zap.Logger
	// contains filtered or unexported fields
}

Server -

func NewServerWithConfig

func NewServerWithConfig(cfg *Config) (*Server, error)

NewServerWithConfig -

func (*Server) HandleRead

func (s *Server) HandleRead(w http.ResponseWriter, r *http.Request)

HandleRead -

func (*Server) HandleWrite

func (s *Server) HandleWrite(w http.ResponseWriter, r *http.Request)

HandleWrite -

func (*Server) Run

func (s *Server) Run() error

Run -

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop -

type Store

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

Store - bigtable store

func NewStore

func NewStore(options ...StoreOptionFunc) (*Store, error)

NewStore -

func (*Store) Close

func (s *Store) Close() error

Close -

func (*Store) EnsureTables

func (s *Store) EnsureTables(ctx context.Context) error

EnsureTables -

func (*Store) Put

func (s *Store) Put(ctx context.Context, req *prompb.WriteRequest) error

Put - for each Timeseries, prepare the metric_name, labelsString first.

RowKey: <name>#<base><hashed labels>

  • name will be raw name
  • base will be encoded into 8 bytes
  • hashed labels will be using murmur3 128 (128 bits, 16 byes)

Column Qualifier: <timestamp reminder><value>

  • 4 bytes timestamp reminder
  • 8 bytes

Column Value: nil Column Timestamp: sample timestamp

If longterm storage is enabled, Put will write to both storage.

func (*Store) Query

func (s *Store) Query(ctx context.Context, q *prompb.Query) ([]*prompb.TimeSeries, error)

Query performs read metrics against single prompb.Query It will first query the meta table to find out exactly which metric rows (ranges) are needed to fetch.

If metricExpiry is enabled, the query's timestamp range will be truncated. if metricExpiry is enabled and longterm storage is enabled, query will be send to separate places.

func (*Store) QueryMetaRows

func (s *Store) QueryMetaRows(ctx context.Context, q *prompb.Query) ([]SeriesRange, error)

QueryMetaRows - query metric meta index and return array of MetaRow which can be used to generate metric baseRange based name#labelsString

func (*Store) Read

Read -

func (*Store) RunMetaCacheGC

func (s *Store) RunMetaCacheGC()

RunMetaCacheGC -

type StoreMetrics

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

StoreMetrics -

func NewStoreMetrics

func NewStoreMetrics() *StoreMetrics

NewStoreMetrics -

func (*StoreMetrics) IncPutSampleCount

func (m *StoreMetrics) IncPutSampleCount(delta int)

IncPutSampleCount -

func (*StoreMetrics) IncPutTimeseriesCount

func (m *StoreMetrics) IncPutTimeseriesCount(delta int)

IncPutTimeseriesCount -

func (*StoreMetrics) IncQueryMetaColumnReadCount

func (m *StoreMetrics) IncQueryMetaColumnReadCount(matched bool, delta int)

IncQueryMetaColumnReadCount -

func (*StoreMetrics) IncQueryMetricRowReadCount

func (m *StoreMetrics) IncQueryMetricRowReadCount(delta int)

IncQueryMetricRowReadCount -

func (*StoreMetrics) IncQueryMetricSampleReadCount

func (m *StoreMetrics) IncQueryMetricSampleReadCount(delta int)

IncQueryMetricSampleReadCount -

func (*StoreMetrics) IncQueryMetricTimeseriesReadCount

func (m *StoreMetrics) IncQueryMetricTimeseriesReadCount(delta int)

IncQueryMetricTimeseriesReadCount -

func (*StoreMetrics) IncQuerySeriesRangesCount

func (m *StoreMetrics) IncQuerySeriesRangesCount(delta int)

IncQuerySeriesRangesCount -

type StoreOptionFunc

type StoreOptionFunc func(*Store) error

StoreOptionFunc -

func StoreWithBigtableAdminClient

func StoreWithBigtableAdminClient(ac *bigtable.AdminClient) StoreOptionFunc

StoreWithBigtableAdminClient -

func StoreWithBigtableClient

func StoreWithBigtableClient(c *bigtable.Client) StoreOptionFunc

StoreWithBigtableClient -

func StoreWithEnableLongtermStorage

func StoreWithEnableLongtermStorage(enabled bool) StoreOptionFunc

StoreWithEnableLongtermStorage -

func StoreWithEnableMetrics

func StoreWithEnableMetrics(enabled bool) StoreOptionFunc

StoreWithEnableMetrics -

func StoreWithHashLabels

func StoreWithHashLabels(hash bool) StoreOptionFunc

StoreWithHashLabels -

func StoreWithLogger

func StoreWithLogger(l *zap.Logger) StoreOptionFunc

StoreWithLogger -

func StoreWithLongermBigtableClient

func StoreWithLongermBigtableClient(c *bigtable.Client) StoreOptionFunc

StoreWithLongermBigtableClient -

func StoreWithLongtermBigtableAdminClient

func StoreWithLongtermBigtableAdminClient(ac *bigtable.AdminClient) StoreOptionFunc

StoreWithLongtermBigtableAdminClient -

func StoreWithLongtermTableNamePrefix

func StoreWithLongtermTableNamePrefix(prefix string) StoreOptionFunc

StoreWithLongtermTableNamePrefix -

func StoreWithMetricExpiration

func StoreWithMetricExpiration(exp time.Duration) StoreOptionFunc

StoreWithMetricExpiration -

func StoreWithTableNamePrefix

func StoreWithTableNamePrefix(prefix string) StoreOptionFunc

StoreWithTableNamePrefix -

Directories

Path Synopsis
cmd
pkg
Package version contains version information for this app.
Package version contains version information for this app.

Jump to

Keyboard shortcuts

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