Collector for Active Directory Logs
Problem Statement
Design and implement a Log Collector system that can connect to Active Directory servers, fetch authentication and access logs, process them, and store them in a structured format for downstream analysis or monitoring tools.
This problem evaluates your understanding of:
📋 Problem Description
Organizations use Active Directory (AD) to manage user authentication, permissions, and access control.
To detect security incidents or policy violations, logs from multiple AD servers need to be collected, aggregated, and stored centrally.
You need to design an Active Directory Log Collector module that can:
🧱 Functional Requirements
⚙️ Non-Functional Requirements
AspectDescription
Scalability
Support multiple AD servers concurrently
Reliability
Ensure no logs are lost during network failures
Extensibility
Easy to add new log types or data sources
Maintainability
Clean, modular class design
Performance
Efficiently process large log volumes
🧩 Key System Components
Component and Responsibility
CollectorManager
Manages configuration and lifecycle of collectors
ADCollector
Connects to a single AD server, fetches logs
LogParser
Parses raw AD logs into structured objects
LogStorage
Handles storage (DB/File/Queue)
Scheduler
Triggers periodic collection
ErrorHandler
Handles retries and failure reporting
🧱 Example Class Structure
1
2class CollectorManager:
3 def __init__(self):
4 self.collectors = []
5
6 def register_collector(self, ad_server):
7 collector = ADCollector(ad_server)
8 self.collectors.append(collector)
9
10 def start_all(self):
11 for collector in self.collectors:
12 collector.start_collection()
13
14
15class ADCollector:
16 def __init__(self, ad_server):
17 self.ad_server = ad_server
18 self.parser = LogParser()
19 self.storage = LogStorage()
20
21 def fetch_logs(self):
22 # Simulate fetching logs from AD via LDAP/WinRM
23 return self.ad_server.get_logs()
24
25 def start_collection(self):
26 logs = self.fetch_logs()
27 parsed_logs = self.parser.parse(logs)
28 self.storage.save(parsed_logs)
29
30
31class LogParser:
32 def parse(self, raw_logs):
33 structured_logs = []
34 for line in raw_logs:
35 # Convert to structured format
36 structured_logs.append(self._parse_line(line))
37 return structured_logs
38
39 def _parse_line(self, line):
40 # Extract timestamp, event type, username, etc.
41 return {"timestamp": "2025-10-24T12:00Z", "event": "Login", "user": "admin"}
42
43
44class LogStorage:
45 def save(self, logs):
46 # Could write to DB, file, or message queue
47 for log in logs:
48 print("Saving:", log)⚙️ Data Model Example
FieldTypeDescription
timestamp
datetime
Time of the log event
event_type
string
Type of AD event (login, group_change, etc.)
user
string
User associated with the event
server
string
Source AD server
details
string/json
Additional event info
🔄 Flow of Execution
🧠 Design Discussion Points
🧾 Example API Design (Optional)
Method, Endpoint and Description
POST
/servers/register
Register a new AD server
GET
/logs/recent
Retrieve latest collected logs
GET
/metrics
View collection stats
DELETE
/servers/{id}
Deregister an AD server
✅ Deliverables
🚀 Stretch Goals