Description | This article describes how to retrieve event logs using an API GET request with specific filters, with emphasis on the use of Unix epoch timestamps in milliseconds for log filtering. |
Scope | FortiGate. |
Solution |
Prerequisites
Step 1: Convert human-readable dates to Unix epoch timestamps. To filter event logs based on time, first convert the human-readable dates into Unix epoch timestamps in milliseconds.
Example:
Date & Time: '2024-08-14 10:33:51' -> '1723617231000'. These conversions can be done using various tools like online converters or programmatically using languages like Python. For example: epochconverter.com.
Step 2: Construct the API GET request. Use the epoch timestamps to create the API GET request, ensuring that the filter conditions are properly structured and combined.
Example API Requests:
Example 1:
To retrieve the logs greater than or equal to the timestamp '2024-08-14 10:33:51', use the '>=' filter.
https://<api_endpoint>/api/v2/log/memory/event/system?access_token=<insert_access_token>&filter=_metadata.timestamp>=1723617231000
Example 2:
To retrieve the logs exactly matching the timestamp '2024-08-14 10:33:51', use the '==' filter.
https://<api_endpoint>/api/v2/log/memory/event/system?access_token=<insert_access_token>&filter=_metadata.timestamp==1723617231000
Example 3:
To retrieve the logs starting from the timestamp '27 August 2024 10:30:00' until '27 August 2024 12:30:00', use the '>=' and '<' filter.
https://<api_endpoint>/api/v2/log/memory/event/system?access_token=<insert_access_token>&filter=_metadata.timestamp>=1724740200000&filter=_metadata.timestamp<1724747400000
Step 3: Execute the request and verify the results.
Submit the GET request to the API and review the returned logs to make sure they are within the given period.
Output for example 1:
Output for example 2:
Output for example 3 (Using an API tool such as postman):
Troubleshooting:
Collect FortiOS output from these commands:
Debug commands for the REST API:
By following these steps, it is possible to successfully use an API GET request with Unix epoch timestamp filters to retrieve event logs from particular times. This method is best for isolating logs for specific events or periods. |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.