config.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package prometheusexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter"
  4. import (
  5. "time"
  6. "github.com/prometheus/client_golang/prometheus"
  7. "go.opentelemetry.io/collector/component"
  8. "go.opentelemetry.io/collector/config/confighttp"
  9. "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry"
  10. )
  11. // Config defines configuration for Prometheus exporter.
  12. type Config struct {
  13. confighttp.HTTPServerSettings `mapstructure:",squash"`
  14. // Namespace if set, exports metrics under the provided value.
  15. Namespace string `mapstructure:"namespace"`
  16. // ConstLabels are values that are applied for every exported metric.
  17. ConstLabels prometheus.Labels `mapstructure:"const_labels"`
  18. // SendTimestamps will send the underlying scrape timestamp with the export
  19. SendTimestamps bool `mapstructure:"send_timestamps"`
  20. // MetricExpiration defines how long metrics are kept without updates
  21. MetricExpiration time.Duration `mapstructure:"metric_expiration"`
  22. // ResourceToTelemetrySettings defines configuration for converting resource attributes to metric labels.
  23. ResourceToTelemetrySettings resourcetotelemetry.Settings `mapstructure:"resource_to_telemetry_conversion"`
  24. // EnableOpenMetrics enables the use of the OpenMetrics encoding option for the prometheus exporter.
  25. EnableOpenMetrics bool `mapstructure:"enable_open_metrics"`
  26. // AddMetricSuffixes controls whether suffixes are added to metric names. Defaults to true.
  27. AddMetricSuffixes bool `mapstructure:"add_metric_suffixes"`
  28. }
  29. var _ component.Config = (*Config)(nil)
  30. // Validate checks if the exporter configuration is valid
  31. func (cfg *Config) Validate() error {
  32. return nil
  33. }