How to pull Audit logs with API?

Hello, im trying to get the audit logs from a database via API,
I know i can manually download them on the UI but i want to automate the process.
So far I came up with this information:

but there’s some information that is required and I cannot find
Need to know where to find the HOSTNAME, PUBLIC KEY and PRIVATE KEY.
If anyone could point me in the right direction, it would be very appreciated.

Hi @Juan_Fernandez_Bernt welcome to the community!

I think you need to follow the steps outlined in Get Started with the Atlas Administration API.

In the section titled Manage Programmatic Access to an Organization, it mentioned how to create the public & private keys. You would need to follow all the prerequisites outlined in that page before arriving at this step though.

Best regards


got the keys but im getting an error 400, invalid hostname.
Where am i supposed to find the hostname? I was trying with the name of the actual database.

When im checking the metrics for my deployments i saw this:
[] and i thought that was the hostname, cant seem to find anything that would point me in the right direction

Hi @Juan_Fernandez_Bernt , I’m sorry you’re having that experience. Best way to get the hostname is to use Get Processes endpoint or “atlas process list -o json” command in the Atlas CLI. Host name example:


1 Like

It works now, but its getting the logs from the last 24 hours.
How to make it pull the last 5 minutes?

I’m so sorry for getting back to you late. I’ve missed this follow up question. Currently there’s no way to filter out results by timeframe. You’d need to do some post processing after downloading the full logs. I’ll pass it as an improvement idea to my colleagues.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.