I tested webhook’s way of sending logs to kafak today, and after sending, I found that the local log(/opt/kumomta/sbin/tailer --tail /var/log/kumomta) had also changed, which disturbed me.
One scenario I envision is that when a tenant uses KumoMTA, I judge the tenant and pass a specific type of data back to the tenant.
How to keep the original log (local log) in case of forwarding some logs to kafka.
Here is my hypothetical code
function connection:send(message)
local log_record = message:get_meta('log_record')
if not log_record then
kumo.reject(400, 'Missing log record metadata')
return
end
local topic = topics_map[log_record.type] or "pmta_other"
local status, partition, offset = pcall(producer.send, producer, {
topic = topic,
payload = message:get_data(),
})
if status then
return string.format('Message sent successfully to topic %s', topic)
else
kumo.reject(400, string.format('Failed to send to topic %s: %s', topic, tostring(partition)))
end
end
function connection:close()
producer:close()
end
return connection
end,
Write a send back script for the ELK log to send back tenant data.
The second step is no longer KumoMTA’s job.
What I would like to ask is whether KumoMTA had any previous considerations that I did not find in the documentation. For example, I originally thought webhook was just a copy of a log, but instead of a replacement.
yeah , good. I think i will first webhook the log to ELK , Then, data is retrieved from ELK and returned to the tenants. This may reduce the impact on KumoMTA.