mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-09-06 05:57:58 +00:00
6.4.0
Add ``number_of_shards`` and ``number_of_replicas`` to as possible options in the ``elasticsearch`` configuration file section (see issue #78)
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
6.4.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Add ``number_of_shards`` and ``number_of_replicas`` to as possible options
|
||||||
|
in the ``elasticsearch`` configuration file section (closes issue #78)
|
||||||
|
|
||||||
6.3.7
|
6.3.7
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ The full set of configuration options are:
|
|||||||
- ``cert_path`` - str: Path to a trusted certificates
|
- ``cert_path`` - str: Path to a trusted certificates
|
||||||
- ``index_suffix`` - str: A suffix to apply to the index names
|
- ``index_suffix`` - str: A suffix to apply to the index names
|
||||||
- ``monthly_indexes`` - bool: Use monthly indexes instead of daily indexes
|
- ``monthly_indexes`` - bool: Use monthly indexes instead of daily indexes
|
||||||
|
- ``number_of_shards`` - int: The number of shards to use when creating the index (Default: 1)
|
||||||
|
- ``number_of_replicas`` - int: The number of replicas to use when creating the index (Default: 1)
|
||||||
- ``splunk_hec``
|
- ``splunk_hec``
|
||||||
- ``url`` - str: The URL of the Splunk HTTP Events Collector (HEC)
|
- ``url`` - str: The URL of the Splunk HTTP Events Collector (HEC)
|
||||||
- ``token`` - str: The HEC token
|
- ``token`` - str: The HEC token
|
||||||
|
|||||||
@@ -6,3 +6,6 @@ debug = True
|
|||||||
[elasticsearch]
|
[elasticsearch]
|
||||||
hosts = http://localhost:9200
|
hosts = http://localhost:9200
|
||||||
ssl = False
|
ssl = False
|
||||||
|
number_of_shards=2
|
||||||
|
number_of_replicas=2
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ from parsedmarc.utils import is_outlook_msg, convert_outlook_msg
|
|||||||
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
|
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
|
||||||
from parsedmarc.utils import parse_email
|
from parsedmarc.utils import parse_email
|
||||||
|
|
||||||
__version__ = "6.3.7"
|
__version__ = "6.4.0"
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='%(levelname)8s:%(filename)s:%(lineno)d:'
|
format='%(levelname)8s:%(filename)s:%(lineno)d:'
|
||||||
|
|||||||
+21
-2
@@ -80,10 +80,15 @@ def _main():
|
|||||||
for report in reports_["aggregate_reports"]:
|
for report in reports_["aggregate_reports"]:
|
||||||
try:
|
try:
|
||||||
if opts.elasticsearch_hosts:
|
if opts.elasticsearch_hosts:
|
||||||
|
shards = opts.elasticsearch_number_of_shards
|
||||||
|
replicas = opts.elasticsearch_number_of_replicas
|
||||||
elastic.save_aggregate_report_to_elasticsearch(
|
elastic.save_aggregate_report_to_elasticsearch(
|
||||||
report,
|
report,
|
||||||
index_suffix=opts.elasticsearch_index_suffix,
|
index_suffix=opts.elasticsearch_index_suffix,
|
||||||
monthly_indexes=opts.elasticsearch_monthly_indexes)
|
monthly_indexes=opts.elasticsearch_monthly_indexes,
|
||||||
|
number_of_shards=shards,
|
||||||
|
number_of_replicas=replicas
|
||||||
|
)
|
||||||
except elastic.AlreadySaved as warning:
|
except elastic.AlreadySaved as warning:
|
||||||
logger.warning(warning.__str__())
|
logger.warning(warning.__str__())
|
||||||
except elastic.ElasticsearchError as error_:
|
except elastic.ElasticsearchError as error_:
|
||||||
@@ -107,11 +112,15 @@ def _main():
|
|||||||
if opts.save_forensic:
|
if opts.save_forensic:
|
||||||
for report in reports_["forensic_reports"]:
|
for report in reports_["forensic_reports"]:
|
||||||
try:
|
try:
|
||||||
|
shards = opts.elasticsearch_number_of_shards
|
||||||
|
replicas = opts.elasticsearch_number_of_replicas
|
||||||
if opts.elasticsearch_hosts:
|
if opts.elasticsearch_hosts:
|
||||||
elastic.save_forensic_report_to_elasticsearch(
|
elastic.save_forensic_report_to_elasticsearch(
|
||||||
report,
|
report,
|
||||||
index_suffix=opts.elasticsearch_index_suffix,
|
index_suffix=opts.elasticsearch_index_suffix,
|
||||||
monthly_indexes=opts.elasticsearch_monthly_indexes)
|
monthly_indexes=opts.elasticsearch_monthly_indexes,
|
||||||
|
number_of_shards=shards,
|
||||||
|
number_of_replicas=replicas)
|
||||||
except elastic.AlreadySaved as warning:
|
except elastic.AlreadySaved as warning:
|
||||||
logger.warning(warning.__str__())
|
logger.warning(warning.__str__())
|
||||||
except elastic.ElasticsearchError as error_:
|
except elastic.ElasticsearchError as error_:
|
||||||
@@ -195,6 +204,8 @@ def _main():
|
|||||||
hec_index=None,
|
hec_index=None,
|
||||||
hec_skip_certificate_verification=False,
|
hec_skip_certificate_verification=False,
|
||||||
elasticsearch_hosts=None,
|
elasticsearch_hosts=None,
|
||||||
|
elasticsearch_number_of_shards=1,
|
||||||
|
elasticsearch_number_of_replicas=1,
|
||||||
elasticsearch_index_suffix=None,
|
elasticsearch_index_suffix=None,
|
||||||
elasticsearch_ssl=True,
|
elasticsearch_ssl=True,
|
||||||
elasticsearch_ssl_cert_path=None,
|
elasticsearch_ssl_cert_path=None,
|
||||||
@@ -303,6 +314,14 @@ def _main():
|
|||||||
logger.critical("hosts setting missing from the "
|
logger.critical("hosts setting missing from the "
|
||||||
"elasticsearch config section")
|
"elasticsearch config section")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
if "number_of_shards" in elasticsearch_config:
|
||||||
|
number_of_shards = elasticsearch_config.getint(
|
||||||
|
"number_of_shards")
|
||||||
|
opts.elasticsearch_number_of_shards = number_of_shards
|
||||||
|
if "number_of_replicas" in elasticsearch_config:
|
||||||
|
number_of_replicas = elasticsearch_config.getint(
|
||||||
|
"number_of_replicas")
|
||||||
|
opts.elasticsearch_number_of_replicas = number_of_replicas
|
||||||
if "index_suffix" in elasticsearch_config:
|
if "index_suffix" in elasticsearch_config:
|
||||||
opts.elasticsearch_index_suffix = elasticsearch_config[
|
opts.elasticsearch_index_suffix = elasticsearch_config[
|
||||||
"index_suffix"]
|
"index_suffix"]
|
||||||
|
|||||||
+17
-4
@@ -271,7 +271,9 @@ def migrate_indexes(aggregate_indexes=None, forensic_indexes=None):
|
|||||||
|
|
||||||
def save_aggregate_report_to_elasticsearch(aggregate_report,
|
def save_aggregate_report_to_elasticsearch(aggregate_report,
|
||||||
index_suffix=None,
|
index_suffix=None,
|
||||||
monthly_indexes=False):
|
monthly_indexes=False,
|
||||||
|
number_of_shards=1,
|
||||||
|
number_of_replicas=1):
|
||||||
"""
|
"""
|
||||||
Saves a parsed DMARC aggregate report to ElasticSearch
|
Saves a parsed DMARC aggregate report to ElasticSearch
|
||||||
|
|
||||||
@@ -279,6 +281,8 @@ def save_aggregate_report_to_elasticsearch(aggregate_report,
|
|||||||
aggregate_report (OrderedDict): A parsed forensic report
|
aggregate_report (OrderedDict): A parsed forensic report
|
||||||
index_suffix (str): The suffix of the name of the index to save to
|
index_suffix (str): The suffix of the name of the index to save to
|
||||||
monthly_indexes (bool): Use monthly indexes instead of daily indexes
|
monthly_indexes (bool): Use monthly indexes instead of daily indexes
|
||||||
|
number_of_shards (int): The number of shards to use in the index
|
||||||
|
number_of_replicas (int): The number of replicas to use in the index
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
AlreadySaved
|
AlreadySaved
|
||||||
@@ -374,7 +378,9 @@ def save_aggregate_report_to_elasticsearch(aggregate_report,
|
|||||||
if index_suffix:
|
if index_suffix:
|
||||||
index = "{0}_{1}".format(index, index_suffix)
|
index = "{0}_{1}".format(index, index_suffix)
|
||||||
index = "{0}-{1}".format(index, index_date)
|
index = "{0}-{1}".format(index, index_date)
|
||||||
create_indexes([index])
|
index_settings = dict(number_of_shards=number_of_shards,
|
||||||
|
number_of_replicas=number_of_replicas)
|
||||||
|
create_indexes([index], index_settings)
|
||||||
agg_doc.meta.index = index
|
agg_doc.meta.index = index
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -386,7 +392,9 @@ def save_aggregate_report_to_elasticsearch(aggregate_report,
|
|||||||
|
|
||||||
def save_forensic_report_to_elasticsearch(forensic_report,
|
def save_forensic_report_to_elasticsearch(forensic_report,
|
||||||
index_suffix=None,
|
index_suffix=None,
|
||||||
monthly_indexes=False):
|
monthly_indexes=False,
|
||||||
|
number_of_shards=1,
|
||||||
|
number_of_replicas=1):
|
||||||
"""
|
"""
|
||||||
Saves a parsed DMARC forensic report to ElasticSearch
|
Saves a parsed DMARC forensic report to ElasticSearch
|
||||||
|
|
||||||
@@ -395,6 +403,9 @@ def save_forensic_report_to_elasticsearch(forensic_report,
|
|||||||
index_suffix (str): The suffix of the name of the index to save to
|
index_suffix (str): The suffix of the name of the index to save to
|
||||||
monthly_indexes (bool): Use monthly indexes instead of daily
|
monthly_indexes (bool): Use monthly indexes instead of daily
|
||||||
indexes
|
indexes
|
||||||
|
number_of_shards (int): The number of shards to use in the index
|
||||||
|
number_of_replicas (int): The number of replicas to use in the
|
||||||
|
index
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
AlreadySaved
|
AlreadySaved
|
||||||
@@ -505,7 +516,9 @@ def save_forensic_report_to_elasticsearch(forensic_report,
|
|||||||
else:
|
else:
|
||||||
index_date = arrival_date.strftime("%Y-%m-%d")
|
index_date = arrival_date.strftime("%Y-%m-%d")
|
||||||
index = "{0}-{1}".format(index, index_date)
|
index = "{0}-{1}".format(index, index_date)
|
||||||
create_indexes([index])
|
index_settings = dict(number_of_shards=number_of_shards,
|
||||||
|
number_of_replicas=number_of_replicas)
|
||||||
|
create_indexes([index], index_settings)
|
||||||
forensic_doc.meta.index = index
|
forensic_doc.meta.index = index
|
||||||
try:
|
try:
|
||||||
forensic_doc.save()
|
forensic_doc.save()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from setuptools import setup
|
|||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
__version__ = "6.3.7"
|
__version__ = "6.4.0"
|
||||||
|
|
||||||
description = "A Python package and CLI for parsing aggregate and " \
|
description = "A Python package and CLI for parsing aggregate and " \
|
||||||
"forensic DMARC reports"
|
"forensic DMARC reports"
|
||||||
|
|||||||
Reference in New Issue
Block a user