Configure Osqueryd logs for SAM total usage metrics
-
- UpdatedAug 3, 2023
- 2 minutes to read
- Vancouver
- IT Operations Management
By default, Osquery supports log rotation based on size. To enable it for SAM total usage metrics and to configure the log size and rotation, you need to add specific flags for Osqueryd service.
Before you begin
Role required: admin
- Average CPU usage for the Agent and Osqueryd was less than 10 % CPU and maximum of 30% CPU. This will only occur when the SAM background policy is triggered. By default, the trigger happens every 480 seconds.
- Average Memory usage for Agent and Osqueryd was less than 10 MB and maximum of 26 MB was consumed.
Procedure
Result
Once the Osqueryd schedule and Osqueryd logs are configured the Osqueryd service can start.
The schedule runs the Osquery: Select name, pid, elapsed_time, start_time, user_time, system_time, username from processes p JOIN users u ON u.uid = p.uid where p.elapsed_time != -1 AND u.type !='special';" runs every 5 minutes (300 seconds) on the target machine. This logs the results into the log file. The log file contains snapshot entries of all the queries configured to run by the Osqueryd . This query contains all the processes attributes.
A temporary file marker.json is created in a temporary local folder on your machine in the directory:
For Windows
: <userprofile>\\AppData\\Local\\AgentClientCollector\\SAM
.
For macOS: /Library/Application\ Support/servicenow/agent-client-collector.
This file has read/write permissions and contains the marker data: Data and Last Read Unix Time stamp.
The Osqueryd can also be configured to write its logs to a custom directory path instead of the default directory. If you choose a custom directory, modify the check definition [samadvanced-background-log-check].