googlemanagedprometheus

package module
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 12 Imported by: 3

README

Google Managed Service for Prometheus Collector Exporter

Building a container image with the googlemanagedprometheus exporter

In your own fork of open-telemetry/opentelemetry-collector-releases, add your own "distribution" directory within the distributions directory, based on either the otelcol or otelcol-contrib distributions. In the exporters list in manifest.yaml, add:

exporters:
  - gomod: "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector/googlemanagedprometheus v0.30.1"

The syntax of manifest.yaml is described in the Collector Builder documentation.

In the configs directory, add your collector configuration yaml file, which should look something like:

receivers:
    prometheus:
        config:
          scrape_configs:
            # Add your prometheus scrape configuration here.
            # Using kubernetes_sd_configs with namespaced resources
            # ensures the namespace is set on your metrics.
            - job_name: 'kubernetes-pods'
                kubernetes_sd_configs:
                - role: pod
                relabel_configs:
                - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
                action: keep
                regex: true
                - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
                action: replace
                target_label: __metrics_path__
                regex: (.+)
                - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
                action: replace
                regex: (.+):(?:\d+);(\d+)
                replacement: $$1:$$2
                target_label: __address__
                - action: labelmap
                regex: __meta_kubernetes_pod_label_(.+)
processors:
    # groupbyattrs promotes labels from metrics to resources, allowing them to
    # be added to the prometheus_target monitored resource.
    # This allows exporters which monitor multiple namespaces, such as
    # kube-state-metrics, to override the namespace in the resource by setting
    # metric labels.
    groupbyattrs:
      keys:
        - namespace
        - cluster
        - location
    batch:
        # batch metrics before sending to reduce API usage
        send_batch_max_size: 200
        send_batch_size: 200
        timeout: 5s
    memory_limiter:
        # drop metrics if memory usage gets too high
        check_interval: 1s
        limit_percentage: 65
        spike_limit_percentage: 20
    resourcedetection:
        # detect cluster name and location
        detectors: [gce, gke]
        timeout: 10s
exporters:
    googlemanagedprometheus:

service:
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: [groupbyattrs, batch, memory_limiter, resourcedetection]
      exporters: [googlemanagedprometheus]

Change the Dockerfile in your directory within distributions to point to your collector config here.

Finally, build the image:

DISTRIBUTIONS=my-distribution make build

Additional Options

The filterprocessor can filter out metrics. The metricstransformprocessor can manipulate metrics in a variety of ways, including synthesizing new metrics from other metrics, adding or removing labels, renaming metrics, and scaling metrics. metric_relabl_configs within the prometheus receiver configuration can also be used to manipulate metrics.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMetricName

func GetMetricName(baseName string, metric pmetric.Metric) (string, error)

func NewFactory

func NewFactory() component.ExporterFactory

NewFactory creates a factory for the googlemanagedprometheus exporter

Types

type Config

type Config struct {
	config.ExporterSettings `mapstructure:",squash"`
	GMPConfig               `mapstructure:",squash"`

	// Timeout for all API calls. If not set, defaults to 12 seconds.
	exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
	exporterhelper.QueueSettings   `mapstructure:"sending_queue"`
	exporterhelper.RetrySettings   `mapstructure:"retry_on_failure"`
}

Config defines configuration for Google Cloud Managed Service for Prometheus exporter.

func (*Config) Validate

func (cfg *Config) Validate() error

type GMPConfig

type GMPConfig struct {
	ProjectID    string                 `mapstructure:"project"`
	UserAgent    string                 `mapstructure:"user_agent"`
	ClientConfig collector.ClientConfig `mapstructure:",squash"`
}

GMPConfig is a subset of the collector config.

Jump to

Keyboard shortcuts

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