A plugin for logging to Elasticsearch with predefined fields.
This plugin uses http-bulk queues. All exported functions uses "elastic" as default queue ID.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-history-elastic
yum install halon-extras-history-elastic
Implement the HSL code to the Post-delivery script hook.
Params
- args
array
- Log data - opts
array
- Options array
Returns
boolean
- Whether it was successfully queued to http-bulk
The following options are available in the args array.
- arguments
array
- Use the predefined context variable $arguments - message
array
- Use the predefined context variable $message - class
string
- Bounce category (optional) - custom
array
- Used for additional logging (optional)
The following options are available in the optional opts array.
- indexname
string
- Elasticsearch index pattern - id
string
- The http-bulk ID - redact
boolean
- Redacts the local-part of the email address for both sender and recipient (Default isfalse
) - normalization
array
- Normalization settings for thesmtpreasonnormalized
property- email
boolean
- Normalize email addresses (Default istrue
) - url
boolean
- Normalize URL:s (Default isfalse
) - ip
boolean
- Normalize IP addresses (Default isfalse
)
- email
import { log_delivery_attempt } from "extras://history-elastic";
log_delivery_attempt([
"arguments" => $arguments,
"message" => $message
]);
The following code is only examples and needs to be added before calling the built-in message actions (e.g. defer, reject, and queue). The action
and reason
array keys needs to be changed to reflect what happened with the message.
Implement the HSL code to the RCPT TO, EOD and Post-delivery script hook.
Params
- args
array
- Log data - opts
array
- Options array
Returns
boolean
- Whether it was successfully queued to http-bulk
The following options are available in the args array.
- action
string
- Message action - reason
string
- The reason for the specific action - custom
array
- Used for additional logging (optional) - arguments
array
- Use the predefined context variable $arguments - connection
array
- Use the predefined context variable $connection - transaction
array
- Use the predefined context variable $transaction
The following options are available in the optional opts array.
- indexname
string
- Elasticsearch index pattern - indexrotate
string
- Elasticsearch index date rotation - id
string
- The http-bulk ID
import { log_rcptto } from "extras://history-elastic";
log_rcptto([
"action" => "REJECT",
"reason" => "Message was rejected",
"arguments" => $arguments,
"connection" => $connection,
"transaction" => $transaction
]);
Params
- args
array
- Log data - opts
array
- Options array
Returns
boolean
- Whether it was successfully queued to http-bulk
The following options are available in the args array.
- action
string
- Message action - reason
string
- The reason for the specific action - recipient
array
- The recipient (https://docs.halon.io/hsl/eod.html#recipient) - queueid
number
- Queue ID - metadata
array
- Metadata - custom
array
- Used for additional logging - arguments
array
- Use the predefined context variable $arguments - connection
array
- Use the predefined context variable $connection - transaction
array
- Use the predefined context variable $transaction
The following options are available in the optional opts array.
- indexname
string
- Elasticsearch index pattern - indexrotate
string
- Elasticsearch index date rotation - id
string
- The http-bulk ID
import { log_eod } from "extras://history-elastic";
log_eod([
"action" => "QUEUE",
"reason" => "",
"recipient" => $recipient,
"queueid" => 1,
"arguments" => $arguments,
"connection" => $connection,
"transaction" => $transaction
]);
Use this function if it is necessary to add custom fields before the delivery attempt.
Params
- args
array
- Log data - opts
array
- Options array
Returns
boolean
- Whether it was successfully queued to http-bulk
The following options are available in the args array.
- message
array
- Use the predefined context variable $message - custom
array
- Used for additional logging
The following options are available in the optional opts array.
- indexname
string
- Elasticsearch index pattern - indexrotate
string
- Elasticsearch index date rotation - id
string
- The http-bulk ID
import { log_predelivery } from "extras://history-elastic";
log_predelivery([
"custom" => [
"hello" => "world"
],
"message" => $message
]);
Params
- args
array
- Log data - opts
array
- Options array
Returns
boolean
- Whether it was successfully queued to http-bulk
The following options are available in the args array.
- arguments
array
- Use the predefined context variable $arguments - message
array
- Use the predefined context variable $message - custom
array
- Used for additional logging
The following options are available in the optional opts array.
- indexname
string
- Elasticsearch index pattern - indexrotate
string
- Elasticsearch index date rotation - id
string
- The http-bulk ID
import { log_postdelivery } from "extras://history-elastic";
log_postdelivery([
"arguments" => $arguments,
"message" => $message
]);