You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/victorialogs/vlagent.md
+37-25Lines changed: 37 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,70 +62,82 @@ in a timely manner when some of the VictoriaLogs instances are unavailable.
62
62
63
63
### Collect Kubernetes Pod logs
64
64
65
-
To collect Kubernetes Pod logs with `vlagent` use [`victoria-logs-collector`](https://docs.victoriametrics.com/helm/victoria-logs-collector/#quick-start) Helm chart.
66
-
This Helm chart deploys `vlagent` as a DaemonSet, which collects logs from Pods on all nodes and sends them to VictoriaLogs instances.
67
-
In case of network issues, `vlagent` automatically buffers the collected logs and sends them to VictoriaLogs instances as soon as they become available,
68
-
as described in [Replication and high availability](https://docs.victoriametrics.com/victorialogs/vlagent/#replication-and-high-availability).
65
+
The [`victoria-logs-collector`](https://docs.victoriametrics.com/helm/victoria-logs-collector/#quick-start) Helm chart deploys `vlagent`
66
+
across all the Kubernetes nodes and enables automatic discovering and collecting all the logs generated by containers across all the pods.
67
+
It sends the collected logs to the configured VictoriaLogs instances (either [single-node](https://docs.victoriametrics.com/helm/victoria-logs-single/)
68
+
or [cluster](https://docs.victoriametrics.com/helm/victoria-logs-cluster/) instances).
69
69
70
-
To quickly deploy `vlagent` and VictoriaLogs with Helm, see [VictoriaLogs Quick Start](https://docs.victoriametrics.com/helm/victoria-logs-single/#quick-start).
70
+
If the configured VictoriaLogs are temporarily unavailable (for example, because of upgrades, configuration changes or other maintenance events),
71
+
then `vlagent` buffers the collected logs at the configured persistent volume and sends them to VictoriaLogs instances as soon as they become available,
72
+
as described in [Replication and high availability](https://docs.victoriametrics.com/victorialogs/vlagent/#replication-and-high-availability).
71
73
72
74
## Kubernetes Collector Configuration
73
75
74
-
This section describes the existing configuration options for `vlagent`.
75
-
In most cases, you don't need to configure `vlagent` manually, use
In most cases, you don't need to configure `vlagent` manually.
77
+
Use [`victoria-logs-collector`](https://docs.victoriametrics.com/helm/victoria-logs-collector/#quick-start) Helm chart instead.
78
+
79
+
`vlagent` must run on Kubernetes nodes in [DaemonSet mode](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/).
80
+
Pass `-kubernetesCollector` command-line flag to `vlagent` in order to start discovering and collecting logs from all the containers
81
+
running inside all the pods on the given Kubernetes node. Pass VictoriaLogs address to store the collected logs
82
+
via `-remoteWrite.url` command-line flag.
83
+
84
+
Here is the minimal configuration for `vlagent` to collect logs on the current Kubernetes node and send them to `http://victoria-logs:9428/internal/insert`:
77
85
78
-
To enable `vlagent` to collect Kubernetes Pod logs, pass `-kubernetesCollector` command-line flag to `vlagent` and specify the list
79
-
of `-remoteWrite.url` values to send the collected logs to.
80
-
Minimal configuration for `vlagent` to collect Kubernetes Pod logs:
`vlagent` needs to be able to access the Kubernetes API server to watch and get pods (the `watch` and `get` verbs on the `pods` resource).
86
-
`vlagent` also needs to be able to access the `/var/log/containers` and `/var/log/pods` directories on the Kubernetes nodes.
90
+
`vlagent` can send the copies of the collected logs into multiple destinations.
91
+
See [replication and high availability docs](https://docs.victoriametrics.com/victorialogs/vlagent/#replication-and-high-availability) for details.
92
+
93
+
`vlagent` requires access to Kubernetes API server to watch and get pods (the `watch` and `get` verbs on the `pods` resource).
94
+
`vlagent` also requires access to the `/var/log/containers` and `/var/log/pods` directories on the Kubernetes node.
87
95
For Kubernetes in Docker (in case you run `vlagent` using tools like minikube or kind), you may need to mount `/var/lib` directory.
88
96
89
97
`vlagent` uses checkpoints to persist its state across restarts.
90
98
Default location for checkpoints is `./vlagent-kubernetes-checkpoints.json`.
91
99
You can specify a different location for checkpoints with `-kubernetesCollector.checkpointsPath` command-line flag.
92
100
Make sure that this file is available for `vlagent` across restarts.
93
-
Use [`hostPath`](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) volume
101
+
Use [`hostPath`](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) volume
94
102
so the checkpoint file stays on the node disk and is reused across Pod restarts.
95
103
96
-
`vlagent` automatically parses JSON logs from Kubernetes Pod logs and treats the following fields
97
-
as [`_msg`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#message-field)fields:
104
+
`vlagent` automatically parses JSON logs from Kubernetes Pod logs and treats the following fields
105
+
as [`_msg`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#message-field)field:
98
106
-`message`
99
107
-`msg`
100
108
-`log`
101
109
102
-
You can change the default list of `_msg` fields by passing `-kubernetesCollector.msgFields` command-line flag with a list of field names.
110
+
You can change the default list of `_msg` fields by passing `-kubernetesCollector.msgFields` command-line flag with comma-separated list of field names.
103
111
104
-
`vlagent` extracts timestamp in RFC3339 format from the log line and uses it as
`vlagent` extracts timestamp from the log line and uses it as
113
+
[`_time`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#time-field) field, using the following fields:
107
114
-`time`
108
115
-`timestamp`
109
116
-`ts`
110
117
111
-
You can change the default list of `_time` fields by passing `-kubernetesCollector.timeField` command-line flag with a list of field names.
118
+
You can change the default list of `_time` fields by passing `-kubernetesCollector.timeField` command-line flag with comma-separated list of field names.
112
119
If none of the specified fields are present in the log line, then `vlagent` uses timestamp when the log line was written by Container Runtime.
113
120
Usually, this timestamp is close to the actual time when the log line was written, but it may differ slightly, normally less than a millisecond.
114
121
115
122
To ignore fields from Kubernetes Pod logs, pass `-kubernetesCollector.ignoreFields` command-line flag with a list of field names to ignore.
116
-
You can also configure `vlagent` to add additional fields to all collected logs,
123
+
You can also configure `vlagent` to add additional fields to all the collected logs,
117
124
using `-kubernetesCollector.extraFields` command-line flag, which accepts a JSON object with additional fields.
125
+
For example, the following command instructs `vlagent` to add `env=dev` and `cluster=staging`[log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model)
126
+
for all the collected logs before sending them to `-remoteWrite.url`:
To set the default [tenant](http://localhost:1313/victorialogs/#multitenancy) ID for logs collected from Kubernetes Pods,
120
-
pass `-kubernetesCollector.tenantID` command-line flag with a tenant ID in format `accountID:projectID`.
133
+
pass `-kubernetesCollector.tenantID` command-line flag with a tenant ID in the format `accountID:projectID`.
121
134
122
135
`vlagent` uses the following fields as [`_stream`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#stream-fields) fields for Kubernetes Pod logs:
123
136
-`kubernetes.container_name`
124
137
-`kubernetes.pod_name`
125
138
-`kubernetes.pod_namespace`
126
139
127
-
Use these fields for fast filtering and grouping of logs in VictoriaLogs.
128
-
See [stream filter](https://docs.victoriametrics.com/victorialogs/logsql/#stream-filter) for more details.
140
+
Use these fields for fast filtering and grouping of logs in VictoriaLogs via [stream filters](https://docs.victoriametrics.com/victorialogs/logsql/#stream-filter).
0 commit comments