translator

package
v0.0.0-...-61cc9b0 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: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DowncaseMetricNames

func DowncaseMetricNames(metricFamilies map[string]*dto.MetricFamily) map[string]*dto.MetricFamily

DowncaseMetricNames downcases metric names.

func FlattenSummaryMetricFamilies

func FlattenSummaryMetricFamilies(metricFamilies map[string]*dto.MetricFamily) map[string]*dto.MetricFamily

FlattenSummaryMetricFamilies flattens summary metric families into two counter metrics, one for the running sum and count, respectively

func MetricFamilyToMetricDescriptor

func MetricFamilyToMetricDescriptor(config *config.CommonConfig,
	family *dto.MetricFamily, originalDescriptor *v3.MetricDescriptor) *v3.MetricDescriptor

MetricFamilyToMetricDescriptor converts MetricFamily object to the MetricDescriptor. If needed it uses information from the previously created metricDescriptor (for example to merge label sets).

func OmitComponentName

func OmitComponentName(metricFamilies map[string]*dto.MetricFamily, componentName string) map[string]*dto.MetricFamily

OmitComponentName removes from the metric names prefix that is equal to component name.

func SendToStackdriver

func SendToStackdriver(service *v3.Service, config *config.CommonConfig, ts []*v3.TimeSeries, scrapeTimestamp time.Time)

SendToStackdriver sends http request to Stackdriver to create the given timeseries.

Types

type MetricDescriptorCache

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

MetricDescriptorCache is responsible for fetching, creating and updating metric descriptors from the stackdriver.

func NewMetricDescriptorCache

func NewMetricDescriptorCache(service *v3.Service, config *config.CommonConfig) *MetricDescriptorCache

NewMetricDescriptorCache creates empty metric descriptor cache for the given component.

func (*MetricDescriptorCache) GetMetricNames

func (cache *MetricDescriptorCache) GetMetricNames() []string

GetMetricNames returns a list of all metric names from the cache.

func (*MetricDescriptorCache) IsMetricBroken

func (cache *MetricDescriptorCache) IsMetricBroken(name string) bool

IsMetricBroken returns true if this metric descriptor assumed to invalid (for examples it has too many labels).

func (*MetricDescriptorCache) MarkStale

func (cache *MetricDescriptorCache) MarkStale()

MarkStale marks all records in the cache as stale until next Refresh() call.

func (*MetricDescriptorCache) Refresh

func (cache *MetricDescriptorCache) Refresh()

Refresh function fetches all metric descriptors of all metrics defined for given component with a defined prefix and puts them into cache.

func (*MetricDescriptorCache) UpdateMetricDescriptors

func (cache *MetricDescriptorCache) UpdateMetricDescriptors(metrics map[string]*dto.MetricFamily, whitelisted []string)

UpdateMetricDescriptors iterates over all metricFamilies and updates metricDescriptors in the Stackdriver if required.

func (*MetricDescriptorCache) ValidateMetricDescriptors

func (cache *MetricDescriptorCache) ValidateMetricDescriptors(metrics map[string]*dto.MetricFamily, whitelisted []string)

ValidateMetricDescriptors checks if metric descriptors differs from the values kept in the cache. If the value has changed then metric family is marked is broken. Use this method to verify that metrics with prefix "container.googleapis.com" haven't changed.

type PrometheusResponse

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

PrometheusResponse represents unprocessed response from Prometheus endpoint.

func GetPrometheusMetrics

func GetPrometheusMetrics(config *config.SourceConfig) (*PrometheusResponse, error)

GetPrometheusMetrics scrapes metrics from the given host and port using /metrics handler.

func (*PrometheusResponse) Build

func (p *PrometheusResponse) Build(config *config.CommonConfig, metricDescriptorCache *MetricDescriptorCache) (map[string]*dto.MetricFamily, error)

Build performs parsing and processing of the prometheus metrics response.

type TimeSeriesBuilder

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

TimeSeriesBuilder keeps track of incoming prometheus updates and can convert last received one to Stackdriver TimeSeries.

func NewTimeSeriesBuilder

func NewTimeSeriesBuilder(commonConfig *config.CommonConfig, cache *MetricDescriptorCache) *TimeSeriesBuilder

NewTimeSeriesBuilder creates new builder object that keeps intermediate state of metrics.

func (*TimeSeriesBuilder) Build

func (t *TimeSeriesBuilder) Build() ([]*v3.TimeSeries, time.Time, error)

Build returns a new TimeSeries array and restarts the internal state.

func (*TimeSeriesBuilder) Update

func (t *TimeSeriesBuilder) Update(batch *PrometheusResponse, timestamp time.Time)

Update updates the internal state with current batch.

Jump to

Keyboard shortcuts

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