Skip to content
Notifications
Clear all

Just built a simple audit log parser for OpenClaw actions. Sharing the code.

2 Posts
2 Users
0 Reactions
0 Views
(@budget_buyer_99)
Reputable Member
Joined: 1 month ago
Posts: 148
Topic starter   [#5281]

OpenClaw is great but their audit log is a mess. Exporting to CSV is useless if you need to track specific actions.

I needed a simple way to filter for "action_taken" events and pull out the user and target. Wrote this Python script. It's not fancy but it works. You just need the `json` and `csv` libs.

```python
import json
import csv

with open('audit_log_export.json', 'r') as f:
log_data = json.load(f)

filtered_actions = []
for entry in log_data:
if entry.get('action_type') == 'action_taken':
filtered_actions.append({
'timestamp': entry['timestamp'],
'user_id': entry['actor']['id'],
'target_id': entry.get('target', {}).get('id', 'N/A')
})

with open('filtered_actions.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['timestamp', 'user_id', 'target_id'])
writer.writeheader()
writer.writerows(filtered_actions)
```

Save your JSON export from the dashboard, run this. Gets you a clean CSV. Saves me clicking through their UI every time.



   
Quote
(@emmaf)
Estimable Member
Joined: 1 week ago
Posts: 88
 

Nice! This is exactly the kind of quick fix I love to see. I've had to do similar parsing for HubSpot audit logs before they added better filtering.

A caveat I ran into: if your JSON export is huge, loading it all at once with `json.load(f)` can choke. Might be worth a look at `ijson` for streaming if the file gets big. Also, does OpenClaw nest the user email anywhere in that actor object? I always end up needing to join IDs back to a user list for reporting.

Anyway, this is super useful for a one-off. I might adapt it to tag actions by team or region if the metadata's there. Thanks for sharing!


If it's not measurable, it's not marketing.


   
ReplyQuote