Skip to content

Commit 41b71f8

Browse files
replaced dataPath with checkpointsPath
1 parent aaa5572 commit 41b71f8

File tree

6 files changed

+34
-33
lines changed

6 files changed

+34
-33
lines changed

api/operator/v1/vlagent_types.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ type VLAgentK8sCollector struct {
9595
// By default VLAgent collects logs from /var/log/containers
9696
LogsPath string `json:"logsPath,omitempty"`
9797

98-
// DataPath configures path where logs checkpoints are stored.
99-
// By default it emptyDir is used as a volume for data path.
100-
// To guarantee checkpoints persistence during pods recreation consider explicitly setting this option to destination, where hostPath volume is mounted.
101-
DataPath string `json:"dataPath,omitempty"`
98+
// CheckpointsPath configures path to file where logs checkpoints are stored.
99+
// By default it's stored at host's /var/lib/vlagent_checkpoints/checkpoints.json.
100+
CheckpointsPath string `json:"checkpointsPath,omitempty"`
102101

103102
// TenantID defines default tenant ID to use for logs collected from pods in format: <accountID>:<projectID>
104103
TenantID string `json:"tenantID,omitempty"`

config/crd/overlay/crd.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,10 @@ spec:
740740
description: K8sCollector configures VLAgent logs collection from
741741
K8s pods
742742
properties:
743-
dataPath:
743+
checkpointsPath:
744744
description: |-
745-
DataPath configures path where logs checkpoints are stored.
746-
By default it emptyDir is used as a volume for data path.
747-
To guarantee checkpoints persistence during pods recreation consider explicitly setting this option to destination, where hostPath volume is mounted.
745+
CheckpointsPath configures path to file where logs checkpoints are stored.
746+
By default it's stored at host's /var/lib/vlagent_checkpoints/checkpoints.json.
748747
type: string
749748
decolorizeFields:
750749
description: DecolorizeFields defines fields to remove ANSI color

config/examples/vlagent-full-collector.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ spec:
1212
memory: "850Mi"
1313
k8sCollector:
1414
enabled: true
15-
dataPath: /var/lib/vl-collector
1615
extraFields: '{"env":"dev","cluster":"staging"}'
17-
volumes:
18-
- name: data
19-
hostPath:
20-
path: /var/lib/vl-collector
21-
volumeMounts:
22-
- name: data
23-
mountPath: /var/lib/vl-collector
16+
msgFields:
17+
- msg
18+
- message
19+
- log.msg
20+
timeFields:
21+
- time
22+
- ts
23+
- timestamp
2424
remoteWrite:
2525
- url: "http://vlsingle-example-0.default.svc:9428/internal/insert"

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Appears in: [VLAgentSpec](#vlagentspec)
180180

181181
| Field | Description |
182182
| --- | --- |
183-
| dataPath<a href="#vlagentk8scollector-datapath" id="vlagentk8scollector-datapath">#</a><br/>_string_ | _(Required)_<br/>DataPath configures path where logs checkpoints are stored.<br />By default it emptyDir is used as a volume for data path.<br />To guarantee checkpoints persistence during pods recreation consider explicitly setting this option to destination, where hostPath volume is mounted. |
183+
| checkpointsPath<a href="#vlagentk8scollector-checkpointspath" id="vlagentk8scollector-checkpointspath">#</a><br/>_string_ | _(Required)_<br/>CheckpointsPath configures path to file where logs checkpoints are stored.<br />By default it's stored at host's /var/lib/vlagent_checkpoints/checkpoints.json. |
184184
| decolorizeFields<a href="#vlagentk8scollector-decolorizefields" id="vlagentk8scollector-decolorizefields">#</a><br/>_string array_ | _(Required)_<br/>DecolorizeFields defines fields to remove ANSI color codes across logs ingested from Kubernetes |
185185
| enabled<a href="#vlagentk8scollector-enabled" id="vlagentk8scollector-enabled">#</a><br/>_boolean_ | _(Required)_<br/>Enabled switches VLAgent to log collection mode.<br />Note, for this purpose operator uses DaemonSet, while by default VLAgent uses StatefulSet.<br />Switching this option will drop all persisted data. |
186186
| extraFields<a href="#vlagentk8scollector-extrafields" id="vlagentk8scollector-extrafields">#</a><br/>_string_ | _(Required)_<br/>ExtraFields defines extra fields as JSON string which should be added to each collected log line<br />Example: '\{"env":"dev","cluster":"staging"\}' |

internal/controller/operator/factory/vlagent/vlagent.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const (
3131
persistentQueueSTSDir = "/vlagent_pq/vlagent-remotewrite-data"
3232
persistentQueueMountName = "persistent-queue-data"
3333

34-
defaultLogsPath = "/var/log/containers"
35-
defaultDataPath = "/vlagent"
36-
dataVolumeName = "data"
34+
defaultLogsPath = "/var/log/containers"
35+
defaultCheckpointsPath = "/var/lib/vlagent_checkpoints"
36+
checkpointsVolumeName = "checkpoints"
3737

3838
remoteWriteAssetsMounthPath = "/etc/vl/remote-write-assets"
3939
tlsServerConfigMountPath = "/etc/vl/tls-server-secrets"
@@ -321,22 +321,24 @@ func newPodSpec(cr *vmv1.VLAgent) (*corev1.PodSpec, error) {
321321
} else {
322322
args = append(args, fmt.Sprintf("-kubernetesCollector.logsPath=%s", cr.Spec.K8sCollector.LogsPath))
323323
}
324-
dataPath := defaultDataPath
325-
if len(cr.Spec.K8sCollector.DataPath) == 0 || cr.Spec.K8sCollector.DataPath == defaultDataPath {
324+
checkpointsPath := defaultCheckpointsPath
325+
if len(cr.Spec.K8sCollector.CheckpointsPath) == 0 || cr.Spec.K8sCollector.CheckpointsPath == defaultCheckpointsPath {
326326
volumes = append(volumes, corev1.Volume{
327-
Name: dataVolumeName,
327+
Name: checkpointsVolumeName,
328328
VolumeSource: corev1.VolumeSource{
329-
EmptyDir: &corev1.EmptyDirVolumeSource{},
329+
HostPath: &corev1.HostPathVolumeSource{
330+
Path: checkpointsPath,
331+
},
330332
},
331333
})
332334
agentVolumeMounts = append(agentVolumeMounts, corev1.VolumeMount{
333-
Name: dataVolumeName,
334-
MountPath: dataPath,
335+
Name: checkpointsVolumeName,
336+
MountPath: checkpointsPath,
335337
})
338+
checkpointsPath = path.Join(checkpointsPath, "checkpoints.json")
336339
} else {
337-
dataPath = cr.Spec.K8sCollector.DataPath
340+
checkpointsPath = cr.Spec.K8sCollector.CheckpointsPath
338341
}
339-
checkpointsPath := path.Join(dataPath, "checkpoints.json")
340342
args = append(args, fmt.Sprintf("-kubernetesCollector.checkpointsPath=%s", checkpointsPath))
341343

342344
if cr.Spec.RemoteWriteSettings == nil || cr.Spec.RemoteWriteSettings.TmpDataPath == nil {

internal/controller/operator/factory/vlagent/vlagent_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ containers:
10811081
args:
10821082
- -httpListenAddr=:9425
10831083
- -kubernetesCollector
1084-
- -kubernetesCollector.checkpointsPath=/vlagent/checkpoints.json
1084+
- -kubernetesCollector.checkpointsPath=/var/lib/vlagent_checkpoints/checkpoints.json
10851085
- -kubernetesCollector.msgField="msg,message"
10861086
- -remoteWrite.maxDiskUsagePerURL=10GB,10GB,
10871087
- -remoteWrite.tmpDataPath=/vlagent_pq/vlagent-remotewrite-data
@@ -1101,8 +1101,8 @@ containers:
11011101
- name: varlib
11021102
readonly: true
11031103
mountpath: /var/lib
1104-
- name: data
1105-
mountpath: /vlagent
1104+
- name: checkpoints
1105+
mountpath: /var/lib/vlagent_checkpoints
11061106
- name: persistent-queue-data
11071107
readonly: false
11081108
mountpath: /vlagent_pq/vlagent-remotewrite-data
@@ -1141,9 +1141,10 @@ volumes:
11411141
volumesource:
11421142
hostpath:
11431143
path: /var/lib
1144-
- name: data
1144+
- name: checkpoints
11451145
volumesource:
1146-
emptydir: {}
1146+
hostpath:
1147+
path: /var/lib/vlagent_checkpoints
11471148
- name: persistent-queue-data
11481149
volumesource:
11491150
emptydir: {}

0 commit comments

Comments
 (0)