metrics

package
v0.4.73 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AccountIdLabel     = "neosyncAccountId"
	JobIdLabel         = "neosyncJobId"
	TemporalWorkflowId = "temporalWorkflowId"
	TemporalRunId      = "temporalRunId"

	TableSchemaLabel    = "tableSchema"
	TableNameLabel      = "tableName"
	JobTypeLabel        = "jobType"
	IsUpdateConfigLabel = "isUpdateConfig"

	NeosyncDateLabel  = "date"
	NeosyncDateFormat = "2006-01-02"

	TemporalWorkflowIdEnvKey = "TEMPORAL_WORKFLOW_ID"
	TemporalRunIdEnvKey      = "TEMPORAL_ENV_ID"
	NeosyncDateEnvKey        = "NEOSYNC_DATE"
)

Variables

This section is empty.

Functions

func CalculatePromLookbackDuration added in v0.4.70

func CalculatePromLookbackDuration(startDate, endDate *mgmtv1alpha1.Date) string

For a given date range, returns the lookback period duration to be plugged in to the PromQL Query

Returns:

2024-09-14, 2024-09-15 == 2d

func DateToTime added in v0.4.70

func DateToTime(d *mgmtv1alpha1.Date) time.Time

func GenerateMonthRegexRange added in v0.4.70

func GenerateMonthRegexRange(startDate, endDate *mgmtv1alpha1.Date) []string

For a given date range, returns the PromQL Month Regex Patterns.

Returns:

[]string{"2024-09-.*", "2024-10-.*"}

func GetDailyUsageFromProm added in v0.4.65

func GetDailyUsageFromProm(
	ctx context.Context,
	api promv1.API,
	query string,
	ts time.Time,
	logger *slog.Logger,
) ([]*mgmtv1alpha1.DayResult, float64, error)

func GetPromQueryFromMetric added in v0.4.65

func GetPromQueryFromMetric(
	metric mgmtv1alpha1.RangedMetricName,
	labels MetricLabels,
	timeWindow string,
) (string, error)

func GetTotalUsageFromProm added in v0.4.65

func GetTotalUsageFromProm(ctx context.Context, api promv1.API, query string, dayEnd time.Time, logger *slog.Logger) (float64, error)

func ToEndOfDay added in v0.4.70

func ToEndOfDay(t time.Time) time.Time

Types

type MetricLabel

type MetricLabel struct {
	Key   string
	Value string
	Sign  string
}

func NewEqLabel

func NewEqLabel(key, value string) MetricLabel

func NewNotEqLabel

func NewNotEqLabel(key, value string) MetricLabel

note: this has only been tested with prometheus and using it with benthos is not currently supported

func NewRegexMatchLabel added in v0.4.70

func NewRegexMatchLabel(key, value string) MetricLabel

This is used when querying Prometheus and is not supported when using with Benthos

func (*MetricLabel) ToBenthosMeta

func (m *MetricLabel) ToBenthosMeta() string

func (*MetricLabel) ToPromQueryString

func (m *MetricLabel) ToPromQueryString() string

type MetricLabels

type MetricLabels []MetricLabel

func (MetricLabels) ToBenthosMeta

func (m MetricLabels) ToBenthosMeta() string

func (MetricLabels) ToPromQueryString

func (m MetricLabels) ToPromQueryString() string

Jump to

Keyboard shortcuts

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