2023-10-14 11:45:57 +00:00
---
weight: 4
title: Promtail setup
disableToc: true
menu:
docs:
parent: "victorialogs-data-ingestion"
weight: 4
aliases:
- /VictoriaLogs/data-ingestion/Promtail.html
2024-06-14 10:32:12 +00:00
- /victorialogs/data-ingestion/Promtail.html
- /victorialogs/data-ingestion/promtail.html
2023-10-14 11:45:57 +00:00
---
2024-11-02 10:36:22 +00:00
[Promtail ](https://grafana.com/docs/loki/latest/clients/promtail/ ), [Grafana Agent ](https://grafana.com/docs/agent/latest/ )
and [Grafana Alloy ](https://grafana.com/docs/alloy/latest/ ) are default log collectors for Grafana Loki.
They can be configured to send the collected logs to VictoriaLogs according to the following docs.
2023-07-20 23:21:47 +00:00
2023-07-20 08:10:55 +00:00
Specify [`clients` ](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#clients ) section in the configuration file
2024-05-24 22:30:58 +00:00
for sending the collected logs to [VictoriaLogs ](https://docs.victoriametrics.com/victorialogs/ ):
2023-07-20 08:10:55 +00:00
```yaml
clients:
2024-12-04 12:57:20 +00:00
- url: "http://localhost:9428/insert/loki/api/v1/push"
2023-07-20 08:10:55 +00:00
```
2023-07-20 23:21:47 +00:00
Substitute `localhost:9428` address inside `clients` with the real TCP address of VictoriaLogs.
2023-07-20 08:10:55 +00:00
2024-12-04 12:57:20 +00:00
VictoriaLogs uses [log streams ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#stream-fields ) defined at the client side,
e.g. at Promtail, Grafana Agent or Grafana Allow. Sometimes it may be needed overriding the set of these fields. This can be done via `_stream_fields`
query arg. For example, the following config instructs using only the `instance` and `job` labels as log stream fields, while other labels
will be stored as [usual log fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model ):
```yaml
clients:
- url: "http://localhost:9428/insert/loki/api/v1/push?_stream_fields=instance,job"
```
2023-07-28 16:46:50 +00:00
2024-05-24 22:30:58 +00:00
See also [these docs ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters ) for details on other supported query args.
2023-07-20 23:21:47 +00:00
There is no need in specifying `_msg_field` and `_time_field` query args, since VictoriaLogs automatically extracts log message and timestamp from the ingested Loki data.
2023-07-20 08:10:55 +00:00
2024-05-24 22:30:58 +00:00
It is recommended verifying whether the initial setup generates the needed [log fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model )
and uses the correct [stream fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#stream-fields ).
This can be done by specifying `debug` [parameter ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters )
2023-07-20 08:10:55 +00:00
and inspecting VictoriaLogs logs then:
```yaml
clients:
2024-12-04 12:57:20 +00:00
- url: "http://localhost:9428/insert/loki/api/v1/push?debug=1"
2023-07-20 08:10:55 +00:00
```
2024-05-24 22:30:58 +00:00
If some [log fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model ) must be skipped
during data ingestion, then they can be put into `ignore_fields` [parameter ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters ).
2023-07-20 23:21:47 +00:00
For example, the following config instructs VictoriaLogs to ignore `filename` and `stream` fields in the ingested logs:
2023-07-20 08:10:55 +00:00
```yaml
clients:
2024-12-04 12:57:20 +00:00
- url: 'http://localhost:9428/insert/loki/api/v1/push?ignore_fields=filename,stream'
2023-07-20 08:10:55 +00:00
```
2024-05-24 22:30:58 +00:00
By default the ingested logs are stored in the `(AccountID=0, ProjectID=0)` [tenant ](https://docs.victoriametrics.com/victorialogs/#multitenancy ).
2023-07-20 23:21:47 +00:00
If you need storing logs in other tenant, then specify the needed tenant via `tenant_id` field
in the [Loki client configuration ](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#clients )
The `tenant_id` must have `AccountID:ProjectID` format, where `AccountID` and `ProjectID` are arbitrary uint32 numbers.
2024-05-24 22:30:58 +00:00
For example, the following config instructs VictoriaLogs to store logs in the `(AccountID=12, ProjectID=34)` [tenant ](https://docs.victoriametrics.com/victorialogs/#multitenancy ):
2023-07-20 08:10:55 +00:00
```yaml
clients:
2024-12-04 12:57:20 +00:00
- url: "http://localhost:9428/insert/loki/api/v1/push"
2023-07-20 23:21:47 +00:00
tenant_id: "12:34"
2023-07-20 08:10:55 +00:00
```
2024-05-24 22:30:58 +00:00
The ingested log entries can be queried according to [these docs ](https://docs.victoriametrics.com/victorialogs/querying/ ).
2023-07-20 08:10:55 +00:00
2024-05-24 22:30:58 +00:00
See also [data ingestion troubleshooting ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#troubleshooting ) docs.