我已经按照以下链接在我的 Kubernetes 集群中使用 Helm Chart 安装了 promtail/loki
https://grafana.com/docs/loki/latest/installation/helm/
但默认情况下,它仅收集容器日志。我想以一种能够从容器收集应用程序日志文件的方式配置我的 promtail。
示例: 我有 ngnix pod,它有 2 组日志文件,例如 access.log 和 error.log,我想将这两个文件流式传输到 loki。
您可以设置一个运行
sidecar
的 promtail
,从 nginx
容器收集文件日志。
从
volumeMounts
容器中设置 nginx
:/var/log
(文件所在的位置)。
然后在
promtail
容器中使用该卷,最后将其流式传输到 loki。
promtail.config:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /var/log/positions.yaml
clients:
- url: http://ip_or_hostname_where_Loki_run:3100/loki/api/v1/push
scrape_configs:
- job_name: system
pipeline_stages:
static_configs:
- labels:
job: nginxlogs
host: yourhost
__path__: /var/log/*.log