(self, name, config)
return '{0:d} events tagged for [{1:s}]'.format(event_counter, name)
Tag and add emojis to events.

        Args:
            name: String with the name describing what will be tagged.
            config: A dict that contains the configuration See data/tags.yaml
                for fields and documentation of what needs to be defined.

        Returns:
            String with summary of the analyzer result.
Tag and add emojis to events.
Tag and add emojis to events .
def tagger(self, name, config):
        """Tag and add emojis to events.

        Args:
            name: String with the name describing what will be tagged.
            config: A dict that contains the configuration See data/tags.yaml
                for fields and documentation of what needs to be defined.

        Returns:
            String with summary of the analyzer result.
        """
        query = config.get('query_string')
        query_dsl = config.get('query_dsl')
        save_search = config.get('save_search', False)
        # For legacy reasons to support both save_search and
        # create_view parameters.
        if not save_search:
            save_search = config.get('create_view', False)

        search_name = config.get('search_name', None)
        # For legacy reasons to support both search_name and view_name.
        if search_name is None:
            search_name = config.get('view_name', name)

        tags = config.get('tags', [])
        emoji_names = config.get('emojis', [])
        emojis_to_add = [emojis.get_emoji(x) for x in emoji_names]

        expression_string = config.get('regular_expression', '')
        attributes = None
        expression = None
        if expression_string:
            expression = utils.compile_regular_expression(
                expression_string=expression_string,
                expression_flags=config.get('re_flags'))

            attribute = config.get('re_attribute')
            if attribute:
                attributes = [attribute]

        event_counter = 0
        events = self.event_stream(
            query_string=query, query_dsl=query_dsl, return_fields=attributes)

        for event in events:
            if expression:
                value = event.source.get(attributes[0])
                if value:
                    result = expression.findall(value)
                    if not result:
                        # Skip counting this tag since the regular expression
                        # didn't find anything.
                        continue

            event_counter += 1
            event.add_tags(tags)
            event.add_emojis(emojis_to_add)

            # Commit the event to the datastore.
            event.commit()

        if save_search and event_counter:
            self.sketch.add_view(
                search_name, self.NAME, query_string=query, query_dsl=query_dsl)

        return '{0:d} events tagged for [{1:s}]'.format(event_counter, name)
def tagger ( self , name , config ) : query = config . get ( 'query_string' ) query_dsl = config . get ( 'query_dsl' ) save_search = config . get ( 'save_search' , False ) # For legacy reasons to support both save_search and # create_view parameters. if not save_search : save_search = config . get ( 'create_view' , False ) search_name = config . get ( 'search_name' , None ) # For legacy reasons to support both search_name and view_name. if search_name is None : search_name = config . get ( 'view_name' , name ) tags = config . get ( 'tags' , [ ] ) emoji_names = config . get ( 'emojis' , [ ] ) emojis_to_add = [ emojis . get_emoji ( x ) for x in emoji_names ] expression_string = config . get ( 'regular_expression' , '' ) attributes = None expression = None if expression_string : expression = utils . compile_regular_expression ( expression_string = expression_string , expression_flags = config . get ( 're_flags' ) ) attribute = config . get ( 're_attribute' ) if attribute : attributes = [ attribute ] event_counter = 0 events = self . event_stream ( query_string = query , query_dsl = query_dsl , return_fields = attributes ) for event in events : if expression : value = event . source . get ( attributes [ 0 ] ) if value : result = expression . findall ( value ) if not result : # Skip counting this tag since the regular expression # didn't find anything. continue event_counter += 1 event . add_tags ( tags ) event . add_emojis ( emojis_to_add ) # Commit the event to the datastore. event . commit ( ) if save_search and event_counter : self . sketch . add_view ( search_name , self . NAME , query_string = query , query_dsl = query_dsl ) return '{0:d} events tagged for [{1:s}]' . format ( event_counter , name )