Audit Trails & Compliance Logging
Comprehensive logging and audit trails for regulatory compliance, security monitoring, and operational transparency
Overview
Enterprise audit trails provide complete visibility into AI operations for compliance, security, and debugging. NeuroLink supports comprehensive logging of all AI interactions with structured audit trails suitable for SOC2, GDPR, HIPAA, and other regulatory frameworks.
What You'll Learn
- Configure comprehensive audit logging
- Meet compliance requirements (GDPR, SOC2, HIPAA)
- Implement user consent tracking
- Store and query audit logs
- Integrate with SIEM systems
- Manage data retention policies
- Generate compliance reports
Why Audit Trails Matter
| Requirement | Without Audit Trails | With Audit Trails |
|---|---|---|
| GDPR Article 30 | ❌ Non-compliant | ✅ Processing records maintained |
| SOC2 Security | ❌ No audit evidence | ✅ Complete audit trail |
| HIPAA § 164.312(b) | ❌ No activity logs | ✅ Full audit and accountability |
| Security Incidents | ❌ No forensic data | ✅ Complete investigation trail |
| Debugging | ❌ Limited visibility | ✅ Full request history |
Quick Start
Basic Audit Logging
import { NeuroLink } from "@juspay/neurolink";
import { createLogger, transports, format } from "winston";
const logger = createLogger({
level: "info",
format: format.json(),
transports: [
new transports.File({ filename: "audit.log" }),
new transports.File({ filename: "error.log", level: "error" }),
],
});
const ai = new NeuroLink({
providers: [
{
name: "openai",
config: { apiKey: process.env.OPENAI_API_KEY },
},
],
// Audit logging configuration
auditLog: {
enabled: true,
level: "detailed", // 'minimal' | 'standard' | 'detailed'
onLog: (event) => {
logger.info("AI Audit Event", {
eventId: event.id,
timestamp: event.timestamp,
userId: event.userId,
action: event.action,
provider: event.provider,
model: event.model,
status: event.status,
latency: event.latency,
cost: event.cost,
tokens: event.tokens,
ip: event.ip,
userAgent: event.userAgent,
});
},
},
});
// Make request with user context
const result = await ai.generate({
input: { text: "Analyze customer feedback" },
provider: "openai",
model: "gpt-4o",
// Audit context
auditContext: {
userId: "user-12345",
sessionId: "sess-abc-789",
action: "customer-feedback-analysis",
purpose: "Business intelligence",
dataClassification: "internal",
ip: req.ip,
userAgent: req.headers["user-agent"],
},
});
Audit Log Output:
{
"eventId": "evt_8x7k2m9p",
"timestamp": "2025-01-15T14:32:11.234Z",
"userId": "user-12345",
"sessionId": "sess-abc-789",
"action": "customer-feedback-analysis",
"purpose": "Business intelligence",
"dataClassification": "internal",
"provider": "openai",
"model": "gpt-4o",
"status": "success",
"latency": 1243,
"cost": 0.0045,
"tokens": {
"input": 150,
"output": 320,
"total": 470
},
"ip": "192.168.1.100",
"userAgent": "Mozilla/5.0..."
}