On 27. Jan 2025, at 15.50, Christian Rößner via dovecot <dovecot@dovecot.org> wrote:
event_exporter conn_state { driver = http-post format = json http_post_url = http://nauthilus:8080/api/v1/custom/dovecot-session-cleaner time_format = rfc3339 http_client_request_absolute_timeout = 5sec } metric client_disconnect_http { exporter = conn_state exporter_include = exporter_include { name = yes hostname = yes timestamps = yes categories = yes fields = yes } filter = event=mail_user_session_finished AND (category=imap OR category=pop3 OR category=lmtp OR category=sieve) } metric imap_noop { exporter = conn_state exporter_include = exporter_include { name = yes hostname = yes timestamps = yes categories = yes fields = yes } filter = event=imap_command_finished AND cmd_name=NOOP }
These seem to work fine with me. I copy&pasted them to my config except changed it to connect to localhost. Then did a test session:
% nc localhost 143
- OK [CAPABILITY IMAP4rev1 LOGIN-REFERRALS ID ENABLE IDLE SASL-IR LITERAL+ STARTTLS AUTH=PLAIN] Dovecot ready. x login tss pass x OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE COMPRESS=DEFLATE INPROGRESS NOTIFY SPECIAL-USE LITERAL+] Logged in x select inbox
- FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
- OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
- 0 EXISTS
- 0 RECENT
- OK [UIDVALIDITY 1738009228] UIDs valid
- OK [UIDNEXT 1] Predicted next UID x OK [READ-WRITE] Select completed (0.008 + 0.000 + 0.008 secs). x noop x OK NOOP completed (0.001 + 0.000 secs). x logout
- BYE Logging out x OK Logout completed (0.001 + 0.000 secs).
It tried to connect on NOOP and LOGOUT commands as expected:
2025-01-27T22:20:25.683680+02:00 ubuntu dovecot: imap-login: Logged in: user=<tss>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1297445, secured, session=<Z3VrzrUszs5/AAAB> 2025-01-27T22:20:29.252767+02:00 ubuntu dovecot: stats: Error: Failed to export event via HTTP POST: 9003 connect(127.0.0.1:8080) failed: Connection refused 2025-01-27T22:20:48.469938+02:00 ubuntu dovecot: imap(tss)<1297445><Z3VrzrUszs5/AAAB>: Disconnected: Logged out in=30 out=858 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0 2025-01-27T22:20:48.470406+02:00 ubuntu dovecot: stats: Error: Failed to export event via HTTP POST: 9003 connect(127.0.0.1:8080) failed: Connection refused