diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-20 13:16:32 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-20 17:23:29 +0000 |
commit | fa755df042314db185d4b213373044702512fa77 (patch) | |
tree | a2b91cb4642f40290699930b0593c3f9f894da2b /src | |
parent | 2993c04b809650933446bf0d23621b8dc4e2cb6a (diff) | |
download | rspamd-fa755df042314db185d4b213373044702512fa77.tar.gz rspamd-fa755df042314db185d4b213373044702512fa77.zip |
[Feature] Use templates when publishing CH schema
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/clickhouse.lua | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 16b987df6..2735f2ade 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -50,7 +50,9 @@ local settings = { table = 'rspamd', attachments_table = 'rspamd_attachments', urls_table = 'rspamd_urls', + emails_table = 'rspamd_emails', symbols_table = 'rspamd_symbols', + asn_table = 'rspamd_asn', ipmask = 19, ipmask6 = 48, full_urls = false, @@ -63,7 +65,7 @@ local settings = { local clickhouse_schema = { rspamd = [[ -CREATE TABLE IF NOT EXISTS rspamd +CREATE TABLE IF NOT EXISTS ${table} ( Date Date, TS DateTime, @@ -91,7 +93,7 @@ CREATE TABLE IF NOT EXISTS rspamd ]], attachments = [[ -CREATE TABLE IF NOT EXISTS rspamd_attachments ( +CREATE TABLE IF NOT EXISTS ${attachments_table} ( Date Date, Digest FixedString(32), `Attachments.FileName` Array(String), @@ -102,7 +104,7 @@ CREATE TABLE IF NOT EXISTS rspamd_attachments ( ]], urls = [[ -CREATE TABLE IF NOT EXISTS rspamd_urls ( +CREATE TABLE IF NOT EXISTS ${urls_table} ( Date Date, Digest FixedString(32), `Urls.Tld` Array(String), @@ -110,8 +112,16 @@ CREATE TABLE IF NOT EXISTS rspamd_urls ( ) ENGINE = MergeTree(Date, Digest, 8192) ]], + emails = [[ +CREATE TABLE IF NOT EXISTS ${emails_table} ( + Date Date, + Digest FixedString(32), + `Emails` Array(String), +) ENGINE = MergeTree(Date, Digest, 8192) +]], + asn = [[ -CREATE TABLE IF NOT EXISTS rspamd_asn ( +CREATE TABLE IF NOT EXISTS ${asn_table} ( Date Date, Digest FixedString(32), ASN String, @@ -121,7 +131,7 @@ CREATE TABLE IF NOT EXISTS rspamd_asn ( ]], symbols = [[ -CREATE TABLE IF NOT EXISTS rspamd_symbols ( +CREATE TABLE IF NOT EXISTS ${symbols_table} ( Date Date, Digest FixedString(32), `Symbols.Names` Array(String), @@ -720,7 +730,7 @@ if opts then end for tab,sql in pairs(clickhouse_schema) do - send_req(tab, sql) + send_req(tab, rspamd_lua_utils.template(sql, settings)) end end end |