「Promtail」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
行 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傳輸軟體,屬於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@http://localhost@http://loki.example.com@' /etc/promtail/config.yml; sudo service promtail restart

相關連結

外部連結