Hello, I looked at the forum and also documentation but couldn't find anything. I am trying to export single log Security ›› Event Logs : Application: Requests with the VT support id over API. (v ...
Can you provide some more insight on how you resolved this? I'm trying to do the same ("Export single ASM Event Log over API"), following this guide: https://support.f5.com/csp/article/K50284219
I receive an html file which is useless, because it contains only a header with f5 logo and some metadata, but no details on the specific event ID at all. Although the html only displays very few lines, it is also about 800kb in size, but this seems to be due to the fact that it contains some java script that brings along a lot of static basic stuff like country codes, descriptions of violations and such.
Is this the same error you enconuntered? If so, can you point out what you mean by "querying the support id as a List object" and "changing it to a string"?
I had the same issue. When you make the get request with the support id, when the support id is not correctly passed to the f5, it generates a report but a useless empty one.
In my case, because of my mistake:
Correct one:
What I can suggest is that you try to check your inputs. If you need more insight sharing the code:
try:
data = {
"restPath": "/mgmt/tm/asm/events/requests",
"filename": f"ASM_security_event_report_{datetime.now().strftime(DATE_FORMAT)}.html",
"filter": f"id eq '{vt_number}'"
}
request = requests.post(url=f'{selected_f5}/mgmt/tm/asm/tasks/export-to-file', headers=headers, json=data, verify=False)
filename = json.loads(request.text)['filename']
id = json.loads(request.text)['id']
request = requests.get(url=f'{selected_f5}/mgmt/tm/asm/tasks/export-to-file/{id}', headers=headers, verify=False)
while json.loads(request.text)['status'] == "STARTED":
request = requests.get(url=f'{selected_f5}/mgmt/tm/asm/tasks/export-to-file/{id}', headers=headers, verify=False)
if json.loads(request.text)['status'] == 'COMPLETED':
request = requests.delete(url=f'{selected_f5}/mgmt/tm/asm/tasks/export-to-file/{id}', headers=headers, verify=False)
response = requests.get(url=f'{selected_f5}/mgmt/tm/asm/file-transfer/downloads/{filename}', headers=headers, verify=False)
response.raise_for_status()
with open('logs/%s' % filename, 'wb') as f:
f.write(response.content)
print(f'{filename} is saved to logs folder.')
I didn't use the article that you shared. I intercept every request with UI and replicate the steps in python.
It has been a few years since I looked into the report generation process, so you may need to do some sniffing of the requests the webui makes through Developer Tools in your browser and double check this still works.
The following call is one I used to grab the report data in JSON format, this is in Python. Set the $filter attribute in the query paramater (aka the variable exampleid in this case) to match the appropriate support ID number. Send this URL via requests as a GET query:
After obtaining the data, if you want to use it in the HTML template it normally goes into, I found it necessary to set the encoding to utf-8 before base64 encoding it. Otherwise as it is just a big JSON file, you can do whatever you want with it.