2023-10-14 13:45:57 +02:00
---
weight: 4
title: Promtail setup
disableToc: true
menu:
docs:
parent: "victorialogs-data-ingestion"
weight: 4
aliases:
- /VictoriaLogs/data-ingestion/Promtail.html
---
2023-07-20 10:10:55 +02:00
# Promtail setup
2023-07-21 01:21:47 +02:00
[Promtail ](https://grafana.com/docs/loki/latest/clients/promtail/ ) is a default log shipper for Grafana Loki.
Promtail can be configured to send the collected logs to VictoriaLogs according to the following docs.
2023-07-20 10:10:55 +02:00
Specify [`clients` ](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#clients ) section in the configuration file
2023-10-14 14:41:04 +02:00
for sending the collected logs to [VictoriaLogs ](/VictoriaLogs/ ):
2023-07-20 10:10:55 +02:00
```yaml
clients:
2023-07-28 18:46:50 +02:00
- url: http://localhost:9428/insert/loki/api/v1/push?_stream_fields=instance,job,host,app
2023-07-20 10:10:55 +02:00
```
2023-07-21 01:21:47 +02:00
Substitute `localhost:9428` address inside `clients` with the real TCP address of VictoriaLogs.
2023-07-20 10:10:55 +02:00
2023-10-14 14:41:04 +02:00
By default VictoriaLogs stores all the ingested logs into a single [log stream ](/VictoriaLogs/keyConcepts.html#stream-fields ).
2023-07-28 18:46:50 +02:00
Storing all the logs in a single log stream may be not so efficient, so it is recommended to specify `_stream_fields` query arg
with the list of labels, which uniquely identify log streams. There is no need in specifying all the labels Promtail generates there -
2023-10-14 14:41:04 +02:00
it is usually enough specifying `instance` and `job` labels. See [these docs ](/VictoriaLogs/keyConcepts.html#stream-fields )
2023-07-28 18:46:50 +02:00
for details.
2023-10-14 14:41:04 +02:00
See also [these docs ](/VictoriaLogs/data-ingestion/#http-parameters ) for details on other supported query args.
2023-07-21 01:21:47 +02: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 10:10:55 +02:00
2023-10-14 14:41:04 +02:00
It is recommended verifying whether the initial setup generates the needed [log fields ](/VictoriaLogs/keyConcepts.html#data-model )
and uses the correct [stream fields ](/VictoriaLogs/keyConcepts.html#stream-fields ).
This can be done by specifying `debug` [parameter ](/VictoriaLogs/data-ingestion/#http-parameters )
2023-07-20 10:10:55 +02:00
and inspecting VictoriaLogs logs then:
```yaml
clients:
2023-07-28 18:46:50 +02:00
- url: http://localhost:9428/insert/loki/api/v1/push?_stream_fields=instance,job,host,app& debug=1
2023-07-20 10:10:55 +02:00
```
2023-10-14 14:41:04 +02:00
If some [log fields ](/VictoriaLogs/keyConcepts.html#data-model ) must be skipped
during data ingestion, then they can be put into `ignore_fields` [parameter ](/VictoriaLogs/data-ingestion/#http-parameters ).
2023-07-21 01:21:47 +02:00
For example, the following config instructs VictoriaLogs to ignore `filename` and `stream` fields in the ingested logs:
2023-07-20 10:10:55 +02:00
```yaml
clients:
2023-07-28 18:46:50 +02:00
- url: http://localhost:9428/insert/loki/api/v1/push?_stream_fields=instance,job,host,app& ignore_fields=filename,stream
2023-07-20 10:10:55 +02:00
```
2023-10-14 14:41:04 +02:00
By default the ingested logs are stored in the `(AccountID=0, ProjectID=0)` [tenant ](/VictoriaLogs/#multitenancy ).
2023-07-21 01:21:47 +02: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.
2023-10-14 14:41:04 +02:00
For example, the following config instructs VictoriaLogs to store logs in the `(AccountID=12, ProjectID=34)` [tenant ](/VictoriaLogs/#multitenancy ):
2023-07-20 10:10:55 +02:00
```yaml
clients:
2023-07-28 18:46:50 +02:00
- url: http://localhost:9428/insert/loki/api/v1/push?_stream_fields=instance,job,host,app& debug=1
2023-07-21 01:21:47 +02:00
tenant_id: "12:34"
2023-07-20 10:10:55 +02:00
```
2023-10-14 14:41:04 +02:00
The ingested log entries can be queried according to [these docs ](/VictoriaLogs/querying/ ).
2023-07-20 10:10:55 +02:00
2023-10-14 14:41:04 +02:00
See also [data ingestion troubleshooting ](/VictoriaLogs/data-ingestion/#troubleshooting ) docs.