PTA - How to output events since a certain date
84
Created On 11/10/26 10:55 AM - Last Modified 11/10/26 16:05 PM
Question
There are many events in the PTA database. These events can be extracted from the PTA console to a text file using mongodbQuery.
How can they be filtered to only show events from a certain date i.e. since 15th August 2023?
How can they be filtered to only show events from a certain date i.e. since 15th August 2023?
Environment
11.5;11.6;11.7;12.0;12.2;12.6;13.0;13.2 Privileged Access Manager (PAM, self-hosted) PTA
Answer
First check the version of mongodb on the server by running the following from the PTA console:
mongod -version
If the db version is 3.4 or earlier, then the following command can be used from the PTA server console:
/opt/diag-tool/ptaInternalDiagTool.sh mongoQuery -c events -t find -q '{"mCreateDate":{$gt:{$date:"2023-08-15T00:00:00Z"}}}'
If the db version is 3.6 or above, the following command should be used:
mongod -version
If the db version is 3.4 or earlier, then the following command can be used from the PTA server console:
/opt/diag-tool/ptaInternalDiagTool.sh mongoQuery -c events -t find -q '{"mCreateDate":{$gt:{$date:"2023-08-15T00:00:00Z"}}}'
If the db version is 3.6 or above, the following command should be used:
/opt/diag-tool/ptaInternalDiagTool.sh mongoQuery -c events -t find -q '{$expr:{ $gt: ["$mCreateDate",{$date:"2023-08-15T00:00:00Z"} ]}}'
In this case, the hour specification can be left out:
/opt/diag-tool/ptaInternalDiagTool.sh mongoQuery -c events -t find -q '{$expr:{ $gt: ["$mCreateDate",{$date:"2023-08-15"} ]}}'
To save the output to a file, append > <filename>.txt to the end of the command
In this case, the hour specification can be left out:
/opt/diag-tool/ptaInternalDiagTool.sh mongoQuery -c events -t find -q '{$expr:{ $gt: ["$mCreateDate",{$date:"2023-08-15"} ]}}'
To save the output to a file, append > <filename>.txt to the end of the command
NOTE: Check the results output. The date format may be different in different environments so the month and day in the command may need to be switched around.