Observing the directory: slapd log levels, the accesslog and auditlog overlays, cn=Monitor statistics, log rotation, and monitoring integrations like SNMP and Prometheus.

In episode 17 you built SASL authentication all the way to the system level. Now the operation needs to see what the server is doing. Episode 18 covers audit logging and monitoring: how slapd writes logs, the overlays that record access and change history, the cn=Monitor statistics, and how all of it connects to tools like SNMP and Prometheus.
A directory without logging is a black box. Proper logging and monitoring give you:
Without logs, a compromise is discovered too late and cannot be reconstructed.
slapd produces logs in its stats level set. Log levels are selected with olcLogLevel in cn=config:
| Level | Category | When to enable |
|---|---|---|
stats | basic statistics: connections, operations, results | production default |
conns | connection open/close details | troubleshooting connectivity |
filter | search filters used | debugging queries |
acl | ACL evaluation details | auditing access control |
sync | replication synchronization | monitoring replication |
stats2 | more detailed statistics, noisy | debug, high overhead |
trace | full trace, extremely noisy | developer debugging only |
For production, a good balance is stats (and sync on replication servers). Start from there; enable more only while troubleshooting.
dn: cn=config
changetype: modify
replace: olcLogLevel
olcLogLevel: statsWhere the logs go depends on the system service manager. Under systemd, slapd logs to the journal (journalctl -u slapd). To separate logs, configure rsyslog to route slapd output to its own file and rotate it with logrotate:
local4.* /var/log/slapd/slapd.log/var/log/slapd/slapd.log {
weekly
rotate 12
compress
delaycompress
missingok
notifempty
create 0640 syslog adm
}Proper rotation prevents the disk from filling up and preserves history for audit.
The auditlog overlay writes every write operation (add, modify, delete) as an LDIF entry to a text file — a real audit trail of who changed what:
dn: cn=module{0},cn=config
objectClass: olcModuleList
olcModulePath: /usr/lib/ldap
olcModuleLoad: auditlog.la
dn: olcOverlay=auditlog,olcDatabase={1}mdb,cn=config
objectClass: olcOverlayConfig
objectClass: olcAuditLogConfig
olcOverlay: auditlog
olcAuditlogFile: /var/log/slapd/auditlog.logEach change is appended to olcAuditlogFile with the timestamp, the operator DN, and the full LDIF of the operation. This is the primary data source for compliance and internal audits.
accesslog (already mentioned in episode 13 for delta-syncrepl) records every access to every entry in a special database, cn=accesslog. Unlike auditlog, which writes to a file, accesslog is a directory database that can be queried and indexed:
dn: olcDatabase={2}mdb,cn=config
objectClass: olcDatabaseConfig
olcDatabase: mdb
olcDbDirectory: /var/lib/ldap/accesslog
olcSuffix: cn=accesslog
olcDbIndex: reqStart eq
olcDbIndex: entryCSN eq
olcDbIndex: objectClass eq
dn: olcOverlay=accesslog,olcDatabase={1}mdb,cn=config
objectClass: olcOverlayConfig
objectClass: olcAccessLogConfig
olcOverlay: accesslog
olcAccessLogDB: cn=accesslog
olcAccessLogOps: writes
olcAccessLogSuccess: TRUESearching it:
ldapsearch -x -D cn=admin,dc=example,dc=com -W \
-b cn=accesslog "(reqDN=uid=budi,ou=people,dc=example,dc=com)" \
reqStart reqDN reqModThe difference from auditlog: accesslog keeps historical state of attributes (useful for forensics and replication) while auditlog is a simpler, human-readable file for auditing.
cn=Monitor is the built-in monitoring database. It doesn't store user data — it publishes live statistics about the server. With the database enabled:
dn: olcDatabase=monitor,cn=config
objectClass: olcDatabaseConfig
olcDatabase: monitor
olcMonitorConfig: FALSEReading statistics:
ldapsearch -x -D cn=admin,dc=example,dc=com -W \
-b cn=Connections,cn=Monitor \
monitorConnectionCurrent monitorConnectionTotal
ldapsearch -x -D cn=admin,dc=example,dc=com -W \
-b cn=Statistics,cn=Monitor \
monitorOpInitiated monitorOpCompletedmonitorConnectionTotal shows how many connections ever opened; monitorOpInitiated and monitorOpCompleted show operation activity. These numbers are the basis for dashboards and capacity planning.
To reach the operations team's monitoring tools:
snmpget/snmpwalk, then collect with Zabbix, Nagios, etc.cn=Monitor and exposes metrics like openldap_connections_total and openldap_operations_total, which Grafana then visualizes.Monitoring suggestions:
| Metric | What it reveals |
|---|---|
monitorConnectionTotal | growth in connection count |
| bind failures | password attack attempts |
| search operations | read load and potential DoS |
| write operations | replication lag or unusual changes |
| entry count | database growth |
replication contextCSN | sync health across servers |
curl -s http://localhost:9330/metrics | grep openldapIn this episode 18 you understood OpenLDAP logging and monitoring: olcLogLevel levels from stats to trace; log placement and rotation; the auditlog overlay writing every write operation to a file; the accesslog overlay recording access to a queryable database; the cn=Monitor statistics; and integration with SNMP and Prometheus.
Key takeaways:
stats is the production baseline, sync for replication servers.In the next episode, episode 19, we turn from observing to consuming: Linux system authentication — how NSS, PAM, and SSSD make LDAP users log into Linux systems, with configuration, testing, and troubleshooting.