config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Example
cfg, _, _, err := Configure([]string{
	"program",
	"--config-file=./sidecar.example.yaml",
}, ioutil.ReadFile)
if err != nil {
	log.Fatal(err)
}

data, err := json.MarshalIndent(cfg, "", "  ")
if err != nil {
	log.Fatal(err)
}

fmt.Println(string(data))
Output:

{
  "destination": {
    "endpoint": "https://otlp.io:443",
    "headers": {
      "access-token": "aabbccdd...wwxxyyzz"
    },
    "attributes": {
      "environment": "public",
      "service.name": "demo"
    },
    "timeout": "2m0s",
    "compression": "snappy"
  },
  "prometheus": {
    "endpoint": "http://127.0.0.1:19090",
    "wal": "/volume/wal",
    "max_point_age": "72h0m0s"
  },
  "opentelemetry": {
    "metrics_prefix": "prefix.",
    "use_meta_labels": true
  },
  "admin": {
    "listen_ip": "0.0.0.0",
    "port": 10000
  },
  "security": {
    "root_certificates": [
      "/certs/root1.crt",
      "/certs/root2.crt"
    ]
  },
  "diagnostics": {
    "endpoint": "https://otlp.io:443",
    "headers": {
      "access-token": "wwxxyyzz...aabbccdd"
    },
    "attributes": {
      "environment": "internal"
    },
    "timeout": "1m0s",
    "compression": "snappy"
  },
  "startup_delay": "30s",
  "startup_timeout": "5m0s",
  "filters": [
    "metric{label=value}",
    "other{l1=v1,l2=v2}"
  ],
  "metric_renames": [
    {
      "from": "old_metric",
      "to": "new_metric"
    },
    {
      "from": "mistake",
      "to": "correct"
    }
  ],
  "static_metadata": [
    {
      "metric": "network_bps",
      "type": "counter",
      "value_type": "int64",
      "help": "Number of bits transferred by this process."
    }
  ],
  "log_config": {
    "level": "debug",
    "format": "json",
    "verbose": 1
  },
  "disable_supervisor": false,
  "disable_diagnostics": false
}

Index

Examples

Constants

View Source
const (
	DefaultAdminPort          = 9091
	DefaultAdminListenIP      = "0.0.0.0"
	DefaultPrometheusEndpoint = "http://127.0.0.1:9090/"
	DefaultWALDirectory       = "data/wal"

	DefaultExportTimeout      = time.Second * 60
	DefaultHealthCheckTimeout = time.Second * 5
	DefaultMaxPointAge        = time.Hour * 25
	DefaultReportingPeriod    = time.Second * 30
	DefaultStartupDelay       = time.Minute
	DefaultShutdownDelay      = time.Minute
	DefaultStartupTimeout     = time.Minute * 5
	DefaultNoisyLogPeriod     = time.Second * 5
	DefaultPrometheusTimeout  = time.Second * 60

	DefaultSupervisorBufferSize  = 16384
	DefaultSupervisorLogsHistory = 16

	// How many points per request.
	MaxTimeseriesPerRequest = 200

	// DefaultMaxExportAttempts sets a maximum on the number of
	// attempts to export a request.  This is not RPC requests,
	// but attempts, defined as trying for up to at least the
	// export timeout.  This helps in case a request fails
	// repeatedly, in which case the queue could block the WAL
	// reader.
	DefaultMaxExportAttempts = 2

	AgentKey = "telemetry-reporting-agent"

	SidecarPrefix       = "sidecar."
	ProcessedMetric     = "sidecar.samples.processed"
	ProducedMetric      = "sidecar.samples.produced"
	OutcomeMetric       = "sidecar.queue.outcome"
	DroppedSeriesMetric = "sidecar.dropped.series"

	OutcomeKey          = label.Key("outcome")
	OutcomeSuccessValue = "success"
)

Variables

View Source
var (
	AgentMainValue = fmt.Sprint(
		"opentelemetry-prometheus-sidecar-main/",
		version.Version,
	)
	AgentSecondaryValue = fmt.Sprint(
		"opentelemetry-prometheus-sidecar-telemetry/",
		version.Version,
	)
	AgentSupervisorValue = fmt.Sprint(
		"opentelemetry-prometheus-sidecar-supervisor/",
		version.Version,
	)
)

Functions

func DefaultQueueConfig added in v0.12.0

func DefaultQueueConfig() promconfig.QueueConfig

TODO Move this config object into MainConfig (or at least the fields we use, which is most) and add command-line flags.

Types

type AdminConfig

type AdminConfig struct {
	ListenIP string `json:"listen_ip"`
	Port     int    `json:"port"`
}

type DurationConfig

type DurationConfig struct {
	time.Duration `json:"duration" yaml:"-,inline"`
}

func (DurationConfig) MarshalJSON

func (d DurationConfig) MarshalJSON() ([]byte, error)

func (*DurationConfig) UnmarshalJSON

func (d *DurationConfig) UnmarshalJSON(data []byte) error

type FileReadFunc

type FileReadFunc func(filename string) ([]byte, error)

type LogConfig

type LogConfig struct {
	Level   string `json:"level"`
	Format  string `json:"format"`
	Verbose int    `json:"verbose"`
}

type MainConfig

type MainConfig struct {
	Destination    OTLPConfig             `json:"destination"`
	Prometheus     PromConfig             `json:"prometheus"`
	OpenTelemetry  OTelConfig             `json:"opentelemetry"`
	Admin          AdminConfig            `json:"admin"`
	Security       SecurityConfig         `json:"security"`
	Diagnostics    OTLPConfig             `json:"diagnostics"`
	StartupDelay   DurationConfig         `json:"startup_delay"`
	StartupTimeout DurationConfig         `json:"startup_timeout"`
	Filters        []string               `json:"filters"`
	MetricRenames  []MetricRenamesConfig  `json:"metric_renames"`
	StaticMetadata []StaticMetadataConfig `json:"static_metadata"`
	LogConfig      LogConfig              `json:"log_config"`

	DisableSupervisor  bool `json:"disable_supervisor"`
	DisableDiagnostics bool `json:"disable_diagnostics"`

	// This field cannot be parsed inside a configuration file,
	// only can be set by command-line flag.:
	ConfigFilename string `json:"-" yaml:"-"`
}

func Configure

func Configure(args []string, readFunc FileReadFunc) (MainConfig, map[string]string, []*metadata.Entry, error)

Configure is a separate unit of code for testing purposes.

func DefaultMainConfig

func DefaultMainConfig() MainConfig

type MetricRenamesConfig

type MetricRenamesConfig struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type OTLPConfig

type OTLPConfig struct {
	Endpoint    string            `json:"endpoint"`
	Headers     map[string]string `json:"headers"`
	Attributes  map[string]string `json:"attributes"`
	Timeout     DurationConfig    `json:"timeout"`
	Compression string            `json:"compression"`
}

type OTelConfig

type OTelConfig struct {
	MetricsPrefix string `json:"metrics_prefix"`
	UseMetaLabels bool   `json:"use_meta_labels"`
}

type PromConfig

type PromConfig struct {
	Endpoint    string         `json:"endpoint"`
	WAL         string         `json:"wal"`
	MaxPointAge DurationConfig `json:"max_point_age"`
}

type SecurityConfig

type SecurityConfig struct {
	RootCertificates []string `json:"root_certificates"`
}

type StaticMetadataConfig

type StaticMetadataConfig struct {
	Metric    string `json:"metric"`
	Type      string `json:"type"`
	ValueType string `json:"value_type"`
	Help      string `json:"help"`
}

TODO: Note that the ../metadata package cannot depend on this package because of a cycle involving this type, which is _nearly_ identical to the Entry{} type of that package. If that package would use _this_ type it would help greatly, and then that package could refer to this one for configuration.

Jump to

Keyboard shortcuts

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