说明
自己记录的安装过程, 作为资料供自己使用.
参考
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.zip
wget https://github.com/grafana/loki/releases/download/v2.1.0/promtail-linux-amd64.zip
wget https://raw.githubusercontent.com/grafana/loki/v2.1.0/cmd/loki/loki-local-config.yaml
wget 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.rpm
sudo yum install grafana-7.4.3-1.x86_64.rpm
service grafana-server start
设置开机启动
grafana 开机启动
systemctl enable grafana-server
loki 开机启动
cd /etc/systemd/system
touch loki.service
vim /etc/systemd/system/loki.service
将以下内容复制进 loki.service
[Unit]
Description=Loki service
After=network.target
[Service]
Type=simple
ExecStart=/root/loki/loki-linux-amd64 -config.file /root/loki/loki-local-config.yaml
[Install]
WantedBy=multi-user.target
service loki start
service loki status
systemctl enable loki.service
promtail 类同 loki, 注意 execstart 的内容根据自己实际目录进行配置
参考一下配置
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://localhost:3100/loki/api/v1/push
scrape_configs:
- job_name: test
static_configs:
- targets:
- test
labels:
job: test
host: localhost
__path__: /home/logs/*/*/*log