Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Mohammed_Waked
New Contributor

how can show logs in blocks with filter by api

hello guys 
i have problem with this api request 

 

start = 0
limit=1
all_policies=[]
while true:
    url = f"{base_url}/api/v2/cmdb/firewall/policy?vdom={vdom}&start={start}&rows={limit}"
        response = requests.get(url, headers=headers, verify=False)
        if response.status_code == 200:
            policies = response.json().get("results", [])
            all_policies.append(policies)
            if not policies:
                break  # No more policies to fetch
start+=limit
​

 

 

when i print all_policies in every loop, the first log show every request, that means the start in the URL does not work correctly
how can i take logs block by block?
the first request get log number 1 to 1000
the second request get log number 1001 to 2000
and so on

 

3 REPLIES 3
funkylicious
SuperUser
SuperUser

hi,

i dont think this would be possible.

first of all, the filters start= and rows= dont exist in the API for firewall policy.

you could fetch all the policyid's with the one that you already are calling, put them in a list and then make blocks of X and fetch them using the /firewall/policy/{policyid} URI.

"jack of all trades, master of none"
"jack of all trades, master of none"
Mohammed_Waked

if i send one request to get logs the device maybe crashed beacuse the logs = 10G for one month 
and i dont know how to filter time for request

dingjerry_FTNT

Hi @Mohammed_Waked ,

 

I am not familiar with API requests.

 

However, if you have an FAZ, why not use FAZ?  Or a third-party log server (i.e. a Syslog server) for log filtering?

Regards,

Jerry
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors