[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NVXRV17VTJWA4XMDZHZ4ND":3,"skill-same:01M6NVXRV17VTJWA4XMDZHZ4ND":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":25,"commitSha":51,"skillDirectory":52,"forksCount":13,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":55,"install":56,"resources":69},"01M6NVXRV17VTJWA4XMDZHZ4ND","audit-logging",null,"Implement centralized audit logging and SIEM integration. Configure log retention and security monitoring. Use when implementing audit trail requirements.","duc-duy-1612\u002FOnline-Delivery-Systems-Web","duc-duy-1612","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F192231384?v=4","01M6NSDKQQDKVTHZ8DZMZ1VYY6","01M6NSDKW8DDVTQHBT1HBDDJPT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Faudit-logging\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"audit logging","logging","audit","configure","implementing","controls","retention","main","community","log","agent-skills","use","safe","devops-security","monitoring","license","framework","change","siem","security","2026-11-10 10:12:30",false,"---\nname: audit-logging\ndescription: Implement centralized audit logging and SIEM integration. Configure log\n  retention and security monitoring. Use when implementing audit trail requirements.\ncategory: security\nrisk: safe\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Checklist and framework guidance; no privileged tooling required. Apply\n  controls through your own change process.\nmetadata:\n  author: devops-skills\n  version: '1.0'\n---\n\n# Audit Logging\n\nImplement comprehensive audit logging for compliance, security monitoring, and forensic analysis across infrastructure and applications.\n\n## When to Use\n\n- Setting up centralized logging for compliance frameworks (SOC 2, HIPAA, PCI DSS)\n- Implementing security event monitoring and alerting\n- Building audit trails for regulatory requirements\n- Configuring log retention and tamper-proof storage\n- Integrating application logs with SIEM platforms\n\n## Log Categories\n\n```yaml\naudit_events:\n  authentication:\n    - Login attempts (success and failure)\n    - MFA enrollment and verification events\n    - Session creation, renewal, and termination\n    - Password changes and resets\n    - API key and token generation\n\n  authorization:\n    - Access grants and denials\n    - Permission changes and role assignments\n    - Privilege escalation events\n    - Resource sharing modifications\n    - Policy evaluation results\n\n  data_access:\n    - Read operations on sensitive data\n    - Write and update operations\n    - Delete and purge operations\n    - Bulk export and download events\n    - Data classification changes\n\n  administrative:\n    - Configuration changes\n    - User and group management\n    - System startup and shutdown\n    - Backup and restore operations\n    - Network and firewall rule changes\n\n  system:\n    - Service health state changes\n    - Resource provisioning and deprovisioning\n    - Certificate and key rotation events\n    - Scheduled job execution results\n    - Integration and webhook events\n```\n\n## Rsyslog Configuration for Centralized Logging\n\n```bash\n# \u002Fetc\u002Frsyslog.d\u002F50-audit.conf\n\n# Load imfile module to read application logs\nmodule(load=\"imfile\")\n\n# Forward auth logs\ninput(type=\"imfile\"\n  File=\"\u002Fvar\u002Flog\u002Fauth.log\"\n  Tag=\"auth\"\n  Severity=\"info\"\n  Facility=\"auth\"\n)\n\n# Forward application audit logs\ninput(type=\"imfile\"\n  File=\"\u002Fvar\u002Flog\u002Fapp\u002Faudit.log\"\n  Tag=\"app-audit\"\n  Severity=\"info\"\n  Facility=\"local0\"\n)\n\n# Structured JSON template\ntemplate(name=\"json-audit\" type=\"list\") {\n  constant(value=\"{\")\n  constant(value=\"\\\"@timestamp\\\":\\\"\")    property(name=\"timereported\" dateFormat=\"rfc3339\")\n  constant(value=\"\\\",\\\"host\\\":\\\"\")       property(name=\"hostname\")\n  constant(value=\"\\\",\\\"severity\\\":\\\"\")   property(name=\"syslogseverity-text\")\n  constant(value=\"\\\",\\\"facility\\\":\\\"\")   property(name=\"syslogfacility-text\")\n  constant(value=\"\\\",\\\"tag\\\":\\\"\")        property(name=\"syslogtag\" format=\"json\")\n  constant(value=\"\\\",\\\"message\\\":\\\"\")    property(name=\"msg\" format=\"json\")\n  constant(value=\"\\\"}\\n\")\n}\n\n# Forward to central syslog server over TLS\naction(\n  type=\"omfwd\"\n  target=\"syslog.internal.example.com\"\n  port=\"6514\"\n  protocol=\"tcp\"\n  StreamDriver=\"gtls\"\n  StreamDriverMode=\"1\"\n  StreamDriverAuthMode=\"x509\u002Fname\"\n  template=\"json-audit\"\n  queue.type=\"LinkedList\"\n  queue.size=\"50000\"\n  queue.filename=\"fwd_audit\"\n  queue.saveonshutdown=\"on\"\n  action.resumeRetryCount=\"-1\"\n)\n```\n\n## Journald Configuration for Persistent Logging\n\n```ini\n# \u002Fetc\u002Fsystemd\u002Fjournald.conf\n[Journal]\nStorage=persistent\nCompress=yes\nSeal=yes\nSplitMode=uid\nMaxRetentionSec=365d\nMaxFileSec=30d\nSystemMaxUse=10G\nSystemKeepFree=2G\nForwardToSyslog=yes\n```\n\n```bash\n# Query journald for audit events\njournalctl _TRANSPORT=audit --since \"24 hours ago\" --output json-pretty\n\n# Filter by specific audit types\njournalctl _AUDIT_TYPE=1112 --since today  # user login events\njournalctl _AUDIT_TYPE=1100 --since today  # user auth events\n\n# Export for offline analysis\njournalctl --since \"7 days ago\" --output export > \u002Fbackup\u002Fjournal-export.bin\n```\n\n## Application Logging with Structured JSON\n\n```python\nimport logging\nimport json\nimport hashlib\nfrom datetime import datetime, timezone\nfrom functools import wraps\n\nclass AuditLogger:\n    def __init__(self, service_name, logger_name=\"audit\"):\n        self.service = service_name\n        self.logger = logging.getLogger(logger_name)\n        handler = logging.FileHandler(\"\u002Fvar\u002Flog\u002Fapp\u002Faudit.log\")\n        handler.setFormatter(logging.Formatter(\"%(message)s\"))\n        self.logger.addHandler(handler)\n        self.logger.setLevel(logging.INFO)\n        self._prev_hash = None\n\n    def log_event(self, event_type, user, resource, action, result,\n                  metadata=None, source_ip=None):\n        log_entry = {\n            \"timestamp\": datetime.now(timezone.utc).isoformat(),\n            \"service\": self.service,\n            \"event_type\": event_type,\n            \"user\": user,\n            \"resource\": resource,\n            \"action\": action,\n            \"result\": result,\n            \"source_ip\": source_ip,\n            \"metadata\": metadata or {},\n        }\n        # Chain hash for tamper detection\n        raw = json.dumps(log_entry, sort_keys=True)\n        log_entry[\"prev_hash\"] = self._prev_hash\n        log_entry[\"hash\"] = hashlib.sha256(\n            f\"{self._prev_hash}:{raw}\".encode()\n        ).hexdigest()\n        self._prev_hash = log_entry[\"hash\"]\n        self.logger.info(json.dumps(log_entry))\n\n    def log_auth(self, user, action, success, source_ip=None, mfa=False):\n        self.log_event(\n            event_type=\"authentication\",\n            user=user,\n            resource=\"auth-service\",\n            action=action,\n            result=\"success\" if success else \"failure\",\n            metadata={\"mfa_used\": mfa},\n            source_ip=source_ip,\n        )\n\n    def log_data_access(self, user, resource, operation, record_count=0,\n                        source_ip=None):\n        self.log_event(\n            event_type=\"data_access\",\n            user=user,\n            resource=resource,\n            action=operation,\n            result=\"success\",\n            metadata={\"record_count\": record_count},\n            source_ip=source_ip,\n        )\n\n\ndef audit_trail(audit_logger, resource_name):\n    \"\"\"Decorator to automatically audit function calls.\"\"\"\n    def decorator(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            user = kwargs.get(\"current_user\", \"system\")\n            try:\n                result = func(*args, **kwargs)\n                audit_logger.log_event(\n                    event_type=\"operation\",\n                    user=user,\n                    resource=resource_name,\n                    action=func.__name__,\n                    result=\"success\",\n                )\n                return result\n            except Exception as e:\n                audit_logger.log_event(\n                    event_type=\"operation\",\n                    user=user,\n                    resource=resource_name,\n                    action=func.__name__,\n                    result=\"failure\",\n                    metadata={\"error\": str(e)},\n                )\n                raise\n        return wrapper\n    return decorator\n```\n\n## Fluentd \u002F Fluent Bit Log Aggregation\n\n```yaml\n# fluent-bit.conf - lightweight agent on each node\n[SERVICE]\n    Flush         5\n    Daemon        Off\n    Log_Level     info\n    Parsers_File  parsers.conf\n\n[INPUT]\n    Name          tail\n    Path          \u002Fvar\u002Flog\u002Fapp\u002Faudit.log\n    Parser        json\n    Tag           audit.app\n    Refresh_Interval 5\n    Rotate_Wait   30\n\n[INPUT]\n    Name          systemd\n    Tag           audit.system\n    Systemd_Filter _TRANSPORT=audit\n\n[FILTER]\n    Name          modify\n    Match         audit.*\n    Add           cluster ${CLUSTER_NAME}\n    Add           node ${NODE_NAME}\n\n[OUTPUT]\n    Name          es\n    Match         audit.*\n    Host          elasticsearch.internal.example.com\n    Port          9200\n    Index         audit-logs\n    Type          _doc\n    tls           On\n    tls.verify    On\n    Retry_Limit   5\n\n[OUTPUT]\n    Name          s3\n    Match         audit.*\n    region        us-east-1\n    bucket        audit-logs-archive\n    total_file_size 50M\n    upload_timeout  10m\n    s3_key_format  \u002Flogs\u002F%Y\u002F%m\u002F%d\u002F$TAG\u002F%H_%M_%S.gz\n    compression    gzip\n```\n\n## Elasticsearch Index Lifecycle for Retention\n\n```json\n{\n  \"policy\": {\n    \"phases\": {\n      \"hot\": {\n        \"min_age\": \"0ms\",\n        \"actions\": {\n          \"rollover\": {\n            \"max_size\": \"50gb\",\n            \"max_age\": \"1d\"\n          },\n          \"set_priority\": { \"priority\": 100 }\n        }\n      },\n      \"warm\": {\n        \"min_age\": \"7d\",\n        \"actions\": {\n          \"shrink\": { \"number_of_shards\": 1 },\n          \"forcemerge\": { \"max_num_segments\": 1 },\n          \"set_priority\": { \"priority\": 50 }\n        }\n      },\n      \"cold\": {\n        \"min_age\": \"30d\",\n        \"actions\": {\n          \"freeze\": {},\n          \"set_priority\": { \"priority\": 0 }\n        }\n      },\n      \"delete\": {\n        \"min_age\": \"365d\",\n        \"actions\": { \"delete\": {} }\n      }\n    }\n  }\n}\n```\n\n## Retention Policy by Compliance Framework\n\n```yaml\nretention_requirements:\n  soc2:\n    minimum: 1 year\n    recommended: 3 years\n    notes: \"Based on audit period and report requirements\"\n\n  hipaa:\n    minimum: 6 years\n    notes: \"From date of creation or last effective date\"\n\n  pci_dss:\n    minimum: 1 year\n    immediately_available: 3 months\n    notes: \"Req 10.7 - retain for at least one year, 3 months immediately available\"\n\n  gdpr:\n    minimum: \"As long as necessary for processing purpose\"\n    notes: \"Apply data minimization; delete when no longer needed\"\n\n  fedramp:\n    minimum: 3 years\n    notes: \"AU-11 control requirement\"\n\n  iso27001:\n    minimum: \"Defined by organization policy\"\n    recommended: 3 years\n    notes: \"A.12.4.1 - retention period must be defined\"\n```\n\n## Log Integrity Verification Script\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\n# verify-log-integrity.sh - Verify log file checksums against stored hashes\n\nLOG_DIR=\"\u002Fvar\u002Flog\u002Fapp\"\nHASH_FILE=\"\u002Fvar\u002Flog\u002Fapp\u002F.checksums\"\nALERT_WEBHOOK=\"${ALERT_WEBHOOK_URL}\"\n\nverify_logs() {\n  local failures=0\n  while IFS='  ' read -r stored_hash filename; do\n    if [ -f \"$filename\" ]; then\n      current_hash=$(sha256sum \"$filename\" | awk '{print $1}')\n      if [ \"$stored_hash\" != \"$current_hash\" ]; then\n        echo \"TAMPER DETECTED: $filename\"\n        failures=$((failures + 1))\n        curl -s -X POST \"$ALERT_WEBHOOK\" \\\n          -H \"Content-Type: application\u002Fjson\" \\\n          -d \"{\\\"text\\\":\\\"ALERT: Audit log tamper detected on $(hostname): $filename\\\"}\"\n      fi\n    else\n      echo \"MISSING: $filename\"\n      failures=$((failures + 1))\n    fi\n  done \u003C \"$HASH_FILE\"\n\n  return $failures\n}\n\nupdate_checksums() {\n  find \"$LOG_DIR\" -name \"*.log\" -type f -exec sha256sum {} \\; > \"$HASH_FILE\"\n  chmod 440 \"$HASH_FILE\"\n}\n\ncase \"${1:-verify}\" in\n  verify)  verify_logs ;;\n  update)  update_checksums ;;\n  *)       echo \"Usage: $0 {verify|update}\" ;;\nesac\n```\n\n## SIEM Integration Checklist\n\n```yaml\nsiem_integration:\n  log_sources:\n    - [ ] Operating system auth logs (syslog, journald)\n    - [ ] Application audit logs (structured JSON)\n    - [ ] Cloud provider audit trails (CloudTrail, Activity Log, Audit Logs)\n    - [ ] Database query and access logs\n    - [ ] Network flow logs and firewall logs\n    - [ ] Container and orchestrator logs (Kubernetes audit)\n    - [ ] WAF and CDN access logs\n    - [ ] VPN and remote access logs\n\n  normalization:\n    - [ ] Common event format (CEF) or OCSF schema\n    - [ ] Consistent timestamp format (ISO 8601 \u002F UTC)\n    - [ ] Unified user identity fields\n    - [ ] Standardized severity levels\n\n  alerting_rules:\n    - [ ] Multiple failed login attempts (brute force)\n    - [ ] Login from unusual location or device\n    - [ ] Privilege escalation events\n    - [ ] Sensitive data bulk export\n    - [ ] Administrative action outside change window\n    - [ ] Service account anomalous activity\n    - [ ] Log forwarding gap or interruption\n\n  operational:\n    - [ ] Log pipeline health monitoring\n    - [ ] Storage capacity alerting\n    - [ ] Retention policy enforcement verified\n    - [ ] Backup of log archives confirmed\n    - [ ] Access to log systems restricted and audited\n```\n\n## Best Practices\n\n- Use structured logging (JSON) with consistent field names across all services\n- Ship logs to a centralized platform with write-once storage for tamper protection\n- Implement hash chaining or digital signatures for log integrity verification\n- Define and enforce retention policies per compliance framework requirements\n- Set up real-time alerting for high-severity security events\n- Separate audit logs from application debug logs to reduce noise\n- Never log sensitive data (passwords, tokens, PII) in audit entries\n- Monitor the logging pipeline itself to detect gaps in coverage\n- Regularly test log restoration from archives to verify recoverability\n- Rotate and compress logs to manage storage while meeting retention windows\n\n## Limitations\n\n- Guidance and checklists only; not legal advice and not a substitute for a qualified auditor.\n- Docs-only import: upstream templates and scripts not bundled.\n\n### Example\n\n```markdown\nMap this skill's control checklist to our current evidence and list gaps.\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n","# Audit Logging\n\nImplement comprehensive audit logging for compliance, security monitoring, and forensic analysis across infrastructure and applications.\n\n## When to Use\n\n- Setting up centralized logging for compliance frameworks (SOC 2, HIPAA, PCI DSS)\n- Implementing security event monitoring and alerting\n- Building audit trails for regulatory requirements\n- Configuring log retention and tamper-proof storage\n- Integrating application logs with SIEM platforms\n\n## Log Categories\n\n```yaml\naudit_events:\n  authentication:\n    - Login attempts (success and failure)\n    - MFA enrollment and verification events\n    - Session creation, renewal, and termination\n    - Password changes and resets\n    - API key and token generation\n\n  authorization:\n    - Access grants and denials\n    - Permission changes and role assignments\n    - Privilege escalation events\n    - Resource sharing modifications\n    - Policy evaluation results\n\n  data_access:\n    - Read operations on sensitive data\n    - Write and update operations\n    - Delete and purge operations\n    - Bulk export and download events\n    - Data classification changes\n\n  administrative:\n    - Configuration changes\n    - User and group management\n    - System startup and shutdown\n    - Backup and restore operations\n    - Network and firewall rule changes\n\n  system:\n    - Service health state changes\n    - Resource provisioning and deprovisioning\n    - Certificate and key rotation events\n    - Scheduled job execution results\n    - Integration and webhook events\n```\n\n## Rsyslog Configuration for Centralized Logging\n\n```bash\n# \u002Fetc\u002Frsyslog.d\u002F50-audit.conf\n\n# Load imfile module to read application logs\nmodule(load=\"imfile\")\n\n# Forward auth logs\ninput(type=\"imfile\"\n  File=\"\u002Fvar\u002Flog\u002Fauth.log\"\n  Tag=\"auth\"\n  Severity=\"info\"\n  Facility=\"auth\"\n)\n\n# Forward application audit logs\ninput(type=\"imfile\"\n  File=\"\u002Fvar\u002Flog\u002Fapp\u002Faudit.log\"\n  Tag=\"app-audit\"\n  Severity=\"info\"\n  Facility=\"local0\"\n)\n\n# Structured JSON template\ntemplate(name=\"json-audit\" type=\"list\") {\n  constant(value=\"{\")\n  constant(value=\"\\\"@timestamp\\\":\\\"\")    property(name=\"timereported\" dateFormat=\"rfc3339\")\n  constant(value=\"\\\",\\\"host\\\":\\\"\")       property(name=\"hostname\")\n  constant(value=\"\\\",\\\"severity\\\":\\\"\")   property(name=\"syslogseverity-text\")\n  constant(value=\"\\\",\\\"facility\\\":\\\"\")   property(name=\"syslogfacility-text\")\n  constant(value=\"\\\",\\\"tag\\\":\\\"\")        property(name=\"syslogtag\" format=\"json\")\n  constant(value=\"\\\",\\\"message\\\":\\\"\")    property(name=\"msg\" format=\"json\")\n  constant(value=\"\\\"}\\n\")\n}\n\n# Forward to central syslog server over TLS\naction(\n  type=\"omfwd\"\n  target=\"syslog.internal.example.com\"\n  port=\"6514\"\n  protocol=\"tcp\"\n  StreamDriver=\"gtls\"\n  StreamDriverMode=\"1\"\n  StreamDriverAuthMode=\"x509\u002Fname\"\n  template=\"json-audit\"\n  queue.type=\"LinkedList\"\n  queue.size=\"50000\"\n  queue.filename=\"fwd_audit\"\n  queue.saveonshutdown=\"on\"\n  action.resumeRetryCount=\"-1\"\n)\n```\n\n## Journald Configuration for Persistent Logging\n\n```ini\n# \u002Fetc\u002Fsystemd\u002Fjournald.conf\n[Journal]\nStorage=persistent\nCompress=yes\nSeal=yes\nSplitMode=uid\nMaxRetentionSec=365d\nMaxFileSec=30d\nSystemMaxUse=10G\nSystemKeepFree=2G\nForwardToSyslog=yes\n```\n\n```bash\n# Query journald for audit events\njournalctl _TRANSPORT=audit --since \"24 hours ago\" --output json-pretty\n\n# Filter by specific audit types\njournalctl _AUDIT_TYPE=1112 --since today  # user login events\njournalctl _AUDIT_TYPE=1100 --since today  # user auth events\n\n# Export for offline analysis\njournalctl --since \"7 days ago\" --output export > \u002Fbackup\u002Fjournal-export.bin\n```\n\n## Application Logging with Structured JSON\n\n```python\nimport logging\nimport json\nimport hashlib\nfrom datetime import datetime, timezone\nfrom functools import wraps\n\nclass AuditLogger:\n    def __init__(self, service_name, logger_name=\"audit\"):\n        self.service = service_name\n        self.logger = logging.getLogger(logger_name)\n        handler = logging.FileHandler(\"\u002Fvar\u002Flog\u002Fapp\u002Faudit.log\")\n        handler.setFormatter(logging.Formatter(\"%(message)s\"))\n        self.logger.addHandler(handler)\n        self.logger.setLevel(logging.INFO)\n        self._prev_hash = None\n\n    def log_event(self, event_type, user, resource, action, result,\n                  metadata=None, source_ip=None):\n        log_entry = {\n            \"timestamp\": datetime.now(timezone.utc).isoformat(),\n            \"service\": self.service,\n            \"event_type\": event_type,\n            \"user\": user,\n            \"resource\": resource,\n            \"action\": action,\n            \"result\": result,\n            \"source_ip\": source_ip,\n            \"metadata\": metadata or {},\n        }\n        # Chain hash for tamper detection\n        raw = json.dumps(log_entry, sort_keys=True)\n        log_entry[\"prev_hash\"] = self._prev_hash\n        log_entry[\"hash\"] = hashlib.sha256(\n            f\"{self._prev_hash}:{raw}\".encode()\n        ).hexdigest()\n        self._prev_hash = log_entry[\"hash\"]\n        self.logger.info(json.dumps(log_entry))\n\n    def log_auth(self, user, action, success, source_ip=None, mfa=False):\n        self.log_event(\n            event_type=\"authentication\",\n            user=user,\n            resource=\"auth-service\",\n            action=action,\n            result=\"success\" if success else \"failure\",\n            metadata={\"mfa_used\": mfa},\n            source_ip=source_ip,\n        )\n\n    def log_data_access(self, user, resource, operation, record_count=0,\n                        source_ip=None):\n        self.log_event(\n            event_type=\"data_access\",\n            user=user,\n            resource=resource,\n            action=operation,\n            result=\"success\",\n            metadata={\"record_count\": record_count},\n            source_ip=source_ip,\n        )\n\n\ndef audit_trail(audit_logger, resource_name):\n    \"\"\"Decorator to automatically audit function calls.\"\"\"\n    def decorator(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            user = kwargs.get(\"current_user\", \"system\")\n            try:\n                result = func(*args, **kwargs)\n                audit_logger.log_event(\n                    event_type=\"operation\",\n                    user=user,\n                    resource=resource_name,\n                    action=func.__name__,\n                    result=\"success\",\n                )\n                return result\n            except Exception as e:\n                audit_logger.log_event(\n                    event_type=\"operation\",\n                    user=user,\n                    resource=resource_name,\n                    action=func.__name__,\n                    result=\"failure\",\n                    metadata={\"error\": str(e)},\n                )\n                raise\n        return wrapper\n    return decorator\n```\n\n## Fluentd \u002F Fluent Bit Log Aggregation\n\n```yaml\n# fluent-bit.conf - lightweight agent on each node\n[SERVICE]\n    Flush         5\n    Daemon        Off\n    Log_Level     info\n    Parsers_File  parsers.conf\n\n[INPUT]\n    Name          tail\n    Path          \u002Fvar\u002Flog\u002Fapp\u002Faudit.log\n    Parser        json\n    Tag           audit.app\n    Refresh_Interval 5\n    Rotate_Wait   30\n\n[INPUT]\n    Name          systemd\n    Tag           audit.system\n    Systemd_Filter _TRANSPORT=audit\n\n[FILTER]\n    Name          modify\n    Match         audit.*\n    Add           cluster ${CLUSTER_NAME}\n    Add           node ${NODE_NAME}\n\n[OUTPUT]\n    Name          es\n    Match         audit.*\n    Host          elasticsearch.internal.example.com\n    Port          9200\n    Index         audit-logs\n    Type          _doc\n    tls           On\n    tls.verify    On\n    Retry_Limit   5\n\n[OUTPUT]\n    Name          s3\n    Match         audit.*\n    region        us-east-1\n    bucket        audit-logs-archive\n    total_file_size 50M\n    upload_timeout  10m\n    s3_key_format  \u002Flogs\u002F%Y\u002F%m\u002F%d\u002F$TAG\u002F%H_%M_%S.gz\n    compression    gzip\n```\n\n## Elasticsearch Index Lifecycle for Retention\n\n```json\n{\n  \"policy\": {\n    \"phases\": {\n      \"hot\": {\n        \"min_age\": \"0ms\",\n        \"actions\": {\n          \"rollover\": {\n            \"max_size\": \"50gb\",\n            \"max_age\": \"1d\"\n          },\n          \"set_priority\": { \"priority\": 100 }\n        }\n      },\n      \"warm\": {\n        \"min_age\": \"7d\",\n        \"actions\": {\n          \"shrink\": { \"number_of_shards\": 1 },\n          \"forcemerge\": { \"max_num_segments\": 1 },\n          \"set_priority\": { \"priority\": 50 }\n        }\n      },\n      \"cold\": {\n        \"min_age\": \"30d\",\n        \"actions\": {\n          \"freeze\": {},\n          \"set_priority\": { \"priority\": 0 }\n        }\n      },\n      \"delete\": {\n        \"min_age\": \"365d\",\n        \"actions\": { \"delete\": {} }\n      }\n    }\n  }\n}\n```\n\n## Retention Policy by Compliance Framework\n\n```yaml\nretention_requirements:\n  soc2:\n    minimum: 1 year\n    recommended: 3 years\n    notes: \"Based on audit period and report requirements\"\n\n  hipaa:\n    minimum: 6 years\n    notes: \"From date of creation or last effective date\"\n\n  pci_dss:\n    minimum: 1 year\n    immediately_available: 3 months\n    notes: \"Req 10.7 - retain for at least one year, 3 months immediately available\"\n\n  gdpr:\n    minimum: \"As long as necessary for processing purpose\"\n    notes: \"Apply data minimization; delete when no longer needed\"\n\n  fedramp:\n    minimum: 3 years\n    notes: \"AU-11 control requirement\"\n\n  iso27001:\n    minimum: \"Defined by organization policy\"\n    recommended: 3 years\n    notes: \"A.12.4.1 - retention period must be defined\"\n```\n\n## Log Integrity Verification Script\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\n# verify-log-integrity.sh - Verify log file checksums against stored hashes\n\nLOG_DIR=\"\u002Fvar\u002Flog\u002Fapp\"\nHASH_FILE=\"\u002Fvar\u002Flog\u002Fapp\u002F.checksums\"\nALERT_WEBHOOK=\"${ALERT_WEBHOOK_URL}\"\n\nverify_logs() {\n  local failures=0\n  while IFS='  ' read -r stored_hash filename; do\n    if [ -f \"$filename\" ]; then\n      current_hash=$(sha256sum \"$filename\" | awk '{print $1}')\n      if [ \"$stored_hash\" != \"$current_hash\" ]; then\n        echo \"TAMPER DETECTED: $filename\"\n        failures=$((failures + 1))\n        curl -s -X POST \"$ALERT_WEBHOOK\" \\\n          -H \"Content-Type: application\u002Fjson\" \\\n          -d \"{\\\"text\\\":\\\"ALERT: Audit log tamper detected on $(hostname): $filename\\\"}\"\n      fi\n    else\n      echo \"MISSING: $filename\"\n      failures=$((failures + 1))\n    fi\n  done \u003C \"$HASH_FILE\"\n\n  return $failures\n}\n\nupdate_checksums() {\n  find \"$LOG_DIR\" -name \"*.log\" -type f -exec sha256sum {} \\; > \"$HASH_FILE\"\n  chmod 440 \"$HASH_FILE\"\n}\n\ncase \"${1:-verify}\" in\n  verify)  verify_logs ;;\n  update)  update_checksums ;;\n  *)       echo \"Usage: $0 {verify|update}\" ;;\nesac\n```\n\n## SIEM Integration Checklist\n\n```yaml\nsiem_integration:\n  log_sources:\n    - [ ] Operating system auth logs (syslog, journald)\n    - [ ] Application audit logs (structured JSON)\n    - [ ] Cloud provider audit trails (CloudTrail, Activity Log, Audit Logs)\n    - [ ] Database query and access logs\n    - [ ] Network flow logs and firewall logs\n    - [ ] Container and orchestrator logs (Kubernetes audit)\n    - [ ] WAF and CDN access logs\n    - [ ] VPN and remote access logs\n\n  normalization:\n    - [ ] Common event format (CEF) or OCSF schema\n    - [ ] Consistent timestamp format (ISO 8601 \u002F UTC)\n    - [ ] Unified user identity fields\n    - [ ] Standardized severity levels\n\n  alerting_rules:\n    - [ ] Multiple failed login attempts (brute force)\n    - [ ] Login from unusual location or device\n    - [ ] Privilege escalation events\n    - [ ] Sensitive data bulk export\n    - [ ] Administrative action outside change window\n    - [ ] Service account anomalous activity\n    - [ ] Log forwarding gap or interruption\n\n  operational:\n    - [ ] Log pipeline health monitoring\n    - [ ] Storage capacity alerting\n    - [ ] Retention policy enforcement verified\n    - [ ] Backup of log archives confirmed\n    - [ ] Access to log systems restricted and audited\n```\n\n## Best Practices\n\n- Use structured logging (JSON) with consistent field names across all services\n- Ship logs to a centralized platform with write-once storage for tamper protection\n- Implement hash chaining or digital signatures for log integrity verification\n- Define and enforce retention policies per compliance framework requirements\n- Set up real-time alerting for high-severity security events\n- Separate audit logs from application debug logs to reduce noise\n- Never log sensitive data (passwords, tokens, PII) in audit entries\n- Monitor the logging pipeline itself to detect gaps in coverage\n- Regularly test log restoration from archives to verify recoverability\n- Rotate and compress logs to manage storage while meeting retention windows\n\n## Limitations\n\n- Guidance and checklists only; not legal advice and not a substitute for a qualified auditor.\n- Docs-only import: upstream templates and scripts not bundled.\n\n### Example\n\n```markdown\nMap this skill's control checklist to our current evidence and list gaps.\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n",{"name":5,"risk":30,"source":43,"license":14,"category":37,"metadata":44,"date_added":47,"description":7,"source_repo":48,"source_type":26,"compatibility":49,"license_source":50},"https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills",{"author":45,"version":46},"devops-skills","1.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Checklist and framework guidance; no privileged tooling required. Apply controls through your own change process.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","f3312ba749561b6159f477dbfc9313c875d40a56",".agents\u002Fskills_archive\u002Faudit-logging","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612","2026-10-25 23:50:58",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill audit-logging",{"tool":62,"command":63},"bunx","bunx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill audit-logging",{"tool":65,"command":66},"pnpm","pnpm dlx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill audit-logging","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Faudit-logging\u002FSKILL.md",true,[],[71,92,116,139,156,176],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":38},"01M6Q0FA5FZ410Z33Z3TFQ4DBA","zero-trust","Implement zero-trust network architecture. Configure identity-based access, micro-segmentation, and continuous verification. Use when implementing modern security architectures.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzero-trust\u002FSKILL.md",[],[78,79,80,81,82,83,73,84,31,85,21,86,26,25,87,88,89,90,91,22],"ZeRO","trust","zero trust","architecture","assessment","verification","segmentation","access","only","active","critical","scope","scripts","relevant",{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":38},"01M6Q0F1YZJW3KX5FBKEVZ8CV4","zcode-delegate","Delegate coding tasks to the Z.AI ZCode CLI only when the user explicitly requests it, while the orchestrator retains review and landing responsibility.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzcode-delegate\u002FSKILL.md",[],[99,100,101,102,103,104,105,106,107,108,109,110,111,86,112,26,113,114,88,115],"delegate","zcode","zcode delegate","review","cli","orchestration","tasks","run","Bash","model","node","read","orchestrator","files","desktop app","app","agent-orchestration",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":38},"01M6Q0ETK41VGNMYEXW0T00AJN","youtube-transcript","Fetch YouTube transcripts through DeepAPI or local fallback tooling and save clean text output.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript\u002FSKILL.md",[],[123,124,125,30,126,127,128,33,129,130,131,132,133,26,25,134,135,136,137,138],"transcript","youtube transcript","youtube","github","codex","research","https","text","fetch","tooling","clean","local","output","deepapi","youtube transcripts","blob",{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":38},"01M6Q0EPPH2PVMDW40017F8WX0","youtube-transcript-skills","Fetch YouTube video transcripts, search videos\u002Fchannels, browse channels, and extract playlists via the getyoutubetranscript.com API - free tier, no card required.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript-skills\u002FSKILL.md",[],[123,124,125,146,30,147,126,127,33,148,149,150,151,131,152,26,25,153,154,155],"youtube transcript skills","gemini","search","api","Video","browse","api-integration","free","card","channels",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":38},"01M6Q0EAB96PX83W5PTE8A0R8D","youtube-notetaker","Turn YouTube talks into local study notes with slides, transcripts, editable annotations, and a markdown-backed viewer.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-notetaker\u002FSKILL.md",[],[125,163,164,103,30,165,166,167,168,33,150,169,170,171,172,25,173,134,174,175],"youtube notetaker","notetaker","workflow","official","notes","code","markdown","slides","annotations","README","study","dair-academy","viewer",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":182,"publishedAt":38},"01M6Q0E55F0GW5MX48V8HXS8B5","youtube-full","Fetch YouTube transcripts, search videos, browse channels, and extract playlists via TranscriptAPI — no yt-dlp, no Google API key, works from any cloud server.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-full\u002FSKILL.md",[],[183,125,184,185,30,147,148,186,187,149,150,151,131,188,152,26,25,153,189,137],"youtube full","full","google","server","dlp","credits","automatic"]