Promtail:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第42行: | 第42行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo curl -L -o /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key; echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list; sudo apt update; sudo apt install -y promtail; sudo apt clean; sudo mkdir /var/lib/promtail; sudo chown promtail:nogroup /var/lib/promtail; sudo sed -i -e 's@filename: /tmp/positions.yaml@filename: /var/lib/promtail/positions.yaml@' -e 's@localhost@loki.example.com@' /etc/promtail/config.yml; sudo service promtail restart | sudo curl -L -o /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key; echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list; sudo apt update; sudo apt install -y promtail; sudo apt clean; sudo mkdir /var/lib/promtail; sudo chown promtail:nogroup /var/lib/promtail; sudo sed -i -e 's@filename: /tmp/positions.yaml@filename: /var/lib/promtail/positions.yaml@' -e 's@http://localhost@http://loki.example.com@' /etc/promtail/config.yml; sudo service promtail restart | ||
</syntaxhighlight> | </syntaxhighlight> | ||
2023年6月28日 (三) 07:24的版本
Promtail是Log传输软件,属于Grafana的Loki生态系。
安装
在Ubuntu上可以透过官方的APT repository安装:
sudo curl -L -o /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key; echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list; sudo apt update; sudo apt install -y promtail; sudo apt clean
设定
先建立状态目录:
sudo mkdir /var/lib/promtail; sudo chown promtail:nogroup /var/lib/promtail
在/etc/promtail/config.yml
里面把状态档案放到/var/lib/promtail
下:
positions:
filename: /var/lib/promtail/positions.yaml
另外把Loki预设的位置改成实际的位置:
clients:
- url: http://loki.example.com:3100/loki/api/v1/push
然后重新启动:
sudo service promtail restart
Cheatsheet
这边需要把loki.example.com
改成自己的Loki服务位置:
sudo curl -L -o /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key; echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list; sudo apt update; sudo apt install -y promtail; sudo apt clean; sudo mkdir /var/lib/promtail; sudo chown promtail:nogroup /var/lib/promtail; sudo sed -i -e 's@filename: /tmp/positions.yaml@filename: /var/lib/promtail/positions.yaml@' -e 's@http://localhost@http://loki.example.com@' /etc/promtail/config.yml; sudo service promtail restart
相关连结
外部链接
- 官方网站 (英文)