Promtail
Start an HTTP endpoint to listen and receive Promtail log data and report it to Guance Cloud.
Configuration¶
Already tested version:
- 2.8.2
- 2.0.0
- 1.5.0
- 1.0.0
- 0.1.0
Collector Configuration¶
Go to the conf.d/log
directory under the DataKit installation directory, copy promtail.conf.sample
and name it promtail.conf
. Examples are as follows:
```toml
[inputs.promtail]
## When processing requests with the legacy version interface,
## setting it to true corresponds to the Loki API endpoint /api/prom/push.
#
legacy = false
[inputs.promtail.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
```
After configuration, [Restart DataKit](../datakit/datakit-service-how-to.md#manage-service).
API Version¶
For Promtail versions v0.3.0
and before, Datakit's configuration should set legacy = true
, by using legacy API POST /api/prom/push
to receiving logging data from Promtail.
Using the default Datakit's configuration, namely legacy = false
for the rest of Promtail versions, by using new API POST /loki/api/v1/push
.
Custom Tags¶
You can add custom tags to log data by configuring [inputs.promtail.tags]
, as shown below:
After configuration, restart DataKit.
Supported parameter¶
The Promtail collector supports adding parameters to the HTTP URL. The list of parameters is as follows:
source
: Identifies the data source. Such asnginx
orredis
(/v1/write/promtail?source=nginx
), Withsource
set todefault
by default;pipeline
: Specify the pipeline name required for the data, Such asnginx.p
(/v1/write/promtail?pipeline=nginx.p
);tags
: Add custom tags, separated by English commas,
, such askey1=value1
andkey2=value2
(/v1/write/promtail?tags=key1=value1,key2=value2
)。
Best Practice¶
Promtail's data was originally sent to Loki, which is, /loki/api/v1/push
. Change the url
in Promtail's configuration to Datakit, after enabled Datakit's Promtail collector, Promtail would send its data to Datakit's Promtail collector.
Promtail's configuration is like below:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://localhost:9529/v1/write/promtail # Send to the endpoint that the promtail collector listens on
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log
Logging¶
The logs delivered by Promtail shall prevail.