Loki 安装教程

1,034 阅读1分钟

说明

自己记录的安装过程,作为资料供自己使用.

参考

gitee.com/frankchenlo…
www.cnblogs.com/mrhugui/p/1…
www.soolco.com/post/94167_…
sbcode.net/grafana/ins…
sbcode.net/grafana/ins…

安装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