Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storage extension to save filelog receivers' offsets #1718

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkg/resources/collector/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
filelog/k8s:
include: [ /var/log/pods/*/*/*.log ]
exclude: []
start_at: beginning
storage: file_storage
include_file_path: true
include_file_name: false
operators:
Expand Down Expand Up @@ -87,7 +87,7 @@ filelog/k8s:
templateLogAgentRKE = `
filelog/rke:
include: [ /var/lib/rancher/rke/log/*.log ]
start_at: beginning
storage: file_storage
include_file_path: true
include_file_name: false
operators:
Expand All @@ -106,7 +106,7 @@ journald/k3s:
templateKubeAuditLogs = template.Must(template.New("kubeauditlogsreceiver").Parse(`
filelog/kubeauditlogs:
include: [ {{ . }} ]
start_at: beginning
storage: file_storage
include_file_path: false
include_file_name: false
operators:
Expand Down Expand Up @@ -157,7 +157,7 @@ journald/rke2:
directory: {{ . }}
filelog/rke2:
include: [ /var/lib/rancher/rke2/agent/logs/kubelet.log ]
start_at: beginning
storage: file_storage
include_file_path: true
include_file_name: false
operators:
Expand Down Expand Up @@ -230,7 +230,12 @@ processors:
- key: tier
- key: component
{{ template "metrics-system-processor" . }}
extensions:
file_storage:
directory: /var/otel/filestorage
timeout: 1s
service:
extensions: [file_storage]
telemetry:
logs:
level: {{ .LogLevel }}
Expand Down
24 changes: 20 additions & 4 deletions pkg/resources/collector/workloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ import (
)

const (
receiversKey = "receivers.yaml"
mainKey = "config.yaml"
aggregatorKey = "aggregator.yaml"
receiversKey = "receivers.yaml"
mainKey = "config.yaml"
aggregatorKey = "aggregator.yaml"

collectorImageRepo = "ghcr.io"
collectorImage = "rancher-sandbox/opni-otel-collector"
collectorVersion = "v0.1.2-0.74.0"
collectorVersion = "v0.1.4-rc1-0.85.0"
reloaderImage = "rancher-sandbox/config-reloader"
reloaderVersion = "v0.1.2"

otelColBinaryName = "otelcol-custom"
otelConfigDir = "/etc/otel"
otelFileStorageDir = "/var/otel/filestorage"

otlpGRPCPort = int32(4317)
rke2AgentLogDir = "/var/lib/rancher/rke2/agent/logs/"
Expand Down Expand Up @@ -213,6 +216,10 @@ func (r *Reconciler) daemonSet() resources.Resource {
Name: "collector-config",
MountPath: otelConfigDir,
},
{
Name: "filestorage-extension",
MountPath: otelFileStorageDir,
},
}
volumes := []corev1.Volume{
{
Expand All @@ -225,6 +232,15 @@ func (r *Reconciler) daemonSet() resources.Resource {
},
},
},
{
Name: "filestorage-extension",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: otelFileStorageDir,
Type: &directoryOrCreate,
alexandreLamarre marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
}

// Short circuit and remove the daemonset if we don't need it
Expand Down
3 changes: 1 addition & 2 deletions pkg/resources/preprocessor/workloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

const (
configKey = "config.yaml"
preprocessorVersion = "v0.1.3-rc2-0.74.0"
preprocessorVersion = "v0.1.4-rc1-0.85.0"
preprocessorImageRepo = "ghcr.io/rancher-sandbox"
preprocessorImage = "opni-otel-collector"
otlpGRPCPort = 4317
Expand Down Expand Up @@ -70,7 +70,6 @@ processors:
log_statements:
- context: log
statements:
- merge_maps(attributes, body, "upsert") where attributes["filename"] == nil
- set(attributes["COMM"], attributes["_COMM"])
- delete_matching_keys(attributes, "^_.*")
- context: resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (m *KubernetesManagerDriver) buildLoggingCollectorConfig() *opniloggingv1be
Spec: opniloggingv1beta1.CollectorConfigSpec{
Provider: opniloggingv1beta1.LogProvider(m.provider),
KubeAuditLogs: &opniloggingv1beta1.KubeAuditLogsSpec{
Enabled: true,
Enabled: false,
},
},
}
Expand Down