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
Kevin

2 Likes

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:
[databasename-shard-xx-xx.xxxxxxx.gcp.mongodb.net:27017] 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: atlas-vpjr9d-shard-00-03.hbmflhz.mongodb.net

Thanks,
Jakub

1 Like

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