Skip to content

Commit

Permalink
Merge pull request #1718 from rancher/store-filelogreceivers-offsets
Browse files Browse the repository at this point in the history
Add storage extension to save filelog receivers' offsets
  • Loading branch information
jaehnri authored Oct 11, 2023
2 parents 189a8eb + ee8a619 commit e305dab
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
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,
},
},
},
}

// 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

0 comments on commit e305dab

Please sign in to comment.