Blog

So leiten Sie GitHub Actions Runner Logs weiter

Laurens Knoll

Aktualisiert Oktober 16, 2025
2 Minuten

Sie verwenden ephemere GitHub Actions Runners und es tritt ein Problem auf. Zeit für die Fehlersuche. Aber wo soll ich suchen? Alle Beweise sind bereits verschwunden... Lassen Sie uns diese Situation verhindern, indem wir die Protokolle der Runner in Cloud Logging speichern.

Voraussetzungen

Um Protokolle zu sammeln und einzulesen, müssen Sie den Ops Agent oder den Legacy Logging Agent installieren.

Ops Agent Konfiguration

Der Ops Agent wird über die /etc/google-cloud-ops-agent/config.yaml-Datei konfiguriert. Führen Sie die unten stehende Protokollierungskonfiguration ein, um mit der Sammlung von GitHub Actions Runner-Protokollen zu beginnen.

logging:
  receivers:
    github_runner:
      type: files
      include_paths:
      - /your-runner-installation-directory/_diag/Runner_*.log
    github_worker:
      type: files
      include_paths:
      - /your-runner-installation-directory/_diag/Worker_*.log

  processors:
    github:
      type: parse_regex
      regex: "^[(?<time>d{4}-d{1,2}-d{1,2} d{1,2}:d{1,2}:d{1,2})Zs+(?<severity>[^s]+)s+(?<thread>.*)] (?<message>.*)"
      time_key: time
      time_format: "%Y-%m-%d %H:%M:%S"

  service:
    pipelines:
      github_runner:
        receivers:
        - github_runner
        processors:
        - github
      github_runner:
        receivers:
        - github_worker
        processors:
        - github

Legacy Logging Agent Konfiguration

Der Legacy Logging Agent wird über Dateien im /etc/google-fluentd/config.d/-Verzeichnis konfiguriert. Erstellen Sie eine github.conf-Datei mit der unten stehenden Konfiguration, um mit der Sammlung von GitHub Actions runner-Protokollen zu beginnen.

<source>
  @type tail
  format multiline
  format_firstline /[d{4}-d{1,2}-d{1,2} d{1,2}:d{1,2}:d{1,2}Z/
  format1 /^[(?<time>d{4}-d{1,2}-d{1,2} d{1,2}:d{1,2}:d{1,2})Zs+(?<severity>[^s]+)s+(?<thread>.*)] (?<message>.*)/

  path /your-runner-installation-directory/_diag/Runner_*.log
  pos_file /var/lib/google-fluentd/pos/github-runner.pos
  read_from_head true
  tag github-runner
</source>

<source>
  @type tail
  format multiline
  format_firstline /[d{4}-d{1,2}-d{1,2} d{1,2}:d{1,2}:d{1,2}Z/
  format1 /^[(?<time>d{4}-d{1,2}-d{1,2} d{1,2}:d{1,2}:d{1,2})Zs+(?<severity>[^s]+)s+(?<thread>.*)] (?<message>.*)/

  path /your-runner-installation-directory/_diag/Worker_*.log
  pos_file /var/lib/google-fluentd/pos/github-worker.pos
  read_from_head true
  tag github-worker
</source>

Diskussion

Man könnte sich fragen, warum wir immer noch einen Agent zur Weiterleitung von Protokollen benötigen. Können Sie die Protokolle nicht einfach an stdout weiterleiten? Derzeit nicht. Auf GitHub wird eine Funktionsanfrage gemeldet.

Fazit

Beobachtbarkeit ist der Schlüssel zum Betrieb Ihrer ephemeren Workloads. Mit Cloud Logging können Sie beliebige Protokolldateien mithilfe einer einfachen Konfigurationsdatei aufbewahren. Viel Spaß mit GitHub Actions runner logging!

Bild von PollyDot aus Pixabay

Verfasst von

Laurens Knoll

As a cloud consultant I enjoy improving what your company does best. I enable your business using cloud technology and enable your engineers by applying software engineering practices to your infrastructure domain.

Contact

Let’s discuss how we can support your journey.