Documentation
¶
Overview ¶
Package logexporter renders the configuration for alloy-logexporter, the installation-wide app that archives selected logs to destinations outside the observability platform.
Rendering is pure: LogExport resources and already-resolved credentials in, Helm values out. The controller owns reading credentials and persisting the result, the same split the collectors use.
Index ¶
Constants ¶
const ( // Port is the push endpoint mirrored requests arrive on. It must match the chart's // extraPorts entry and the mirror backendRef. Port = 3100 // WALDirectory holds the persistent sending queue. It sits under WALMountPath, which // is a per-replica PVC: the WAL is what carries buffered records across a pod restart. WALMountPath = "/var/lib/alloy" WALDirectory = WALMountPath + "/wal" // RunAsUser is the chart's Alloy user, needed as fsGroup so a fresh PVC is writable. RunAsUser = 473 // QueueSize is in items because the queue holds one entry per Loki entry. The default // of 1000 requests is under a second of buffer at installation scale and overflows // silently. QueueSize = 200000 QueueConsumers = 4 // Batching is mandatory: otelcol.receiver.loki calls ConsumeLogs once per entry, so // without it every log line becomes its own object. BatchMinSize sets object size and // BatchFlushTimeout sets the worst-case latency to the archive. BatchMinSize = 1000 BatchMaxSize = 10000 BatchFlushTimeout = "60s" // Retries within the export timeout. Once it elapses the exporter gives up, so // raising these past the configured timeout buys nothing. RetryMaxAttempts = 10 RetryMaxBackoff = "5m" )
Tuning that is neither on the CRD nor in the operator's configuration. Every value here is set to a specific measured failure, and getting one wrong loses data silently rather than merely performing differently, so change them only with the same kind of evidence.
const ( // Environment variable names for static S3 credentials. otelcol.exporter.awss3 has no // credential arguments at all -- it reads the AWS SDK's default chain -- so these are // the names the SDK defined, not a choice of ours. // // They double as the keys a credentialsRef Secret has to carry, which is documented on // LogExport.spec.destination.s3.credentialsRef and published in the CRD schema. AccessKeyIDEnv = "AWS_ACCESS_KEY_ID" SecretAccessKeyEnv = "AWS_SECRET_ACCESS_KEY" //nolint:gosec // G101: an environment variable name, not a credential. )
Variables ¶
var DefaultResources = corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("400Mi"), corev1.ResourceEphemeralStorage: resource.MustParse("1Gi"), }, Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("1"), corev1.ResourceMemory: resource.MustParse("1Gi"), corev1.ResourceEphemeralStorage: resource.MustParse("2Gi"), }, }
DefaultResources is the exporter container's sizing when the operator is configured with none. ephemeral-storage is required by the require-emptydir-requests-and-limits Kyverno policy, because the container mounts the alloy-tmp emptyDir.
Functions ¶
func RenderValues ¶
func RenderValues(exports []observabilityv1alpha1.LogExport, cfg config.LogExportConfig) (string, error)
RenderValues renders the Helm values document for alloy-logexporter, covering every LogExport on the installation. The result is the `values` key of the ConfigMap the HelmRelease reads last, so it is also what switches the app on.
Order is not taken from the caller: exports are sorted so that the same set of resources always renders byte-identically.
func SecretEnv ¶
func SecretEnv(exports []observabilityv1alpha1.LogExport, creds map[client.ObjectKey]Credentials) (map[string]string, error)
SecretEnv returns the environment the exporter needs for static credentials, keyed by variable name, ready for common.GenerateSecretData.
The awss3 exporter has no credential fields: it uses the AWS SDK's default chain, which reads the process environment. Environment variables are per-container, not per exporter, so only one export can carry static credentials. Additional destinations have to authenticate by workload identity with roleARN, which is per exporter.
Types ¶
type Credentials ¶
Credentials are the resolved contents of a destination's credentialsRef Secret.