Documentation ¶
Index ¶
- Constants
- Variables
- func NewBufferPool(capacity int) sync.Pool
- func NewPrometheusMetricsRepo(queryer db.Queryer, queryBufferPool *sync.Pool) *prometheusMetricRepo
- func NewReportResultsRepo(queryer db.Queryer) *reportResultsRepo
- func PrometheusMetricTimestampPartition(t time.Time) string
- func StorePrometheusMetricsWithBuffer(queryBuf *bytes.Buffer, ctx context.Context, queryer db.Queryer, ...) error
- type Config
- type ImporterMetricsCollectors
- type PrometheusImportResults
- type PrometheusImporter
- type PrometheusMetric
- type PrometheusMetricTimestampTracker
- type PrometheusMetricsGetter
- type PrometheusMetricsRepo
- type PrometheusMetricsStorer
- type ReportResultsGetter
- type ReportResultsRepo
- type ReportResultsStorer
- type ReportsResultsDeleter
Constants ¶
const PrometheusMetricTimestampPartitionFormat = "2006-01-02"
Variables ¶
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 NewReportResultsRepo ¶
Types ¶
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 ¶
type PrometheusMetricsGetter ¶
type PrometheusMetricsGetter interface {
GetPrometheusMetrics(tableName string, start, end time.Time) ([]*PrometheusMetric, error)
}
type PrometheusMetricsRepo ¶
type PrometheusMetricsRepo interface { PrometheusMetricsGetter PrometheusMetricsStorer PrometheusMetricTimestampTracker }
type PrometheusMetricsStorer ¶
type PrometheusMetricsStorer interface {
StorePrometheusMetrics(ctx context.Context, tableName string, metrics []*PrometheusMetric) error
}
type ReportResultsGetter ¶
type ReportResultsRepo ¶
type ReportResultsRepo interface { ReportResultsGetter ReportResultsStorer ReportsResultsDeleter }