Promtail:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
无编辑摘要
第38行: 第38行:


== Cheatsheet ==
== Cheatsheet ==
這邊需要把<code>loki.example.com</code>改成自己的[[Loki]]服務位置:


<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 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
</syntaxhighlight>
</syntaxhighlight>



2023年6月28日 (三) 07:23的版本

Promtail是Log傳輸軟體,屬於GrafanaLoki生態系。

安裝

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@localhost@loki.example.com@' /etc/promtail/config.yml; sudo service promtail restart

相關連結

外部連結