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", "health_check_request_timeout": "5s" }, "opentelemetry": { "max_bytes_per_request": 1500, "metrics_prefix": "prefix.", "min_shards": 100, "max_shards": 200, "queue_size": 100001 }, "admin": { "listen_ip": "0.0.0.0", "port": 10000, "health_check_period": "20s", "health_check_threshold_ratio": 0.5 }, "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_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": { "level": "debug", "format": "json", "verbose": 1 }, "leader_election": { "enabled": true, "k8s": { "namespace": "tools" } }, "disable_supervisor": false, "disable_diagnostics": false }
Index ¶
- Constants
- Variables
- func Configure(args []string, readFunc FileReadFunc) (MainConfig, map[string]string, []*MetadataEntry, error)
- type AdminConfig
- type DurationConfig
- type FileReadFunc
- type K8SLeaderElectionConfig
- type Kind
- type LeaderElectionConfig
- type LogConfig
- type MainConfig
- type MetadataEntry
- type MetricRenamesConfig
- type OTLPConfig
- type OTelConfig
- type PromConfig
- type PromReady
- type SecurityConfig
- type StaticMetadataConfig
- type ValueType
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 DefaultHealthCheckPeriod = time.Second * 60 DefaultHealthCheckThresholdRatio = 0.5 DefaultReadinessPeriod = time.Second * 5 DefaultScrapeIntervalWaitPeriod = time.Minute DefaultMaxPointAge = time.Hour * 25 DefaultShutdownDelay = time.Minute DefaultStartupTimeout = time.Minute * 10 DefaultNoisyLogPeriod = time.Second * 60 DefaultPrometheusTimeout = time.Second * 60 DefaultSingleMetricBatchSizeLimit = 4096 DefaultSupervisorBufferSize = 16384 DefaultSupervisorLogsHistory = 16 // How many bytes per request DefaultMaxBytesPerRequest = 65536 // How many items can be queued before the reader blocks // // Note: queue entries are 16 bytes, this is a large block of memory. // TODO: Consider adjusting this down after understanding performance // of the single-queue approach to sharding taken in #247. DefaultQueueSize = 100000 // Min number of shards, i.e. amount of concurrency DefaultMinShards = 1 // Max number of shards, i.e. amount of concurrency DefaultMaxShards = 200 // TODO: This was 1 minute; it's not clear how often it should // happen bit it's a suspiciously short timeout given that it // can race with startup. Should we wait until the WAL reader // reaches a current position before we begin garbage // collection? DefaultSeriesCacheGarbageCollectionPeriod = time.Minute * 15 // DefaultSeriesCacheLookupPeriod determines how often the // sidecar will try to load metadata for the series when it is // not known. DefaultSeriesCacheLookupPeriod = time.Minute * 3 // 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 DefaultMaxRetrySkipSegments = 5 // DefaultCheckpointInProgressPeriod is the maximum amount of time // to wait if it appears a checkpoint is in progress. DefaultCheckpointInProgressPeriod = time.Minute * 5 AgentKey = "telemetry-reporting-agent" SidecarPrefix = "sidecar." SeriesDefinedMetric = "sidecar.series.defined" DroppedSeriesMetric = "sidecar.series.dropped" CurrentSeriesMetric = "sidecar.series.current" OutcomeMetric = "sidecar.queue.outcome" ProducedPointsMetric = "sidecar.points.produced" DroppedPointsMetric = "sidecar.points.dropped" SkippedPointsMetric = "sidecar.points.skipped" FailingMetricsMetric = "sidecar.metrics.failing" CurrentMetricsMetric = "sidecar.metrics.current" LeadershipMetric = "sidecar.leadership" OutcomeKey = attribute.Key("outcome") OutcomeSuccessValue = "success" HealthCheckURI = "/-/health" // PrometheusCurrentSegmentMetricName names an internal gauge // exposed by Prometheus (having no attributes). PrometheusCurrentSegmentMetricName = "prometheus_tsdb_wal_segment_current" // PrometheusTargetIntervalLengthName is an internal histogram // indicating how long the interval between scrapes. PrometheusTargetIntervalLengthName = "prometheus_target_interval_length_seconds" // PrometheusBuildInfoName provides prometheus version information PrometheusBuildInfoName = "prometheus_build_info" // PrometheusMinVersion is the minimum supported version PrometheusMinVersion = "2.10.0" // LeaderLockDefaultNamespace is the name of the default k8s namespace. // Note: can't be empty. LeaderLockDefaultNamespace = "default" // LeaderLockDefaultName will be used when no `prometheus` // external label is found. LeaderLockDefaultName = "otel-prom-sidecar" )
View Source
const ( GAUGE Kind = 1 CUMULATIVE Kind = 2 DELTA Kind = 3 DOUBLE ValueType = 1 INT64 ValueType = 2 DISTRIBUTION ValueType = 3 HISTOGRAM ValueType = 4 )
View Source
const ( PrometheusTargetMetadataEndpointPath = "api/v1/targets/metadata" PrometheusMetadataEndpointPath = "api/v1/metadata" PrometheusConfigEndpointPath = "api/v1/status/config" )
DefaultEndpointPath is the default HTTP path on which Prometheus serves the target metadata endpoint.
View Source
const MetricTypeUntyped = "untyped"
The old metric type value for textparse.MetricTypeUnknown that is used in Prometheus 2.4 and earlier.
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 Configure ¶
func Configure(args []string, readFunc FileReadFunc) (MainConfig, map[string]string, []*MetadataEntry, error)
Configure is a separate unit of code for testing purposes.
Types ¶
type AdminConfig ¶
type AdminConfig struct { ListenIP string `json:"listen_ip"` Port int `json:"port"` HealthCheckPeriod DurationConfig `json:"health_check_period"` HealthCheckThresholdRatio float64 `json:"health_check_threshold_ratio"` }
type DurationConfig ¶
func (DurationConfig) MarshalJSON ¶
func (d DurationConfig) MarshalJSON() ([]byte, error)
func (*DurationConfig) UnmarshalJSON ¶
func (d *DurationConfig) UnmarshalJSON(data []byte) error
type FileReadFunc ¶
type K8SLeaderElectionConfig ¶ added in v0.26.0
type K8SLeaderElectionConfig struct {
Namespace string `json:"namespace"`
}
type LeaderElectionConfig ¶ added in v0.26.0
type LeaderElectionConfig struct { Enabled bool `json:"enabled"` K8S K8SLeaderElectionConfig `json:"k8s"` }
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"` StartupTimeout DurationConfig `json:"startup_timeout"` Filters []string `json:"filters"` MetricRenames []MetricRenamesConfig `json:"metric_renames"` StaticMetadata []StaticMetadataConfig `json:"static_metadata"` LogConfig LogConfig `json:"log"` LeaderElection LeaderElectionConfig `json:"leader_election"` 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 DefaultMainConfig ¶
func DefaultMainConfig() MainConfig
func (MainConfig) QueueConfig ¶
func (c MainConfig) QueueConfig() promconfig.QueueConfig
TODO Remove this code. Stop using promconfig.QueueConfig.
type MetadataEntry ¶
type MetadataEntry struct { Metric string MetricType textparse.MetricType ValueType ValueType Help string }
MetadataEntry is the parsed and checked form of StaticMetadataConfig
type MetricRenamesConfig ¶
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"` }
func (OTLPConfig) Copy ¶ added in v0.24.0
func (config OTLPConfig) Copy() OTLPConfig
type OTelConfig ¶
type PromConfig ¶
type PromConfig struct { Endpoint string `json:"endpoint"` WAL string `json:"wal"` MaxPointAge DurationConfig `json:"max_point_age"` HealthCheckRequestTimeout DurationConfig `json:"health_check_request_timeout"` }
type PromReady ¶
type PromReady struct { Logger log.Logger PromURL *url.URL StartupDelayEffectiveStartTime time.Time HealthCheckRequestTimeout time.Duration }
PromReady is used for prometheus.WaitForReady() in several places. It is not parsed from the config file or command-line, it is here to avoid a test package cycle, primarily.
type SecurityConfig ¶
type SecurityConfig struct {
RootCertificates []string `json:"root_certificates"`
}
type StaticMetadataConfig ¶
type StaticMetadataConfig struct { Metric string `json:"metric"` Type textparse.MetricType `json:"type"` ValueType string `json:"value_type"` Help string `json:"help"` }
Click to show internal directories.
Click to hide internal directories.