Skip to main content

Configure and Access Audit Logs

On any operational Edge host, many services write events, logs, and any other applicable audit logs to the /var/log/stylus-audit.log file. If you have application workloads on your cluster, you can also configure them to write audit logs to the same file. This allows you to keep all audit logs in a single location for easy management and retrieval. Audit logs written to the /var/log/stylus-audit.log file can be downloaded from Local UI.

Configure Audit Logs to be Written to File​

You can configure your own application to write log entries to the /var/log/stylus-audit.log file by setting up the applications to write to syslog and configure your syslog daemon to direct the logs to the file. The exact steps to do this vary by application, but the log entries must conform to the expected schema. In addition, you can also direct Palette agent's logs to another file if you want to collect the logs in a different file.

By default, Local UI displays one year's worth of audit logs. After one year, log files are rotated out and archived. You can download archived log files that are less than three years old, but Local UI does not display them.

Prerequisites​

  • You must have configured your application to write logs to syslog with a given facility and severity level. We recommend setting the facility as local7 and severity as notice. We also recommend that you add a tag to your application logs to distinguish it from other logs.

  • The audit entries logged to syslog must be in the RFC 5424 Syslog protocol, with the message in JSON format. The JSON object must contain the following keys: edgeHostId, contentMsg, action, actor, actorType, resourceId, resourceName, resourceKind. For more information about the Syslog protocol, refer to RFC 5424 - The Syslog Protocol.

  • This how-to is based on the EdgeForge process. We recommend that you familiarize yourself with EdgeForge and the process to build Edge artifacts.

  • A physical or virtual Linux machine with AMD64 (also known as x86_64) processor architecture to build the Edge artifacts. You can issue the following command in the terminal to check your processor architecture.

    uname -m
  • Minimum hardware configuration of the Linux machine:

    • 4 CPU
    • 8 GB memory
    • 150 GB storage
  • Git. You can ensure git installation by issuing the git --version command.

Procedure​

  1. Clone the CanvOS repository and change into the directory.

     git clone https://github.com/spectrocloud/CanvOS.git
  2. Create a file at the path overlay/files/etc/rsyslog.d/48-audit.conf. You can change the file name, but it must be a conf file and sorted alphanumerically before 49-stylus.conf. For example, 30-my-log.conf.

  1. Populate the file with the following configuration. Replace your-tag with the tag you configured for the logs of your own application. If you changed the facility or the severity level from the suggested values, replace them with your actual values.

    $PrivDropToUser root
    $PrivDropToGroup root
    $Umask 0000
    $template ForwardFormat,"<%pri%>1 %timestamp:::date-rfc3339% %HOSTNAME% %syslogtag% %procid% - - %msg%\n"
    if ($syslogfacility-text == 'local7' and $syslogseverity-text == 'notice' and $syslogtag contains '<your-tag>') then {
    action(
    type="omfile"
    file="/var/log/stylus-audit.log"
    FileCreateMode="0600"
    fileowner="root"
    template="ForwardFormat"
    )
    }

    Ensure your logs follow the RFC 5424 Syslog protocol, with the message in JSON format. The JSON object must contain the following keys: edgeHostId, contentMsg, action, actor, actorType, resourceId, resourceName, resourceKind. If your log entries do not follow the RFC 5424 Syslog protocol, or do not contain the necessary keys, they are still logged, but Local UI does not display them.

  1. Follow the Build Edge Installer ISO guide to build an Edge installer ISO and install an Edge host. Then follow the relevant guides in Deployment to deploy a cluster with your application workloads.

Validate​

  1. Log in to Local UI. For more information, refer to Access Local UI Console.

  2. From the left main menu, select Diagnostics, and then select the Audit tab. Confirm that the list shows the logs from your applications.

View and Download Log File from Local UI​

Log files are stored in the /var/log/ folder. The active log file stylus-audit.log stores up to one year's worth of logs. After a year, or when the file size reaches 100 MB, the log file is rotated out and archived. If the log messages follow the expected schema, Local UI displays them.

From Local UI, you can also download the audit log files in the /var/log/ folder that are less than three years old. These files include the log entries that Local UI does not display.

Prerequisites​

  • An Edge host installed with Edge Installer 4.3 or later.

  • Network access to the Edge host's port where Local UI is exposed. The default port is 5080.

  • Credentials to log in to Local UI. Any Operating System (OS) user can be used to log into Local UI.

Procedure​

  1. Log in to Local UI. For more information, refer to Access Local UI Console.

  2. From the left main menu, select Diagnostics, and then select the Audit tab. The tab lists the audit log entries from the past year.

    info

    To configure the format of the Timestamp column, navigate to the User Menu in the upper-right corner and select Time/Date Settings. Local UI supports displaying values in Coordinated Universal Time (UTC), the browser’s local time zone, or both simultaneously.

  3. To download the log files, select Download all logs to the right of the filters. Local UI downloads a compressed archive that contains stylus-audit.log and its archived log files. The archive does not include other files in the /var/log/ folder, such as a separate file that you configured to receive a copy of the Palette agent logs.

Validate​

  1. Extract the downloaded archive. Confirm that it contains stylus-audit.log.