@kyanny's blog

My thoughts, my life. Views/opinions are my own.

systemd, journald, journalctl メモ

systemd, journald, journalctl について

  • systemd とは、Linux のシステム管理の仕組み。現在の主流。かつての init を置き換えるもの。
  • journald とは、systemd 標準のログ管理の仕組み。syslog などを置き換えることもできるし、併用もできる。
  • journalctl とは、journald が保存しているログ(バイナリファイル)を閲覧するためのツール。

journalctl コマンドについて

  • フィールドによる絞り込み: journalctl FIELD_NAME=FIELD_VALUE が正式な形式
  • -u オプション: systemd の unit 単位で絞り込む。↑のショートカット
    • unit とは、systemd が管理するサービスの単位
  • -t オプション: syslog identifier で絞り込む。↑のショートカット

systemd - How can I view journalctl logs by unit and identifier with one command? - Unix & Linux Stack Exchange

$ journalctl _SYSTEMD_UNIT=vpn.service + SYSLOG_IDENTIFIER=vpn.sh

In order to do that, you need to refer to them by their proper field names (the flags -u and -t are shortcuts for those.)

  • -N オプション: ↑の形式で指定できるフィールド名の一覧を得る
  • -F オプション: ↑の形式で指定できるフィールドの、特定のフィールド名について、指定できる値の一覧を得る

dockerd:

CONTAINER_TAG, SYSLOG_IDENTIFIER The container tag (log tag option documentation).

Customize log driver output | Docker Documentation

色々入り組んでて、これを理解するには前提としてこれを理解しないと・・というのが積み重なっていて、難しい。まともに書くことができない。