Skip to content

Commit dee6654

Browse files
committed
docs/victorialogs/vlagent.md: clarify docs about collecting Kubernetes logs via vlagent
This is a follow-up for the commit 2aa0ea1 Updates #815 Updates #538
1 parent dec40fd commit dee6654

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

docs/victorialogs/vlagent.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,70 +62,82 @@ in a timely manner when some of the VictoriaLogs instances are unavailable.
6262

6363
### Collect Kubernetes Pod logs
6464

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).
6969

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).
7173

7274
## Kubernetes Collector Configuration
7375

74-
This section describes the existing configuration options for `vlagent`.
75-
In most cases, you don't need to configure `vlagent` manually, use
76-
[`victoria-logs-collector`](https://docs.victoriametrics.com/helm/victoria-logs-collector/#quick-start) Helm chart instead.
76+
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`:
7785

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:
8186
```sh
8287
./vlagent -kubernetesCollector -remoteWrite.url=http://victoria-logs:9428/internal/insert
8388
```
8489

85-
`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.
8795
For Kubernetes in Docker (in case you run `vlagent` using tools like minikube or kind), you may need to mount `/var/lib` directory.
8896

8997
`vlagent` uses checkpoints to persist its state across restarts.
9098
Default location for checkpoints is `./vlagent-kubernetes-checkpoints.json`.
9199
You can specify a different location for checkpoints with `-kubernetesCollector.checkpointsPath` command-line flag.
92100
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
94102
so the checkpoint file stays on the node disk and is reused across Pod restarts.
95103

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:
98106
- `message`
99107
- `msg`
100108
- `log`
101109

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.
103111

104-
`vlagent` extracts timestamp in RFC3339 format from the log line and uses it as
105-
[`_time`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#time-field) field,
106-
using the following fields:
112+
`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:
107114
- `time`
108115
- `timestamp`
109116
- `ts`
110117

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.
112119
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.
113120
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.
114121

115122
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,
117124
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`:
127+
128+
```sh
129+
./vlagent -kubernetesCollector.extraFields='{"env":"dev","cluster":"staging"}' ...
130+
```
118131

119132
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`.
121134

122135
`vlagent` uses the following fields as [`_stream`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#stream-fields) fields for Kubernetes Pod logs:
123136
- `kubernetes.container_name`
124137
- `kubernetes.pod_name`
125138
- `kubernetes.pod_namespace`
126139

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).
129141

130142
## Monitoring
131143

0 commit comments

Comments
 (0)