iac/infrastructure/vector/base/vector.yaml

113 lines
4.6 KiB
YAML

data_dir: /var/lib/vector
api:
enabled: true
address: 0.0.0.0:8686
playground: false
sources:
otlp:
type: opentelemetry
grpc: {address: "0.0.0.0:4317"}
http: {address: "0.0.0.0:4318"}
# Default native decoding exposes .message, .resources, .attributes.
internal_metrics:
type: internal_metrics
transforms:
normalize_logs:
type: remap
inputs: [otlp.logs]
# A transformation failure is exported unchanged rather than silently dropped;
# all conversions below have fallbacks to keep the fixed schema valid.
source: |
resources = object(.resources) ?? {}
attributes = object(.attributes) ?? {}
app = object(attributes.app) ?? {}
text = string(.message) ?? encode_json(.message)
parsed = parse_json(text) ?? {}
if is_object(parsed) && is_empty(app) {
app = object!(parsed)
}
ts = to_timestamp(.timestamp) ?? now()
observed = to_timestamp(.observed_timestamp) ?? ts
service_name = string(resources."service.name") ?? string(resources.app) ?? string(resources."k8s.container.name") ?? "unknown"
if service_name == "" {
service_name = string(resources.app) ?? string(resources."k8s.container.name") ?? "unknown"
}
severity = upcase(string(.severity_text) ?? string(app.level) ?? string(app.levelname) ?? "UNSPECIFIED")
if severity == "" {
severity = upcase(string(app.level) ?? string(app.levelname) ?? "UNSPECIFIED")
}
trace_id = string(.trace_id) ?? ""
span_id = string(.span_id) ?? ""
if trace_id == "" || trace_id == "00000000000000000000000000000000" {
trace_id = string(app.trace_id) ?? ""
}
if span_id == "" || span_id == "0000000000000000" {
span_id = string(app.span_id) ?? ""
}
# Redact common credentials in both the original message and nested attributes.
text = replace(text, r'(?i)Bearer\s+[A-Za-z0-9._~+/-]+=*', "Bearer ***")
text = replace(text, r'(?i)"?(password|passwd|pwd|token|secret|client_secret|api[_-]?key|authorization|cookie|signature|x-amz-signature)"?\s*[:=]\s*("(\\.|[^"\\])*"|[^,;\s}]+)', "[REDACTED]")
text = replace(text, r'[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}', "***jwt***")
safe_attributes = encode_json({"resource": resources, "log": attributes})
safe_attributes = replace(safe_attributes, r'(?i)"(password|passwd|pwd|token|secret|client_secret|api[_-]?key|authorization|cookie|signature|x-amz-signature)"\s*:\s*"(\\.|[^"\\])*"', "\"redacted\":\"***\"")
safe_attributes = replace(safe_attributes, r'(?i)Bearer\s+[A-Za-z0-9._~+/-]+=*', "Bearer ***")
safe_attributes = replace(safe_attributes, r'[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}', "***jwt***")
. = {
"event_time": format_timestamp!(ts, format: "%+"),
"observed_time": format_timestamp!(observed, format: "%+"),
"contour": "${CONTOUR}",
"namespace": string(resources."k8s.namespace.name") ?? "unknown",
"service_name": service_name,
"pod": string(resources."k8s.pod.name") ?? "",
"pod_uid": string(resources."k8s.pod.uid") ?? "",
"container": string(resources."k8s.container.name") ?? "",
"node": string(resources."k8s.node.name") ?? "",
"severity": severity,
"severity_number": to_int(.severity_number) ?? 0,
"trace_id": trace_id,
"span_id": span_id,
"message": text,
"attributes_json": safe_attributes,
"partition_date": format_timestamp!(ts, format: "%F", timezone: "UTC"),
"partition_hour": format_timestamp!(ts, format: "%H", timezone: "UTC")
}
sinks:
minio_logs:
type: aws_s3
inputs: [normalize_logs]
bucket: "${S3_BUCKET}"
endpoint: "${S3_ENDPOINT}"
region: us-east-1
force_path_style: true
auth:
credentials_file: /vault/secrets/aws-credentials
key_prefix: "logs/contour={{ contour }}/date={{ partition_date }}/hour={{ partition_hour }}/"
filename_append_uuid: true
compression: none
encoding: {codec: text}
batch_encoding:
codec: parquet
schema_file: /etc/vector/logs.schema
schema_mode: strict
compression: {algorithm: zstd, level: 3}
batch:
max_bytes: 67108864
timeout_secs: 300
buffer:
type: disk
max_size: 10737418240
when_full: block
# Retain the upstream agent queue until the S3 request succeeds.
acknowledgements: {enabled: true}
tags:
contour: "${CONTOUR}"
signal: logs
retention: 14d
metrics:
type: prometheus_exporter
inputs: [internal_metrics]
address: 0.0.0.0:9598