Example #1
0
    def setUp(self):
        self.conf = MagicMock()
        self.conf.liblognorm = MagicMock()
        self.conf.liblognorm.rules_dir = '../etc/meniscus/normalizer_rules'

        self.normalizer, self.loaded_rules = get_normalizer(self.conf)
Example #2
0
from meniscus import env
from meniscus.queue import celery
from meniscus.normalization.lognorm import get_normalizer
from meniscus import sinks
import json


_LOG = env.get_logger(__name__)
_normalizer, loaded_normalizer_rules = get_normalizer()


def should_normalize(message):
    """Returns true only if the pattern is in the loaded rules
    list and there is a string msg in the message dictionary"""
    should_normalize = (
        message['meniscus']['correlation']['pattern'] in
        loaded_normalizer_rules)
    can_normalize = ('msg' in message)
    return should_normalize and can_normalize


@celery.task(acks_late=True, max_retries=None, serializer="json")
def normalize_message(message):
    """
    This code takes a message and normalizes it into a dictionary. This
    normalized dictionary is assigned to a field matching the pattern name
    of the normalization. This dictionary is then assigned to the message
    under the normalized field.
    """
    pattern = message['meniscus']['correlation']['pattern']
    normalized_doc = json.loads(
Example #3
0
from meniscus.queue import celery
from meniscus.normalization.lognorm import get_normalizer
from meniscus import env
import json


_LOG = env.get_logger(__name__)
_normalizer, loaded_normalizer_rules = get_normalizer()


def should_normalize(message):
    """Returns true only if the pattern is in the loaded rules
    list and there is a string msg in the message dictionary"""
    should_normalize = (
        message['meniscus']['correlation']['pattern'] in
        loaded_normalizer_rules)
    can_normalize = ('msg' in message)
    return should_normalize and can_normalize


@celery.task(acks_late=True, max_retries=None, serializer="json")
def normalize_message(message):
    """
    This code takes a message and normalizes it into a dictionary. This
    normalized dictionary is assigned to a field matching the pattern name
    of the normalization. This dictionary is then assigned to the message
    under the normalized field.
    """
    pattern = message['meniscus']['correlation']['pattern']
    normalized_doc = json.loads(
        _normalizer.normalize(message['msg']).as_json())
Example #4
0
    def setUp(self):
        self.conf = MagicMock()
        self.conf.liblognorm = MagicMock()
        self.conf.liblognorm.rules_dir = '../etc/meniscus/normalizer_rules'

        self.normalizer, self.loaded_rules = get_normalizer(self.conf)