Knowledge base

Selecting the fields that answer questions

Accounting takes space, and extra columns cost

The task. Questions answered by accounting fields — whether delivery was encrypted, which proxy it went through, after how many failures — come up after the campaign. But a field not named in advance did not get into the file, and there is no data for that period.

What it is made of:

The parts have different scopes. Fields are selected per record type in each <acct-file> block, so a node can write a detailed file for one consumer and a sparse one for another. Record types are selected the same way: by default only d and b.

How they interact. This is one decision, not four: what a delivery record must say. Without these fields it says the message arrived; with them — with what transport protection, through which proxy, after how many failures and how long it all took. The cost is bytes per record; the limitation is that a field works only going forward.

The main trap is taking the star for “all fields”. The record-fields description says “all”, but the field tables say the star gives only the marked ones: dlvTlsProtocol, numRetries and dlvProxyName are not in it, and the file is silently written without them.
What the Hub does. It applies this partially. For deliveries and bounces the Hub adds timeFirstAttempt, totalSecondsQueued and numRetries to the star. dlvTlsProtocol and dlvProxyName are not named: delivery encryption is not visible in accounting, and the proxy can be recognized only by the sending address name. bounceCat for bounces comes with the star — it is in the default set.
Recommended values

What to name and what it gives:

Field In the star What it answers
dlvTlsProtocol, dlvTlsCipher no whether delivery was encrypted and with what
numRetries, timeFirstAttempt, totalSecondsQueued no how many failures and how much time before delivery
dlvProxyName no which proxy the message went through
bounceCat yes for b, no for d bounce category
The fields and the default set marks come from the manual (§ 12.2.1–12.2.2, § 3.3.11.12). The scheme itself is our hypothesis.
Example configuration
<acct-file /var/log/pmta/acct.csv>
    records d, b
    record-fields d *, timeFirstAttempt, numRetries, dlvTlsProtocol, dlvTlsCipher, dlvProxyName    record-fields b *, timeFirstAttempt, numRetries
</acct-file>
The star is the default fields, and everything after it is added to them; bounceCat for b is already in the star.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
How to check on the node
Check which fields the accounting file writes:
grep -n 'record-fields' /etc/pmta/config
head -1 "$(ls -t /var/log/pmta/acct-*.csv | head -1)"
A CSV accounting file starts with a header line: a field that is not there is not in the file.