Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90bfbb50 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Merge branch 'dev/syslog-alloy' into 'slim'

feat: switch from syslog-ng to alloy

See merge request !288
parents c2dcf9ef 68a80f29
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ NEXTCLOUD_DOCKER_IMG=registry.gitlab.e.foundation/e/infra/ecloud/nextcloud/slim:
NEXTCLOUD_ADMIN_USER=admin
NEXTCLOUD_ADMIN_PASSWORD=@dm1n
NEXTCLOUD_TRUSTED_DOMAINS=nginx
NEXTCLOUD_LOGLEVEL=2
NEXTCLOUD_SYSLOG_TAG=nextcloud
TRUSTED_PROXIES=
OVERWRITEPROTOCOL=
SENTRY_DSN=
+73 −0
Original line number Diff line number Diff line
loki.source.syslog "local" {
  listener {
    address  = "0.0.0.0:514"
    use_incoming_timestamp = true
    syslog_format = "rfc5424"
    idle_timeout = "24h"
    labels   = { component = "loki.source.syslog", protocol = "tcp" }
  }
  relabel_rules = loki.relabel.syslog_tag.rules
  forward_to = [loki.process.nextcloud.receiver]
}

loki.relabel "syslog_tag" {
  forward_to = []

  rule {
    action        = "replace"
    source_labels = ["__syslog_message_app_name"]
    target_label  = "nextcloud_tag"
  }
}

loki.process "nextcloud" {
  forward_to = [loki.echo.syslog.receiver]

  stage.json {
    expressions = {
      nc_req_id     = "reqId",
      nc_level      = "level",
      nc_time       = "time",
      nc_remote     = "remoteAddr",
      nc_user       = "user",
      nc_app        = "app",
      nc_method     = "method",
      nc_url        = "url",
      nc_user_agent = "userAgent",
      nc_version    = "version",
      nc_data_app   = "data.app",
      nc_message    = "message",
    }
  }

  stage.timestamp {
    source = "nc_time"
    format = "RFC3339Nano"
  }

  stage.labels {
    values = {
      nextcloud_req_id = "nc_req_id",
      nextcloud_app    = "nc_app",
      nextcloud_user   = "nc_user",
      nextcloud_level  = "nc_level",
    }
  }

  stage.structured_metadata {
    values = {
      remoteAddr = "nc_remote",
      method     = "nc_method",
      url        = "nc_url",
      userAgent  = "nc_user_agent",
      version    = "nc_version",
      dataApp    = "nc_data_app",
    }
  }

  stage.output {
    source = "nc_message"
  }
}

loki.echo "syslog" {}
+7 −2
Original line number Diff line number Diff line
@@ -6,8 +6,13 @@ $CONFIG = array(
  'theme' => 'eCloud',
  'filelocking.enabled' => true,
  'log_type' => 'syslog',
  'loglevel' => 2,
  'syslog_tag' => 'nextcloud',
  'loglevel' => getenv('NEXTCLOUD_LOGLEVEL') !== false ? (int) getenv('NEXTCLOUD_LOGLEVEL') : 2,
  'syslog_tag' => getenv('NEXTCLOUD_SYSLOG_TAG') ?: 'nextcloud',
  'log_type_audit' => 'syslog',
  'syslog_tag_audit' => (getenv('NEXTCLOUD_SYSLOG_TAG') ?: 'nextcloud'),
  'log.condition' => [
    'apps' => ['admin_audit'],
  ],
  'cron_log' => true,
  'preview_max_x' => 1024,
  'preview_max_y' => 1024,
+16 −1
Original line number Diff line number Diff line
@@ -5,11 +5,26 @@ source s_local {
    internal();
};

filter f_nextcloud {
    program("${NEXTCLOUD_SYSLOG_TAG}");
};

destination d_remote {
    network("${SYSLOG_HOST}" port(514) transport(tcp));
    network(
        "${SYSLOG_HOST}"
        port(514)
        transport("tcp")
        flags(syslog-protocol)
        so-keepalive(yes)              # enable TCP keepalive probes
        tcp-keepalive-time(60)         # wait 60s before sending the first probe
        tcp-keepalive-intvl(15)        # resend probes every 15s if no reply
        tcp-keepalive-probes(3)        # give up after 3 unanswered probes
        time-reopen(5)                 # reconnect quickly when peer closes
    );
};

log {
    source(s_local);
    filter(f_nextcloud);
    destination(d_remote);
};
+5 −2
Original line number Diff line number Diff line
@@ -3,8 +3,11 @@
echo "Murena entrypoint"

# syslog-ng
if [ -n ${SYSLOG_HOST} ]; then
  sed -i "s|\${SYSLOG_HOST}|${SYSLOG_HOST:-127.0.0.1}|g" /etc/syslog-ng/syslog-ng.conf
if [ -n "${SYSLOG_HOST}" ]; then
  sed -i \
    -e "s|\${SYSLOG_HOST}|${SYSLOG_HOST:-127.0.0.1}|g" \
    -e "s|\${NEXTCLOUD_SYSLOG_TAG}|${NEXTCLOUD_SYSLOG_TAG:-nextcloud}|g" \
    /etc/syslog-ng/syslog-ng.conf
  syslog-ng --no-caps
  echo "syslog-ng started."
fi
Loading