From 9bea8e1ce7c221788a626b1d85ffaf505b8eaf0b Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 13 Oct 2024 18:05:50 -0500 Subject: [PATCH] nextcloud: Scrape logs with Promtail Nextcloud writes JSON-structured logs to `/var/lib/nextcloud/data/nextcloud.log`. These logs contain errors, etc. from the Nextcloud server, which are useful for troubleshooting. Having them in Loki will allow us to view them in Grafan as well as generate alerts for certain events. --- group_vars/nextcloud.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/group_vars/nextcloud.yml b/group_vars/nextcloud.yml index a6ea6fc..9bb4fb3 100644 --- a/group_vars/nextcloud.yml +++ b/group_vars/nextcloud.yml @@ -21,3 +21,34 @@ restic_include: restic_exclude: - /var/lib/nextcloud/data/*/files_trashbin - /var/lib/nextcloud/.snapshots + +promtail_dac_read_search: true +promtail_scrape_configs: +- '{{ promtail_default_scrape.journal }}' +- job_name: nextcloud + static_configs: + - labels: + __path__: /var/lib/nextcloud/data/nextcloud.log* + job: nextcloud + pipeline_stages: + - json: + expressions: + timestamp: time + level: level + - timestamp: + source: timestamp + format: '2006-01-02T15:04:05-07:00' + - labels: + level: +- job_name: nextcloud-updater + static_configs: + - labels: + __path__: /var/lib/nextcloud/data/updater.log + job: nextcloud-updater + pipeline_stages: + - regex: + expression: >- + ^(?P\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}) + - timestamp: + source: timestamp + format: '2006-01-02T15:04:05-0700'