Mail::SpamAssassin::Plugin::RuleTimingRedis - collect SA rule timings in redis


version 1.005


RuleTimingRedis is a plugin for spamassassin which gathers and stores performance data of processed spamassassin rules in a redis server.


To load the plugin put an loadplugin line into init.pre:

  loadplugin Mail::SpamAssassin::Plugin::RuleTimingRedis

If the is not in perls @INC you need to specify the path:

  loadplugin Mail::SpamAssassin::Plugin::RuleTimingRedis <path-to>/

If your redis server is not listening on configure the address in


Then restart amavisd.

After the first mail was processed the keys for the processed rules should appear in redis:

  $ redis-cli
  redis> KEYS 'sa-timing.*'
     1) "sa-timing.__DRUGS_SLEEP3.count"
     2) "sa-timing.__MAIL_LINK.count"
     3) "sa-timing.__CGATE_RCVD.count"


The plugin has the following configuration options:

timing_redis_server (default: '')

Address and port of the redis server.

timing_redis_password (default: no password)

Set if you redis server requires a password.

timing_redis_exclude_re (default: '^__')

Regex to exclude rules from timing statistics.

The current SpamAssassin ruleset is about ~2k rules. The default will exclude all sub-rules that start with '__' (two underscores).

Set to empty string if you really want to measure all rules.

timing_redis_prefix (default: 'sa-timing.')

Prefix to used for the keys in redis.

timing_redis_database (default: 0)

Will call SELECT to switch database after connect if set to a non-zero value.

Database 0 is the default in redis.

timing_redis_precision (default: 1000000)

Since redis uses integers the floating point value is multiplied by this factor before storing in redis.

timing_redis_bulk_update (default: 50)

Will queue redis updates up to the configured value and execute them in bulks via a server-side script.

Requires a redis server >= 2.6.0 and Redis perl module >= 1.954.

Set to 0 to disable bulk.

timing_redis_debug (default: 0)

Turn on/off debug on the Redis connection.

timing_redis_hits_enabled (default: 0)

If enabled for each test that matched an counter will be incremented in the redis database.> keys *.hits
   1) "sa-timing.MISSING_SUBJECT.hits"
   2) "sa-timing.MISSING_MID.hits"
   3) "sa-timing.NO_RELAYS.hits"> GET "sa-timing.MISSING_SUBJECT.hits"


Markus Benning <>


This software is Copyright (c) 2015 by Markus Benning.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004