Documentation ¶
Index ¶
- Constants
- func BtRowToPromSamples(base int64, r bigtable.Row, startTs, endTs int64) []prompb.Sample
- func EscapeLabelValue(v string) string
- func Float64FromBytes(val []byte) float64
- func Float64ToBytes(val float64) []byte
- func Int32FromBytes(val []byte) int32
- func Int32ToBytes(val int32) []byte
- func Int64FromBytes(val []byte) int64
- func Int64ToBytes(val int64) []byte
- func LabelsFromString(labelsString string) ([]prompb.Label, error)
- func LabelsToRowKeyComponents(labels []prompb.Label) (name, labelsString string, err error)
- func NewMetricRowRange(name, hashedLabelsString, baseStart, baseEnd string) *btpb.RowRange
- func QueryToBigtableMetaRowRange(name string, startTs, endTs int64) (*btpb.RowRange, error)
- func QueryToBigtableTimeFilter(startMs, endMs int64) bigtable.Filter
- func TimeMs(tm time.Time) int64
- func TimestampToColumn(ts int64) string
- func UnescapeLabelValue(v string) string
- type BT
- type Config
- type LabelsMatcher
- type SeriesRange
- type Server
- type Store
- func (s *Store) Close() error
- func (s *Store) EnsureTables(ctx context.Context) error
- func (s *Store) Put(ctx context.Context, req *prompb.WriteRequest) error
- func (s *Store) Query(ctx context.Context, q *prompb.Query) ([]*prompb.TimeSeries, error)
- func (s *Store) QueryMetaRows(ctx context.Context, q *prompb.Query) ([]SeriesRange, error)
- func (s *Store) Read(ctx context.Context, req *prompb.ReadRequest) (*prompb.ReadResponse, error)
- func (s *Store) RunMetaCacheGC()
- type StoreMetrics
- func (m *StoreMetrics) IncPutSampleCount(delta int)
- func (m *StoreMetrics) IncPutTimeseriesCount(delta int)
- func (m *StoreMetrics) IncQueryMetaColumnReadCount(matched bool, delta int)
- func (m *StoreMetrics) IncQueryMetricRowReadCount(delta int)
- func (m *StoreMetrics) IncQueryMetricSampleReadCount(delta int)
- func (m *StoreMetrics) IncQueryMetricTimeseriesReadCount(delta int)
- func (m *StoreMetrics) IncQuerySeriesRangesCount(delta int)
- type StoreOptionFunc
- func StoreWithBigtableAdminClient(ac *bigtable.AdminClient) StoreOptionFunc
- func StoreWithBigtableClient(c *bigtable.Client) StoreOptionFunc
- func StoreWithEnableLongtermStorage(enabled bool) StoreOptionFunc
- func StoreWithEnableMetrics(enabled bool) StoreOptionFunc
- func StoreWithHashLabels(hash bool) StoreOptionFunc
- func StoreWithLogger(l *zap.Logger) StoreOptionFunc
- func StoreWithLongermBigtableClient(c *bigtable.Client) StoreOptionFunc
- func StoreWithLongtermBigtableAdminClient(ac *bigtable.AdminClient) StoreOptionFunc
- func StoreWithLongtermTableNamePrefix(prefix string) StoreOptionFunc
- func StoreWithMetricExpiration(exp time.Duration) StoreOptionFunc
- func StoreWithTableNamePrefix(prefix string) StoreOptionFunc
Constants ¶
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 ¶
BtRowToPromSamples -
func Int32FromBytes ¶
Int32FromBytes converts BigEdian bytes encoding to int32. bytes can be either 8 bytes or 10 bytes.
func LabelsFromString ¶
LabelsFromString -
func LabelsToRowKeyComponents ¶
LabelsToRowKeyComponents - labels must be sorted
func NewMetricRowRange ¶
NewMetricRowRange - generate bigtable.RowRange
func QueryToBigtableMetaRowRange ¶
QueryToBigtableMetaRowRange -
func QueryToBigtableTimeFilter ¶
QueryToBigtableTimeFilter -
func TimestampToColumn ¶
TimestampToColumn column is the delta within the range.
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 -
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.
type Server ¶
Server -
func NewServerWithConfig ¶
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 -
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store - bigtable store
func (*Store) Put ¶
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 ¶
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 ¶
QueryMetaRows - query metric meta index and return array of MetaRow which can be used to generate metric baseRange based name#labelsString
func (*Store) Read ¶
func (s *Store) Read(ctx context.Context, req *prompb.ReadRequest) (*prompb.ReadResponse, error)
Read -
type StoreMetrics ¶
type StoreMetrics struct {
// contains filtered or unexported fields
}
StoreMetrics -
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 ¶
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 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 -