prestostore

package
v0.0.0-...-1d44d98 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PrometheusMetricTimestampPartitionFormat = "2006-01-02"

Variables

View Source
var (
	PrometheusMetricHiveTableColumns = []hive.Column{
		{Name: amountColumnName, Type: "double"},
		{Name: timestampColumnName, Type: "timestamp"},
		{Name: timePrecisionColumnName, Type: "double"},
		{Name: labelsColumnName, Type: "map<string, string>"},
	}
	PrometheusMetricHivePartitionColumns = []hive.Column{
		{Name: dtColumnName, Type: "string"},
	}

	// Initialized by init()
	PrometheusMetricPrestoTableColumn, PrometheusMetricPrestoPartitionColumns, PrometheusMetricPrestoAllColumns []presto.Column
)

Functions

func NewBufferPool

func NewBufferPool(capacity int) sync.Pool

func NewPrometheusMetricsRepo

func NewPrometheusMetricsRepo(queryer db.Queryer, queryBufferPool *sync.Pool) *prometheusMetricRepo

func NewReportResultsRepo

func NewReportResultsRepo(queryer db.Queryer) *reportResultsRepo

func PrometheusMetricTimestampPartition

func PrometheusMetricTimestampPartition(t time.Time) string

func StorePrometheusMetricsWithBuffer

func StorePrometheusMetricsWithBuffer(queryBuf *bytes.Buffer, ctx context.Context, queryer db.Queryer, tableName string, metrics []*PrometheusMetric) error

storePrometheusMetricsWithBuffer handles storing Prometheus metrics into the specified Presto table.

Types

type Config

type Config struct {
	PrometheusQuery           string
	PrestoTableName           string
	ChunkSize                 time.Duration
	StepSize                  time.Duration
	MaxTimeRanges             int64
	MaxQueryRangeDuration     time.Duration
	ImportFromTime            *time.Time
	MaxBackfillImportDuration time.Duration
}

type ImporterMetricsCollectors

type ImporterMetricsCollectors struct {
	TotalImportsCounter     prometheus.Counter
	FailedImportsCounter    prometheus.Counter
	ImportDurationHistogram prometheus.Observer

	TotalPrometheusQueriesCounter    prometheus.Counter
	FailedPrometheusQueriesCounter   prometheus.Counter
	PrometheusQueryDurationHistogram prometheus.Observer

	TotalPrestoStoresCounter     prometheus.Counter
	FailedPrestoStoresCounter    prometheus.Counter
	PrestoStoreDurationHistogram prometheus.Observer

	MetricsScrapedCounter  prometheus.Counter
	MetricsImportedCounter prometheus.Counter

	ImportsRunningGauge prometheus.Gauge
}

type PrometheusImportResults

type PrometheusImportResults struct {
	ProcessedTimeRanges []prom.Range
	Metrics             []*PrometheusMetric
}

func ImportFromTimeRange

func ImportFromTimeRange(logger logrus.FieldLogger, clock clock.Clock, promConn prom.API, prometheusMetricsStorer PrometheusMetricsStorer, metricsCollectors ImporterMetricsCollectors, ctx context.Context, startTime, endTime time.Time, cfg Config) (PrometheusImportResults, error)

importFromTimeRange executes a promQL query over the interval between start and end, performing multiple Prometheus query_range queries of chunkSize. Returns the time ranges queried and any errors encountered. Stops after the first error, consult timeRanges to determine how many chunks were queried.

If the number of queries exceeds maxTimeRanges, then the timeRanges exceeding that count will be skipped.

type PrometheusImporter

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

PrometheusImporter imports Prometheus metrics into Presto tables

func NewPrometheusImporter

func NewPrometheusImporter(logger logrus.FieldLogger, promConn prom.API, prometheusMetricsRepo PrometheusMetricsRepo, clock clock.Clock, cfg Config, collectors ImporterMetricsCollectors) *PrometheusImporter

func (*PrometheusImporter) ImportFromLastTimestamp

func (importer *PrometheusImporter) ImportFromLastTimestamp(ctx context.Context) (*PrometheusImportResults, error)

ImportFromLastTimestamp executes a Presto query from the last time range it queried and stores the results in a Presto table. The importer will track the last time series it retrieved and will query the next time range starting from where it left off if paused or stopped. For more details on how querying Prometheus is done, see the package pkg/promquery.

func (*PrometheusImporter) UpdateConfig

func (importer *PrometheusImporter) UpdateConfig(cfg Config)

type PrometheusMetric

type PrometheusMetric struct {
	Labels    map[string]string `json:"labels"`
	Amount    float64           `json:"amount"`
	StepSize  time.Duration     `json:"stepSize"`
	Timestamp time.Time         `json:"timestamp"`
	Dt        string            `json:"dt"`
}

PrometheusMetric is a receipt of a usage determined by a query within a specific time range.

func GetPrometheusMetrics

func GetPrometheusMetrics(queryer db.Queryer, tableName string, start, end time.Time) ([]*PrometheusMetric, error)

type PrometheusMetricTimestampTracker

type PrometheusMetricTimestampTracker interface {
	GetLastTimestampForTable(tableName string) (*time.Time, error)
}

type PrometheusMetricsGetter

type PrometheusMetricsGetter interface {
	GetPrometheusMetrics(tableName string, start, end time.Time) ([]*PrometheusMetric, error)
}

type PrometheusMetricsStorer

type PrometheusMetricsStorer interface {
	StorePrometheusMetrics(ctx context.Context, tableName string, metrics []*PrometheusMetric) error
}

type ReportResultsGetter

type ReportResultsGetter interface {
	GetReportResults(tableName string, columns []presto.Column) ([]presto.Row, error)
}

type ReportResultsStorer

type ReportResultsStorer interface {
	StoreReportResults(tableName, query string) error
}

type ReportsResultsDeleter

type ReportsResultsDeleter interface {
	DeleteReportResults(tableName string) error
}

Directories

Path Synopsis
Package mockprestostore is a generated GoMock package.
Package mockprestostore is a generated GoMock package.

Jump to

Keyboard shortcuts

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