yum -y install yum-utils
yum clean all
yum makecache
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl enable docker --now
docker pull grafana/promtail:2.4.1
mkdir -p /opt/grafana/promtail
vi /opt/grafana/promtail/config.yml
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://192.168.0.777:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: dev-log # job 名称
__path__: /etc/logs/*.log
docker run -ti -d --name promtail \
-v /etc/logs/:/etc/logs/ \
-v /etc/promtail/config.yml:/etc/promtail/config.yml \
grafana/promtail:2.4.1 -config.file=/etc/promtail/config.yml