说明
自己记录的安装过程, 作为资料供自己使用.
参考
https://gitee.com/frankchenlong/plumelog
https://www.cnblogs.com/mrhugui/p/11544145.html
http://www.soolco.com/post/94167_1_1.html
https://sbcode.net/grafana/install-loki-service/
https://sbcode.net/grafana/install-promtail-service/
安装 loki
wget https://github.com/grafana/loki/releases/download/v2.1.0/loki-linux-amd64.zipwget https://github.com/grafana/loki/releases/download/v2.1.0/promtail-linux-amd64.zipwget https://raw.githubusercontent.com/grafana/loki/v2.1.0/cmd/loki/loki-local-config.yamlwget https://raw.githubusercontent.com/grafana/loki/v2.1.0/cmd/promtail/promtail-local-config.yaml./loki-linux-amd64 -config.file=loki-local-config.yaml# 开放3100端口firewall-cmd --zone=public --add-port=3100/tcp --permanent# 配置立即生效firewall-cmd --reload
安装 grafana
wget https://dl.grafana.com/oss/release/grafana-7.4.3-1.x86_64.rpmsudo yum install grafana-7.4.3-1.x86_64.rpmservice grafana-server start
设置开机启动
grafana 开机启动
systemctl enable grafana-server
loki 开机启动
cd /etc/systemd/systemtouch loki.servicevim /etc/systemd/system/loki.service
将以下内容复制进 loki.service
[Unit]Description=Loki serviceAfter=network.target[Service]Type=simpleExecStart=/root/loki/loki-linux-amd64 -config.file /root/loki/loki-local-config.yaml[Install]WantedBy=multi-user.target
service loki startservice loki statussystemctl enable loki.service
promtail 类同 loki, 注意 execstart 的内容根据自己实际目录进行配置
参考一下配置
server:http_listen_port: 9080grpc_listen_port: 0positions:filename: /tmp/positions.yamlclients:- url: http://localhost:3100/loki/api/v1/pushscrape_configs:- job_name: teststatic_configs:- targets:- testlabels:job: testhost: localhost__path__: /home/logs/*/*/*log
