promcw

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: MIT Imports: 24 Imported by: 0

README

promcw

Prometheus publisher to Cloud Watch

Configuration

// Config defines configuration options
type Config struct {
	// Required. The AWS Region to use
	AwsRegion string

	// Required. The CloudWatch namespace under which metrics should be published
	CloudWatchNamespace string

	// The frequency with which metrics should be published to Cloudwatch.
	CloudWatchPublishInterval time.Duration

	// Timeout for sending metrics to Cloudwatch.
	CloudWatchPublishTimeout time.Duration

	// Prometheus scrape URL. If it's empty, then internal Prometheus handler will be used.
	PrometheusScrapeURL string

	// Additional dimensions to send to CloudWatch
	AdditionalDimensions map[string]string

	// Replace dimensions with the provided label. This allows for aggregating metrics across dimensions so we can set CloudWatch Alarms on the metrics
	ReplaceDimensions map[string]string
}

Usage

	bridge, err := promcw.NewBridge(&c)
	if err != nil {
		return nil, errors.WithStack(err)
	}

    ctx, cancel := context.WithCancel(context.Background())
	bridge.Run(ctx)

    // To stop publisher call cancell when your service stops
    // cancel()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge pushes metrics to AWS CloudWatch

func NewBridge

func NewBridge(c *Config) (*Bridge, error)

NewBridge initializes and returns a pointer to a Bridge using the supplied configuration, or an error if there is a problem with the configuration

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context)

Run starts a loop that will push metrics to Cloudwatch at the configured interval. Accepts a context.Context to support cancellation

type Config

type Config struct {
	// Required. The AWS Region to use
	AwsRegion string

	// Required. The CloudWatch namespace under which metrics should be published
	CloudWatchNamespace string

	// The frequency with which metrics should be published to Cloudwatch.
	CloudWatchPublishInterval time.Duration

	// Timeout for sending metrics to Cloudwatch.
	CloudWatchPublishTimeout time.Duration

	// Prometheus scrape URL. If it's empty, then internal Prometheus handler will be used.
	PrometheusScrapeURL string

	// Additional dimensions to send to CloudWatch
	AdditionalDimensions map[string]string

	// Replace dimensions with the provided label. This allows for aggregating metrics across dimensions so we can set CloudWatch Alarms on the metrics
	ReplaceDimensions map[string]string
}

Config defines configuration options

Jump to

Keyboard shortcuts

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