Parsing Nextcloud Audit Logs with Grafana Loki

Hello,

im on NixOs 24.05 and am followed this tutorial:

Enabled following logs for nextcloud:

  services.nextcloud = {
    settings = {
      loglevel = 1;
      log_type = "file";
    };
  };

Added the scrape_config to promtail:

  {
    job_name = "system";
    static_configs = {
      targets =  [ "localhost" ];
      labels = {
        instance = "${builtins.toString config.services.nextcloud.hostName}";
        env = "${builtins.toString config.networking.hostName}";
        job = "nextcloud";
        __path__ = "/tank/Nextcloud/data/{nextcloud,audit}.log";
      };
    };
  }

however, nixos-rebuild throws an error: Failed to start Promtail log ingress.

And the logs show:

Sep 17 14:21:27 omhe promtail-pre-start[253583]: Unable to parse config: /nix/store/wk8w56rkkgj1j8wwmv138azh5xlrp3la-promtail-config.json: yaml: unmarshal errors:
Sep 17 14:21:27 omhe promtail-pre-start[253583]:   line 31: cannot unmarshal !!map into discovery.StaticConfig. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file
Sep 17 14:21:27 omhe systemd[1]: promtail.service: Control process exited, code=exited, status=1/FAILURE

so there seems to be some kind of error in the scrape_config. according to the tutorial, it should look like this:

scrape_configs: #The most important part
- job_name: system
  static_configs:
  - targets:
      - localhost #Promtail target is localhost
    labels:
      instance: nextcloud.voidquark.com #Label identifier for instance (hostname -f)
      env: home-lab #Environment label
      job: nextcloud #Job label
      __path__: /var/log/nextcloud/{nextcloud,audit}.log

I’m really not sure on how to change the promtail.configuration.scrape_configs to match the above.

Appreciate all input! thanks