elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

0 hits ES 5.6.2 no query hits

Open sathishdsgithub opened this issue 9 years ago • 21 comments

I'm tryinig to run elastalert with ES version 5.x . I have copied my yaml rule and config.yaml and ES version and ES index data format. Please assist I get 0 hits when I run elastalert

ElasticSearch version details below

  "cluster_uuid" : "WBJrU1DoTKuhBZs9GJDczg",
  "version" : {
    "number" : "5.6.2",
    "build_hash" : "57e20f3",
    "build_date" : "2017-09-23T13:16:45.703Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"

Elasticsearch data format

[root@ladcsealert01 elastalert]# curl -XGET "http://10.50.XX:9200/firewalls_*/message/_search?pretty"
{
  "took" : 3078,
  "timed_out" : false,
  "num_reduce_phases" : 2,
  "_shards" : {
    "total" : 600,
    "successful" : 600,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1528782218,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "firewalls_1390",
        "_type" : "message",
        "_id" : "df84f177-d150-11e7-8201-1866dae8a558",
        "_score" : 1.0,
        "_source" : {
          "srx-nat-source-address" : "10.50.XX",
          "gl2_remote_ip" : "10.191.XX",
          "srx-destination-address" : "10.15.XX",
          "gl2_remote_port" : 35353,
          "source" : "10.42.XX",
          "gl2_source_input" : "57fd0f0aa345205031b18652",
          "srx-ip-address" : "10.42.XX",
          "srx-destination-port" : "161",
          "srx-nat-source-port" : "42282",
          "srx-source-zone-name" : "T_XX",
          "gl2_source_node" : "1037c649-ea01-42cb-9cb0-1f462b6e7618",
          "srx-reason" : "idle Timeout",
          "srx-service-name" : "None",
          "srx-source-nat-rule-name" : "N/A",
          "srx-src-nat-rule-type" : "N/A",
          "srx-roles" : "N/A",
          "srx-packets-from-client" : "38",
          "srx-protocol-id" : "17",
          "timestamp" : "2017-11-24 19:51:33.000",
          "srx-application" : "UNKNOWN",
          "srx-session-id-32" : "10690079",
          "srx-nat-destination-port" : "161",
          "srx-destination-nat-rule-name" : "N/A",
          "level" : 6,
          "srx-packets-from-server" : "38",
          "streams" : [
            "57fd0f28a345205031b18676"
          ],
          "srx-username" : "N/A",
          "TCHInput" : "SRX-12208-TCP",
          "srx-bytes-from-client" : "3524",
          "srx-dst-nat-rule-type" : "N/A",
          "message" : "10.42.XX Nov 24 19:51:31 10.42.255.255 1 2017-11-24T19:51:30.677Z  RT_FLOW - RT_FLOW_SESSION_CLOSE [[email protected] reason=\"idle Timeout\" source-address=\"10.50.XX\" source-port=\"42282\" destination-address=\"10.15.XX1\" destination-port=\"161\" service-name=\"None\" nat-source-address=\"10.50.XX\" nat-source-port=\"42282\" nat-destination-address=\"10.15.XX\" nat-destination-port=\"161\" src-nat-rule-type=\"N/A\" src-nat-rule-name=\"N/A\" dst-nat-rule-type=\"N/A\" dst-nat-rule-name=\"N/A\" protocol-id=\"17\" policy-name=\"G_XX (global)\" source-zone-name=\"T_SHARED\" destination-zone-name=\"CORPORATE\" session-id-32=\"10690079\" packets-from-client=\"38\" bytes-from-client=\"3524\" packets-from-server=\"38\" bytes-from-server=\"5030\" elapsed-time=\"63\" application=\"UNKNOWN\" nested-application=\"UNKNOWN\" username=\"N/A\" roles=\"N/A\" packet-incoming-interface=\"reth0.217\" encrypted=\"UNKNOWN\"]",
          "srx-bytes-from-server" : "5030",
          "srx-elapsed-time" : "63",
          "srx-nat-destination-address" : "10.XX",
          "srx-encrypted" : "UNKNOWN",
          "srx-source-port" : "42282",
          "srx-policy-name" : "G_NETWORK_XX(global)",
          "srx-rt-flow" : "RT_FLOW_SESSION_CLOSE",
          "srx-destination-zone-name" : "CORPORATE",
          "facility" : "user-level",
          "srx-nested-application" : "UNKNOWN",
          "srx-source-address" : "10.50.XX",
          "srx-packet-incoming-interface" : "reth0.217"
        }
      },

ElastAlert YAML Rule


# ElastAlert Rule Name

name:  Test Port Scan detection use case

# ElasticSearch Index Name

index: firewalls*

# Timestamp added to overcome ES graylog parsing issue

timestamp_field: timestamp
timestamp_field: created
timestamp_format: '%Y-%m-%d %H:%M:%S.%f'
timestamp_format_expr: 'ts[:23] + ts[26:]'


doc_type: message
# Network Port scan aggregation Rule 250 counts in 60 Seconds

type: cardinality

query_key: [srx-source-address, srx-destination-address]
cardinality_field: "srx-destination-port"
max_cardinality: 250

timeframe:
   hours: 1

filter:
 - query_string:
      query: "srx-rt-flow: RT_FLOW_SESSION_DENY"

#import:
#  - filter-whitelist-ip
#  - filter-whitelist-zone


# Combine multiple events and aggreagate the event for 2 minutes


aggregation:

   minutes: 5

# Aggregate the events based on the specfic field parameter

aggregation_key: 'srx-source-address'

############### Email Alert Configuration SMTP #############################

alert:
 - "email"
smtp_host: smtpio.XX
smtp_port: 25
smtp_ssl : false
from_addr: "Elastalert@XX"


# Email will be sent to bewlo Rcpt

email:

#    -  "[email protected]"

# Email will contain following Subject TAG and Body message


alert_subject: "Port Scan activity detected between Source {0} and Destination {1} @ {2}"

alert_subject_args:

  - srx-source-address
  - srx-destination-address
  - timestamp


html_table_title: "<h3> Network Port Scan has been detected </h3> <p style='color:#4169E1;' style=font-family:verdana> Hi Team <br/><br/> Elastalert has identified a potential Network portscan detection between following source and de
stination IP address, do something about it</p>"

alert_text_type: alert_text_only

alert_text: |

email_type: "html"

summary_table_fields_html:

    - srx-source-address

    - srx-destination-address

    - srx-destination-port

config.yaml rule

# This is the folder that contains the rule yaml files
# Any .yaml file will be loaded as a rule
rules_folder: Rule_folder

# How often ElastAlert will query Elasticsearch
# The unit can be anything from weeks to seconds
run_every:
#  minutes: 5
  seconds: 20
# ElastAlert will buffer results from the most recent
# period of time, in case some log sources are not in real time
buffer_time:
#  minutes: 45
#  hours: 6
   days: 1
#query_delay:
#  hours: 1
# The Elasticsearch hostname for metadata writeback
# Note that every rule can have its own Elasticsearch host
es_host: 10.XXX

# The Elasticsearch port
es_port: 9200

max_query_size: 50000
# The AWS region to use. Set this when using AWS-managed elasticsearch
#aws_region: us-east-1

# The AWS profile to use. Use this if you are using an aws-cli profile.
# See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
# for details
#profile: test

# Optional URL prefix for Elasticsearch
#es_url_prefix: elasticsearch

# Connect with TLS to Elasticsearch
#use_ssl: True

# Verify TLS certificates
#verify_certs: True
#use_count_query: true
# GET request with body is the default option for Elasticsearch.
# If it fails for some reason, you can pass 'GET', 'POST' or 'source'.
# See http://elasticsearch-py.readthedocs.io/en/master/connection.html?highlight=send_get_body_as#transport
# for details
#es_send_get_body_as: GET

# Option basic-auth username and password for Elasticsearch
#es_username: someusername
#es_password: somepassword

# Use SSL authentication with client certificates client_cert must be
# a pem file containing both cert and key for client
#verify_certs: True
#ca_certs: /path/to/cacert.pem
#client_cert: /path/to/client_cert.pem
#client_key: /path/to/client_key.key

# The index on es_host which is used for metadata storage
# This can be a unmapped index, but it is recommended that you run
# elastalert-create-index to set a mapping
writeback_index: elastalert_status

# If an alert fails for some reason, ElastAlert will retry
# sending the alert until this time period has elapsed
#alert_time_limit:
#  days: 0

Config.py configuration

# -*- coding: utf-8 -*-
import copy
import datetime
import hashlib
import logging
import os
import sys

import alerts
import enhancements
import jsonschema
import ruletypes
import yaml
import yaml.scanner
from opsgenie import OpsGenieAlerter
from staticconf.loader import yaml_loader
from util import dt_to_ts
from util import dt_to_ts_with_format
from util import dt_to_unix
from util import dt_to_unixms
from util import EAException
from util import ts_to_dt
from util import ts_to_dt_with_format
from util import unix_to_dt
from util import unixms_to_dt

# schema for rule yaml
rule_schema = jsonschema.Draft4Validator(yaml.load(open(os.path.join(os.path.dirname(__file__), 'schema.yaml'))))

# Required global (config.yaml) and local (rule.yaml)  configuration options
required_globals = frozenset(['run_every', 'rules_folder', 'es_host', 'es_port', 'writeback_index', 'buffer_time'])
required_locals = frozenset(['alert', 'type', 'name', 'index'])

# Settings that can be derived from ENV variables
env_settings = {'ES_USE_SSL': 'use_ssl',
                'ES_PASSWORD': 'es_password',
                'ES_USERNAME': 'es_username',
                'ES_HOST': 'es_host',
                'ES_PORT': 'es_port'}

# Used to map the names of rules to their classes
rules_mapping = {
    'frequency': ruletypes.FrequencyRule,
    'any': ruletypes.AnyRule,
    'spike': ruletypes.SpikeRule,
    'blacklist': ruletypes.BlacklistRule,
    'whitelist': ruletypes.WhitelistRule,
    'change': ruletypes.ChangeRule,
    'flatline': ruletypes.FlatlineRule,
    'new_term': ruletypes.NewTermsRule,
    'cardinality': ruletypes.CardinalityRule,
    'metric_aggregation': ruletypes.MetricAggregationRule,
    'percentage_match': ruletypes.PercentageMatchRule,
}

# Used to map names of alerts to their classes
alerts_mapping = {
    'email': alerts.EmailAlerter,
    'jira': alerts.JiraAlerter,
    'opsgenie': OpsGenieAlerter,
    'stomp': alerts.StompAlerter,
    'debug': alerts.DebugAlerter,
    'command': alerts.CommandAlerter,
    'sns': alerts.SnsAlerter,
    'hipchat': alerts.HipChatAlerter,
    'ms_teams': alerts.MsTeamsAlerter,
    'slack': alerts.SlackAlerter,
    'pagerduty': alerts.PagerDutyAlerter,
    'exotel': alerts.ExotelAlerter,
    'twilio': alerts.TwilioAlerter,
    'victorops': alerts.VictorOpsAlerter,
    'telegram': alerts.TelegramAlerter,
    'gitter': alerts.GitterAlerter,
    'servicenow': alerts.ServiceNowAlerter,
    'post': alerts.HTTPPostAlerter
}
# A partial ordering of alert types. Relative order will be preserved in the resulting alerts list
# For example, jira goes before email so the ticket # will be added to the resulting email.
alerts_order = {
    'jira': 0,
    'email': 1
}

base_config = {}


def get_module(module_name):
    """ Loads a module and returns a specific object.
    module_name should 'module.file.object'.
    Returns object or raises EAException on error. """
    try:
        module_path, module_class = module_name.rsplit('.', 1)
        base_module = __import__(module_path, globals(), locals(), [module_class])
        module = getattr(base_module, module_class)
    except (ImportError, AttributeError, ValueError) as e:
        raise EAException("Could not import module %s: %s" % (module_name, e)), None, sys.exc_info()[2]
    return module


def load_configuration(filename, conf, args=None):
    """ Load a yaml rule file and fill in the relevant fields with objects.

    :param filename: The name of a rule configuration file.
    :param conf: The global configuration dictionary, used for populating defaults.
    :return: The rule configuration, a dictionary.
    """
    rule = load_rule_yaml(filename)
    load_options(rule, conf, filename, args)
    load_modules(rule, args)
    return rule


def load_rule_yaml(filename):
    return add_rule_yaml(filename, {'rule_file': filename})


def add_rule_yaml(filename, parent_rule):
    try:
        loaded_rule = yaml_loader(filename)
    except yaml.scanner.ScannerError as e:
        raise EAException('Could not parse file %s: %s' % (filename, e))

    if 'import' in loaded_rule:
        current_import = loaded_rule['import']
        del(loaded_rule['import'])  # or we could go on forever!

        child_rules = {}
        if isinstance(current_import, basestring):
            child_rules = add_rule_yaml(rule_file_import_path_to_absolute_path(filename, current_import), child_rules)
        elif isinstance(current_import, list):
            for import_target in current_import:
                child_rules = add_rule_yaml(rule_file_import_path_to_absolute_path(filename, import_target), child_rules)
        loaded_rule = merge_rules(loaded_rule, child_rules)

    loaded_rule = merge_rules(parent_rule, loaded_rule)
    return loaded_rule


def merge_rules(parent_rule, child_rule):
    # Special case for merging filters - if both files specify a filter merge (AND) them
    merged_filter = None
    if 'filter' in parent_rule and 'filter' in child_rule:
        merged_filter = child_rule['filter'] + parent_rule['filter']

    child_rule.update(parent_rule)
    if merged_filter is not None:
        child_rule['filter'] = merged_filter

    return child_rule


def rule_file_import_path_to_absolute_path(currently_parsed_file_path, import_file_path):
    if os.path.isabs(import_file_path):
        return import_file_path
    else:
        return os.path.join(os.path.dirname(currently_parsed_file_path), import_file_path)


def load_options(rule, conf, filename, args=None):
    """ Converts time objects, sets defaults, and validates some settings.

    :param rule: A dictionary of parsed YAML from a rule config file.
    :param conf: The global configuration dictionary, used for populating defaults.
    """
    adjust_deprecated_values(rule)

    try:
        rule_schema.validate(rule)
    except jsonschema.ValidationError as e:
        raise EAException("Invalid Rule file: %s\n%s" % (filename, e))

    try:
        # Set all time based parameters
        if 'timeframe' in rule:
            rule['timeframe'] = datetime.timedelta(**rule['timeframe'])
        if 'realert' in rule:
            rule['realert'] = datetime.timedelta(**rule['realert'])
        else:
            if 'aggregation' in rule:
                rule['realert'] = datetime.timedelta(minutes=0)
            else:
                rule['realert'] = datetime.timedelta(minutes=1)
        if 'aggregation' in rule and not rule['aggregation'].get('schedule'):
            rule['aggregation'] = datetime.timedelta(**rule['aggregation'])
        if 'query_delay' in rule:
            rule['query_delay'] = datetime.timedelta(**rule['query_delay'])
        if 'buffer_time' in rule:
            rule['buffer_time'] = datetime.timedelta(**rule['buffer_time'])
        if 'bucket_interval' in rule:
            rule['bucket_interval_timedelta'] = datetime.timedelta(**rule['bucket_interval'])
        if 'exponential_realert' in rule:
            rule['exponential_realert'] = datetime.timedelta(**rule['exponential_realert'])
        if 'kibana4_start_timedelta' in rule:
            rule['kibana4_start_timedelta'] = datetime.timedelta(**rule['kibana4_start_timedelta'])
        if 'kibana4_end_timedelta' in rule:
            rule['kibana4_end_timedelta'] = datetime.timedelta(**rule['kibana4_end_timedelta'])
    except (KeyError, TypeError) as e:
        raise EAException('Invalid time format used: %s' % (e))

    # Set defaults, copy defaults from config.yaml
    for key, val in base_config.items():
        rule.setdefault(key, val)
    rule.setdefault('name', os.path.splitext(filename)[0])
    rule.setdefault('realert', datetime.timedelta(seconds=0))
    rule.setdefault('aggregation', datetime.timedelta(seconds=0))
    rule.setdefault('query_delay', datetime.timedelta(seconds=0))
    rule.setdefault('timestamp_field', '@timestamp')
    rule.setdefault('filter', [])
    rule.setdefault('timestamp_type', 'iso')
    rule.setdefault('timestamp_format', '%Y-%m-%dT%H:%M:%SZ')
    rule.setdefault('_source_enabled', True)
    rule.setdefault('use_local_time', True)
    rule.setdefault('description', "")

    # Set timestamp_type conversion function, used when generating queries and processing hits
    rule['timestamp_type'] = rule['timestamp_type'].strip().lower()
    if rule['timestamp_type'] == 'iso':
        rule['ts_to_dt'] = ts_to_dt
        rule['dt_to_ts'] = dt_to_ts
    elif rule['timestamp_type'] == 'unix':
        rule['ts_to_dt'] = unix_to_dt
        rule['dt_to_ts'] = dt_to_unix
    elif rule['timestamp_type'] == 'unix_ms':
        rule['ts_to_dt'] = unixms_to_dt
        rule['dt_to_ts'] = dt_to_unixms
    elif rule['timestamp_type'] == 'custom':
        def _ts_to_dt_with_format(ts):
            return ts_to_dt_with_format(ts, ts_format=rule['timestamp_format'])

        def _dt_to_ts_with_format(dt):
            ts = dt_to_ts_with_format(dt, ts_format=rule['timestamp_format'])
            if 'timestamp_format_expr' in rule:
                # eval expression passing 'ts' and 'dt'
                return eval(rule['timestamp_format_expr'], {'ts': ts, 'dt': dt})
            else:
                return ts

        rule['ts_to_dt'] = _ts_to_dt_with_format
        rule['dt_to_ts'] = _dt_to_ts_with_format
    else:
        raise EAException('timestamp_type must be one of iso, unix, or unix_ms')

    # Set HipChat options from global config
    rule.setdefault('hipchat_msg_color', 'red')
    rule.setdefault('hipchat_domain', 'api.hipchat.com')
    rule.setdefault('hipchat_notify', True)
    rule.setdefault('hipchat_from', '')
    rule.setdefault('hipchat_ignore_ssl_errors', False)

    # Make sure we have required options
    if required_locals - frozenset(rule.keys()):
        raise EAException('Missing required option(s): %s' % (', '.join(required_locals - frozenset(rule.keys()))))

    if 'include' in rule and type(rule['include']) != list:
        raise EAException('include option must be a list')

    if isinstance(rule.get('query_key'), list):
        rule['compound_query_key'] = rule['query_key']
        rule['query_key'] = ','.join(rule['query_key'])

    if isinstance(rule.get('aggregation_key'), list):
        rule['compound_aggregation_key'] = rule['aggregation_key']
        rule['aggregation_key'] = ','.join(rule['aggregation_key'])

    if isinstance(rule.get('compare_key'), list):
        rule['compound_compare_key'] = rule['compare_key']
        rule['compare_key'] = ','.join(rule['compare_key'])
    elif 'compare_key' in rule:
        rule['compound_compare_key'] = [rule['compare_key']]
    # Add QK, CK and timestamp to include
    include = rule.get('include', ['*'])
    if 'query_key' in rule:
        include.append(rule['query_key'])
    if 'compound_query_key' in rule:
        include += rule['compound_query_key']
    if 'compound_aggregation_key' in rule:
        include += rule['compound_aggregation_key']
    if 'compare_key' in rule:
        include.append(rule['compare_key'])
    if 'compound_compare_key' in rule:
        include += rule['compound_compare_key']
    if 'top_count_keys' in rule:
        include += rule['top_count_keys']
    include.append(rule['timestamp_field'])
    rule['include'] = list(set(include))

    # Check that generate_kibana_url is compatible with the filters
    if rule.get('generate_kibana_link'):
        for es_filter in rule.get('filter'):
            if es_filter:
                if 'not' in es_filter:
                    es_filter = es_filter['not']
                if 'query' in es_filter:
                    es_filter = es_filter['query']
                if es_filter.keys()[0] not in ('term', 'query_string', 'range'):
                    raise EAException('generate_kibana_link is incompatible with filters other than term, query_string and range. '
                                      'Consider creating a dashboard and using use_kibana_dashboard instead.')

    # Check that doc_type is provided if use_count/terms_query
    if rule.get('use_count_query') or rule.get('use_terms_query'):
        if 'doc_type' not in rule:
            raise EAException('doc_type must be specified.')

    # Check that query_key is set if use_terms_query
    if rule.get('use_terms_query'):
        if 'query_key' not in rule:
            raise EAException('query_key must be specified with use_terms_query')

    # Warn if use_strf_index is used with %y, %M or %D
    # (%y = short year, %M = minutes, %D = full date)
    if rule.get('use_strftime_index'):
        for token in ['%y', '%M', '%D']:
            if token in rule.get('index'):
                logging.warning('Did you mean to use %s in the index? '
                                'The index will be formatted like %s' % (token,
                                                                         datetime.datetime.now().strftime(rule.get('index'))))


def load_modules(rule, args=None):
    """ Loads things that could be modules. Enhancements, alerts and rule type. """
    # Set match enhancements
    match_enhancements = []
    for enhancement_name in rule.get('match_enhancements', []):
        if enhancement_name in dir(enhancements):
            enhancement = getattr(enhancements, enhancement_name)
        else:
            enhancement = get_module(enhancement_name)
        if not issubclass(enhancement, enhancements.BaseEnhancement):
            raise EAException("Enhancement module %s not a subclass of BaseEnhancement" % (enhancement_name))
        match_enhancements.append(enhancement(rule))
    rule['match_enhancements'] = match_enhancements

    # Convert rule type into RuleType object
    if rule['type'] in rules_mapping:
        rule['type'] = rules_mapping[rule['type']]
    else:
        rule['type'] = get_module(rule['type'])
        if not issubclass(rule['type'], ruletypes.RuleType):
            raise EAException('Rule module %s is not a subclass of RuleType' % (rule['type']))

    # Make sure we have required alert and type options
    reqs = rule['type'].required_options

    if reqs - frozenset(rule.keys()):
        raise EAException('Missing required option(s): %s' % (', '.join(reqs - frozenset(rule.keys()))))
    # Instantiate rule
    try:
        rule['type'] = rule['type'](rule, args)
    except (KeyError, EAException) as e:
        raise EAException('Error initializing rule %s: %s' % (rule['name'], e)), None, sys.exc_info()[2]
    # Instantiate alert
    rule['alert'] = load_alerts(rule, alert_field=rule['alert'])


def isyaml(filename):
    return filename.endswith('.yaml') or filename.endswith('.yml')


def get_file_paths(conf, use_rule=None):
    # Passing a filename directly can bypass rules_folder and .yaml checks
    if use_rule and os.path.isfile(use_rule):
        return [use_rule]
    rule_folder = conf['rules_folder']
    rule_files = []
    if conf['scan_subdirectories']:
        for root, folders, files in os.walk(rule_folder):
            for filename in files:
                if use_rule and use_rule != filename:
                    continue
                if isyaml(filename):
                    rule_files.append(os.path.join(root, filename))
    else:
        for filename in os.listdir(rule_folder):
            fullpath = os.path.join(rule_folder, filename)
            if os.path.isfile(fullpath) and isyaml(filename):
                rule_files.append(fullpath)
    return rule_files


def load_alerts(rule, alert_field):
    def normalize_config(alert):
        """Alert config entries are either "alertType" or {"alertType": {"key": "data"}}.
        This function normalizes them both to the latter format. """
        if isinstance(alert, basestring):
            return alert, rule
        elif isinstance(alert, dict):
            name, config = iter(alert.items()).next()
            config_copy = copy.copy(rule)
            config_copy.update(config)  # warning, this (intentionally) mutates the rule dict
            return name, config_copy
        else:
            raise EAException()

    def create_alert(alert, alert_config):
        alert_class = alerts_mapping.get(alert) or get_module(alert)
        if not issubclass(alert_class, alerts.Alerter):
            raise EAException('Alert module %s is not a subclass of Alerter' % (alert))
        missing_options = (rule['type'].required_options | alert_class.required_options) - frozenset(alert_config or [])
        if missing_options:
            raise EAException('Missing required option(s): %s' % (', '.join(missing_options)))
        return alert_class(alert_config)

    try:
        if type(alert_field) != list:
            alert_field = [alert_field]

        alert_field = [normalize_config(x) for x in alert_field]
        alert_field = sorted(alert_field, key=lambda (a, b): alerts_order.get(a, -1))
        # Convert all alerts into Alerter objects
        alert_field = [create_alert(a, b) for a, b in alert_field]

    except (KeyError, EAException) as e:
        raise EAException('Error initiating alert %s: %s' % (rule['alert'], e)), None, sys.exc_info()[2]

    return alert_field


def load_rules(args):
    """ Creates a conf dictionary for ElastAlerter. Loads the global
    config file and then each rule found in rules_folder.

    :param args: The parsed arguments to ElastAlert
    :return: The global configuration, a dictionary.
    """
    names = []
    filename = args.config
    conf = yaml_loader(filename)
    use_rule = args.rule

    for env_var, conf_var in env_settings.items():
        if env_var in os.environ:
            conf[conf_var] = os.environ[env_var]

    # Make sure we have all required globals
    if required_globals - frozenset(conf.keys()):
        raise EAException('%s must contain %s' % (filename, ', '.join(required_globals - frozenset(conf.keys()))))

    conf.setdefault('max_query_size', 10000)
    conf.setdefault('scroll_keepalive', '30s')
    conf.setdefault('disable_rules_on_error', True)
    conf.setdefault('scan_subdirectories', True)

    # Convert run_every, buffer_time into a timedelta object
    try:
        conf['run_every'] = datetime.timedelta(**conf['run_every'])
        conf['buffer_time'] = datetime.timedelta(**conf['buffer_time'])
        if 'alert_time_limit' in conf:
            conf['alert_time_limit'] = datetime.timedelta(**conf['alert_time_limit'])
        else:
            conf['alert_time_limit'] = datetime.timedelta(days=2)
        if 'old_query_limit' in conf:
            conf['old_query_limit'] = datetime.timedelta(**conf['old_query_limit'])
        else:
            conf['old_query_limit'] = datetime.timedelta(weeks=1)
    except (KeyError, TypeError) as e:
        raise EAException('Invalid time format used: %s' % (e))

    global base_config
    base_config = copy.deepcopy(conf)

    # Load each rule configuration file
    rules = []
    rule_files = get_file_paths(conf, use_rule)
    for rule_file in rule_files:
        try:
            rule = load_configuration(rule_file, conf, args)
            if rule['name'] in names:
                raise EAException('Duplicate rule named %s' % (rule['name']))
        except EAException as e:
            raise EAException('Error loading file %s: %s' % (rule_file, e))

        rules.append(rule)
        names.append(rule['name'])

    conf['rules'] = rules
    return conf


def get_rule_hashes(conf, use_rule=None):
    rule_files = get_file_paths(conf, use_rule)
    rule_mod_times = {}
    for rule_file in rule_files:
        with open(rule_file) as fh:
            rule_mod_times[rule_file] = hashlib.sha1(fh.read()).digest()
    return rule_mod_times


def adjust_deprecated_values(rule):
    # From rename of simple HTTP alerter
    if rule.get('type') == 'simple':
        rule['type'] = 'post'
        if 'simple_proxy' in rule:
            rule['http_post_proxy'] = rule['simple_proxy']
        if 'simple_webhook_url' in rule:
            rule['http_post_url'] = rule['simple_webhook_url']
        logging.warning('"simple" alerter has been renamed "post" and comptability may be removed in a future release.')

Running ElastAlert rule I get Zero hits

[root@XX elastalert]# python -m elastalert.elastalert --start NOW --verbose --config config.yaml --rule Rule_folder/fw_text.yaml
INFO:elastalert:Starting up
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-11-30 12:00 UTC to 2017-11-30 12:00 UTC: 0 / 0 hits
INFO:elastalert:Ran Test Port Scan detection use case from 2017-11-30 12:00 UTC to 2017-11-30 12:00 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 19.949356 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-11-30 12:00 UTC to 2017-11-30 12:00 UTC: 0 / 0 hits
INFO:elastalert:Ran Test Port Scan detection use case from 2017-11-30 12:00 UTC to 2017-11-30 12:00 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 19.965983 seconds

sathishdsgithub avatar Nov 30 '17 12:11 sathishdsgithub

You've got "srx-rt-flow" : "RT_FLOW_SESSION_CLOSE" But you're searching for query: "srx-rt-flow: RT_FLOW_SESSION_DENY"

Those don't match.

Qmando avatar Dec 01 '17 21:12 Qmando

@Qmando

Thanks for your reply. Does it mean the hit count will remain zero until it finds the exact filter match?

Tthe below filter format which works in 2.x but not in 5.x , how do I replace and put correct format filter for 5.x ?

filter:
   - not:
        terms:
          srx-source-address: ["10.10.192.18", "10.19.192.17", "123.11.160.42"]
	


filter:
   - not:
       terms:
          srx-source-zone-name: ["EXTERNAL"]

sathishdsgithub avatar Dec 02 '17 07:12 sathishdsgithub

@Qmando

Our log field srx-rt-flow has RT_FLOW_SESSION_DENY and RT_FLOW_SESSION_CLOSE and other type. Here we are specifically trying to filter RT_FLOW_SESSION_DENY .

For testing even after changing to srx-rt-flow: "RT_FLOW_SESSION_CLOSE" I still get 0 hits. Not sure where is the problem. Please need your help ASAP Thanks

[root@elastalert]# python -m elastalert.elastalert --start NOW --verbose --config config.yaml --rule Rule_folder/fw_text.yaml
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 / 0 hits
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.96719 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 / 0 hits
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.965549 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 / 0 hits
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 16:29 UTC to 2017-12-03 16:34 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.967957 seconds
INFO:elastalert:SIGINT received, stopping ElastAlert...
[root@elastalert]# more Rule_folder/filter-whitelist-ip

# This will filter will whitelist the IP address specified in the below filter

description: "The below IP address will whitelist the scan"

filter:
   - query:
        query_string:
          query: "NOT srx-source-address: 133.11.160.42"

[root@elastalert]# more Rule_folder/filter-whitelist-zone

filter:
   - query:
        query_string:
          query: "NOT srx-source-zone-name: ZONENAME"

Even tried with debug mode still no clue . please help


[root@ elastalert]# python -m elastalert.elastalert --debug  --start 2017-12-03T16:00-05:000  --verbose --config config.yaml --rule Rule_folder/fw_text.yaml --es_debug_trace search.trace
INFO:elastalert:Note: In debug mode, alerts will be logged to console but NOT actually sent.
                To send them but remain verbose, use --verbose instead.
INFO:elastalert:Starting up
WARNING:root:Attempted to use query start time in the future (2017-12-03 16:00:00-05:00), sleeping instead
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 21:00 UTC to 2017-12-03 17:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.988146 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 11:24 UTC to 2017-12-03 17:24 UTC: 0 / 0 hits
INFO:elastalert:Skipping writing to ES: {'hits': 0, 'matches': 0, '@timestamp': '2017-12-03T17:24:52.954182Z', 'rule_name': 'Test Port Scan detection use case', 'starttime': '2017-12-03T11:24:52.925049Z', 'endtime': '2017-12-03T17:24:52.925049Z', 'time_taken': 0.029106855392456055}
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 11:24 UTC to 2017-12-03 17:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.96111 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 11:24 UTC to 2017-12-03 17:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 17:24 UTC to 2017-12-03 17:24 UTC: 0 / 0 hits
INFO:elastalert:Skipping writing to ES: {'hits': 0, 'matches': 0, '@timestamp': '2017-12-03T17:24:57.976200Z', 'rule_name': 'Test Port Scan detection use case', 'starttime': '2017-12-03T11:24:52.925049Z', 'endtime': '2017-12-03T17:24:57.927463Z', 'time_taken': 0.048718929290771484}
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 11:24 UTC to 2017-12-03 17:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.943998 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 17:24 UTC to 2017-12-03 17:25 UTC: 0 / 0 hits
INFO:elastalert:Skipping writing to ES: {'hits': 0, 'matches': 0, '@timestamp': '2017-12-03T17:25:02.972658Z', 'rule_name': 'Test Port Scan detection use case', 'starttime': '2017-12-03T17:24:52.925049Z', 'endtime': '2017-12-03T17:25:02.934914Z', 'time_taken': 0.03771781921386719}
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 17:24 UTC to 2017-12-03 17:25 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.953036 seconds
INFO:elastalert:Queried rule Test Port Scan detection use case from 2017-12-03 17:24 UTC to 2017-12-03 17:25 UTC: 0 / 0 hits
INFO:elastalert:Skipping writing to ES: {'hits': 0, 'matches': 0, '@timestamp': '2017-12-03T17:25:07.973400Z', 'rule_name': 'Test Port Scan detection use case', 'starttime': '2017-12-03T17:24:52.925049Z', 'endtime': '2017-12-03T17:25:07.940606Z', 'time_taken': 0.032768964767456055}
INFO:elastalert:Ran Test Port Scan detection use case from 2017-12-03 17:24 UTC to 2017-12-03 17:25 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 4.957099 seconds

sathishdsgithub avatar Dec 03 '17 16:12 sathishdsgithub

@Qmando @Dmitry

I managed to fix but I get the below scrolling message any idea how to fix it ? I'm using graylog for log collection and we get huge thousands of logs every ~100ms example Found 1,343,765 messages in 169 ms

How do we make elastalert to query huge logs for every 5 minutes without impacting performance ?

[root@ elastalert]# python -m elastalert.elastalert --start NOW --verbose  --config config.yaml --rule Rule_folder/port_scan.yaml
INFO:elastalert:Starting up
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 17:55 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 17:55 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 299.938797 seconds
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 10000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 20000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 30000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 40000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 50000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 60000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 70000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 80000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 90000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 100000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 110000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 120000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 130000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 140000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 150000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 160000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 170000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 180000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 190000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 200000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 210000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 220000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 230000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 240000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 250000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 260000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 270000 / 10000 hits (scrolling..)
INFO:elastalert:Queried rule Port Scan detection use case from 2017-12-03 17:55 UTC to 2017-12-03 18:00 UTC: 280000 / 10000 hits (scrolling..)


sathishdsgithub avatar Dec 03 '17 18:12 sathishdsgithub

You can set max_query_size to something larger than 10,000 which will reduce the number of times it scrolls.

Qmando avatar Dec 04 '17 20:12 Qmando

@Qmando If I use max_query_size in config.yaml i get 0hits and matches

sathishdsgithub avatar Dec 08 '17 20:12 sathishdsgithub

@Qmando

As you can see my query hits is very high . how do i improve the query size. Tried withmax_query_sizeno luck. If I use max_query_size i get 0 query hits.

Dec 12 06:31:05 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 228360 / 409 hits
Dec 12 06:31:06 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 228734 / 374 hits
Dec 12 06:31:07 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 230644 / 1910 hits
Dec 12 06:31:07 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 230752 / 108 hits
Dec 12 06:31:07 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 231405 / 653 hits
Dec 12 06:31:08 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 233384 / 1979 hits
Dec 12 06:31:09 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:24 UTC: 233414 / 30 hits
Dec 12 06:31:09 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:24 UTC to 2017-12-12 06:25 UTC: 234221 / 807 hits
Dec 12 06:31:10 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 234821 / 600 hits
Dec 12 06:31:10 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 235600 / 779 hits
Dec 12 06:31:11 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 236214 / 614 hits
Dec 12 06:31:11 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 237390 / 1176 hits
Dec 12 06:31:12 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 238027 / 637 hits
Dec 12 06:31:12 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 238684 / 657 hits
Dec 12 06:31:13 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 240153 / 1469 hits
Dec 12 06:31:13 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 240780 / 627 hits
Dec 12 06:31:14 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 240859 / 79 hits
Dec 12 06:31:14 elastalert01 python: INFO:elastalert:Queried rule   Scan detection use case from 2017-12-12 06:25 UTC to 2017-12-12 06:25 UTC: 241467 / 608 hits


sathishdsgithub avatar Dec 12 '17 06:12 sathishdsgithub

You might want to set run_every to something pretty small and then run elastalert with --start NOW to force it to start at the present time.

If you add max_query_size you always get 0 hits?

Qmando avatar Dec 12 '17 19:12 Qmando

@Qmando I'm already running elastalert with --start NOW and reduced the run_every to 2 min

If you add max_query_size you always get 0 hits?

Yes, if I enable the max_query_size I see only zero hits always.

sathishdsgithub avatar Dec 13 '17 10:12 sathishdsgithub

@Qmando

Is there any option to fix the below WARNING .

In addition to this is it possible to use blacklist file inclusion with type cardinality? My rule scenario is, If the destination address mentioned in blacklist file with cardinality value >15 it should trigger alert

Dec 16 12:03:30  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:01 UTC to 2017-12-16 12:02 UTC took longer than 0:00:10!
Dec 16 12:03:32  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:02 UTC to 2017-12-16 12:03 UTC took longer than 0:00:10!
Dec 16 12:04:10  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:02 UTC to 2017-12-16 12:03 UTC took longer than 0:00:10!
Dec 16 12:04:12  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:02 UTC to 2017-12-16 12:04 UTC took longer than 0:00:10!
Dec 16 12:04:14  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:02 UTC to 2017-12-16 12:04 UTC took longer than 0:00:10!
Dec 16 12:05:12  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:02 UTC to 2017-12-16 12:04 UTC took longer than 0:00:10!
Dec 16 12:05:14  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:03 UTC to 2017-12-16 12:05 UTC took longer than 0:00:10!
Dec 16 12:06:13  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:03 UTC to 2017-12-16 12:05 UTC took longer than 0:00:10!
Dec 16 12:06:16  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:04 UTC to 2017-12-16 12:06 UTC took longer than 0:00:10!
Dec 16 12:06:19  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:04 UTC to 2017-12-16 12:06 UTC took longer than 0:00:10!
Dec 16 12:07:49  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:04 UTC to 2017-12-16 12:06 UTC took longer than 0:00:10!
Dec 16 12:07:53  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:05 UTC to 2017-12-16 12:07 UTC took longer than 0:00:10!
Dec 16 12:09:22  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:05 UTC to 2017-12-16 12:07 UTC took longer than 0:00:10!
Dec 16 12:09:26  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:06 UTC to 2017-12-16 12:09 UTC took longer than 0:00:10!
Dec 16 12:09:32  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:06 UTC to 2017-12-16 12:09 UTC took longer than 0:00:10!
Dec 16 12:11:42  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:06 UTC to 2017-12-16 12:09 UTC took longer than 0:00:10!
Dec 16 12:11:47  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:07 UTC to 2017-12-16 12:11 UTC took longer than 0:00:10!
Dec 16 12:14:00  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:07 UTC to 2017-12-16 12:11 UTC took longer than 0:00:10!
Dec 16 12:14:08  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:09 UTC to 2017-12-16 12:14 UTC took longer than 0:00:10!
Dec 16 12:14:15  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:09 UTC to 2017-12-16 12:14 UTC took longer than 0:00:10!
Dec 16 12:17:44  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:09 UTC to 2017-12-16 12:14 UTC took longer than 0:00:10!
Dec 16 12:17:53  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:11 UTC to 2017-12-16 12:17 UTC took longer than 0:00:10!
Dec 16 12:21:23  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:11 UTC to 2017-12-16 12:17 UTC took longer than 0:00:10!
Dec 16 12:21:34  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:14 UTC to 2017-12-16 12:21 UTC took longer than 0:00:10!
Dec 16 12:21:48  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:14 UTC to 2017-12-16 12:21 UTC took longer than 0:00:10!
Dec 16 12:22:00  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:14 UTC to 2017-12-16 12:21 UTC took longer than 0:00:10!
Dec 16 12:27:32  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:14 UTC to 2017-12-16 12:22 UTC took longer than 0:00:10!
Dec 16 12:27:48  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:17 UTC to 2017-12-16 12:27 UTC took longer than 0:00:10!
Dec 16 12:33:44  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:17 UTC to 2017-12-16 12:27 UTC took longer than 0:00:10!
Dec 16 12:34:03  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:21 UTC to 2017-12-16 12:33 UTC took longer than 0:00:10!
Dec 16 12:34:25  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:21 UTC to 2017-12-16 12:34 UTC took longer than 0:00:10!
Dec 16 12:34:46  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:21 UTC to 2017-12-16 12:34 UTC took longer than 0:00:10!
Dec 16 12:44:24  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:22 UTC to 2017-12-16 12:34 UTC took longer than 0:00:10!
Dec 16 12:44:51  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:27 UTC to 2017-12-16 12:44 UTC took longer than 0:00:10!
Dec 16 12:54:43  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:27 UTC to 2017-12-16 12:44 UTC took longer than 0:00:10!
Dec 16 12:55:18  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:33 UTC to 2017-12-16 12:54 UTC took longer than 0:00:10!
Dec 16 12:55:48  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:34 UTC to 2017-12-16 12:55 UTC took longer than 0:00:10!
Dec 16 12:56:22  ElastAlert python: WARNING:root:Querying from 2017-12-16 12:34 UTC to 2017-12-16 12:55 UTC took longer than 0:00:10!

sathishdsgithub avatar Dec 16 '17 12:12 sathishdsgithub

@Qmando

[root@elastalert ~]# cat /opt/elastalert/config.yaml
# This is the folder that contains the rule yaml files
# Any .yaml file will be loaded as a rule
rules_folder: Rule_folder

# How often ElastAlert will query Elasticsearch
# The unit can be anything from weeks to seconds
run_every:
#   minutes: 60
   seconds: 10
# ElastAlert will buffer results from the most recent
# period of time, in case some log sources are not in real time
buffer_time:
#  minutes: 30
   seconds: 1
#  hours: 6
#   days: 1
#query_delay:
#  hours: 1
# The Elasticsearch hostname for metadata writeback
# Note that every rule can have its own Elasticsearch host
es_host: 10.101.10.1
#use_strftime_index: true
# The Elasticsearch port
es_port: 9200

max_query_size: 50000
# The AWS region to use. Set this when using AWS-managed elasticsearch
#aws_region: us-east-1

# The AWS profile to use. Use this if you are using an aws-cli profile.
# See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
# for details
#profile: test

# Optional URL prefix for Elasticsearch
#es_url_prefix: elasticsearch

# Connect with TLS to Elasticsearch
#use_ssl: True

# Verify TLS certificates
#verify_certs: True
#use_count_query: true
# GET request with body is the default option for Elasticsearch.
# If it fails for some reason, you can pass 'GET', 'POST' or 'source'.
# See http://elasticsearch-py.readthedocs.io/en/master/connection.html?highlight=send_get_body_as#transport
# for details
#es_send_get_body_as: GET

# Option basic-auth username and password for Elasticsearch
#es_username: someusername
#es_password: somepassword

# Use SSL authentication with client certificates client_cert must be
# a pem file containing both cert and key for client
#verify_certs: True
#ca_certs: /path/to/cacert.pem
#client_cert: /path/to/client_cert.pem
#client_key: /path/to/client_key.key

# The index on es_host which is used for metadata storage
# This can be a unmapped index, but it is recommended that you run
# elastalert-create-index to set a mapping
writeback_index: elastalert_status

# If an alert fails for some reason, ElastAlert will retry
# sending the alert until this time period has elapsed
#alert_time_limit:
#  days: 0

[root@elastalert ~]# more /opt/elastalert/Rule_folder/port_scan.yaml

# ElastAlert Rule Name

name: Port Scan detection use case

# ElasticSearch Index Name

index: firewalls*

# Timestamp added to overcome ES graylog parsing issue

timestamp_field: timestamp
timestamp_type: custom
timestamp_format: '%Y-%m-%d %H:%M:%S.%f'
timestamp_format_expr: 'ts[:23] + ts[26:]'

doc_type: message
# Network Port scan aggregation Rule 250 counts in 60 Seconds

type: cardinality

query_key: [srx-source-address, srx-destination-address]
cardinality_field: "srx-destination-port"
max_cardinality: 250

timeframe:
#   hours: 1
   minutes: 5
filter:
 - query_string:
      query: "srx-rt-flow: RT_FLOW_SESSION_DENY"

import:
  - filter-whitelist-ip
  - filter-whitelist-zone
  - qualys-scanner-ip
  - service-now-scanners-ip

# Combine multiple events and aggreagate the event for 2 minutes


aggregation:

   minutes: 15

# Aggregate the events based on the specfic field parameter

aggregation_key: ['srx-source-address', 'srx-destination-address']

############### Email Alert Configuration SMTP #############################

alert:
 - "email"
smtp_host: smtpio.example.com
smtp_port: 25
smtp_ssl : false
from_addr: "[email protected]"


# Email will be sent to below Rcpt

email:

#    -  "[email protected]"

# Email will contain following Subject TAG and Body message


alert_subject: "Port Scan activity detected between Source {0} and Destination {1} @ {2}"

alert_subject_args:

  - srx-source-address
  - srx-destination-address
  - timestamp


html_table_title: "<h3> Network Port Scan has been detected </h3> <p style='color:#4169E1;' style=font-family:verdana> Hi Team <br/><br/> Elastalert has identified a potential Network port
scan detection between following source and destination IP address, do something about it</p>"

alert_text_type: alert_text_only

alert_text: |

email_type: "html"

summary_table_fields_html:

    - srx-source-address

    - srx-source-port

    - srx-destination-address

    - srx-destination-port

OUTPUT

[root@elastalert]# python -m elastalert.elastalert --start NOW --verbose  --config config.yaml --rule Rule_folder/port_scan.yaml
INFO:elastalert:Starting up
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 9.784933 seconds
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 9.269487 seconds
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:23 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2018-01-18 06:23 UTC to 2018-01-18 06:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 9.10574 seconds
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 9.305822 seconds
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 / 0 hits
INFO:elastalert:Ran Port Scan detection use case from 2018-01-18 06:24 UTC to 2018-01-18 06:24 UTC: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 9.09498 seconds

image

sathishdsgithub avatar Jan 18 '18 06:01 sathishdsgithub

@Qmando @Dmitry1987

I also get the below ERROR message after querying some time. Please have a look at the query hits 572K . This is my problem as the documents are huge my elastalert is unable to query all the documents within run_every time:1 hour.

Problem: Need an option to query maximum documents. Please note I cannot useuse_count_queryas my YAML rule contains query_key

Jan 18 09:54:25 ServerElastalert python: INFO:elastalert:Queried rule Port Scan detection use case from 2018-01-18 08:58 UTC to 2018-01-18 08:58 UTC: **5722230 / 1236 hits**
Jan 18 09:54:45 ServerElastalert python: WARNING:elasticsearch:POST http://10.1.1.2:9200/elastalert_status/elastalert_status [status:N/A request:20.021s]
Jan 18 09:54:45 ServerElastalert python: Traceback (most recent call last):
Jan 18 09:54:45 ServerElastalert python: File "build/bdist.linux-x86_64/egg/elasticsearch/connection/http_requests.py", line 76, in perform_request
Jan 18 09:54:45 ServerElastalert python: response = self.session.send(prepared_request, **send_kwargs)
Jan 18 09:54:45 ServerElastalert python: File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
Jan 18 09:54:45 ServerElastalert python: r = adapter.send(request, **kwargs)
Jan 18 09:54:45 ServerElastalert python: File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 433, in send
Jan 18 09:54:45 ServerElastalert python: raise ReadTimeout(e, request=request)
Jan 18 09:54:45 ServerElastalert python: ReadTimeout: HTTPConnectionPool(host='10.1.1.2', port=9200): Read timed out. (read timeout=20)
Jan 18 09:54:45 ServerElastalert python: ERROR:root:Error writing alert info to Elasticsearch: ConnectionTimeout caused by - ReadTimeout(HTTPConnectionPool(host='10.1.1.2', port=9200): Read timed out. (read timeout=20))
Jan 18 09:54:45 ServerElastalert python: Traceback (most recent call last):
Jan 18 09:54:45 ServerElastalert python: File "/opt/elastalert/elastalert/elastalert.py", line 1361, in writeback
Jan 18 09:54:45 ServerElastalert python: doc_type=doc_type, body=body)
Jan 18 09:54:45 ServerElastalert python: File "build/bdist.linux-x86_64/egg/elasticsearch/client/utils.py", line 76, in _wrapped
Jan 18 09:54:45 ServerElastalert python: return func(*args, params=params, **kwargs)
Jan 18 09:54:45 ServerElastalert python: File "build/bdist.linux-x86_64/egg/elasticsearch/client/__init__.py", line 300, in index
Jan 18 09:54:45 ServerElastalert python: _make_path(index, doc_type, id), params=params, body=body)
Jan 18 09:54:45 ServerElastalert python: File "build/bdist.linux-x86_64/egg/elasticsearch/transport.py", line 314, in perform_request
Jan 18 09:54:45 ServerElastalert python: status, headers, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
Jan 18 09:54:45 ServerElastalert python: File "build/bdist.linux-x86_64/egg/elasticsearch/connection/http_requests.py", line 84, in perform_request
Jan 18 09:54:45 ServerElastalert python: raise ConnectionTimeout('TIMEOUT', str(e), e)
Jan 18 09:54:45 ServerElastalert python: ConnectionTimeout: ConnectionTimeout caused by - ReadTimeout(HTTPConnectionPool(host='10.1.1.2', port=9200): Read timed out. (read timeout=20))

sathishdsgithub avatar Jan 18 '18 10:01 sathishdsgithub

Maybe this has something to do with the Elasticsearch version. I don't have much experience with 5 or 6, perhaps for some very strange reason, passing the size parameter to the query breaks it.

Do you have the output from es_debug_trace for a query with and without the max_query_size? I don't understand one would result in 0 hits. Maybe there is a clue in there.

Qmando avatar Jan 18 '18 19:01 Qmando

@Qmando @Dmitry1987

When I make changes to YAML rule should I restart elastalert again to take the latest modified YAML rule ? OR is there any option to do it without restarting the elastalert ?

sathishdsgithub avatar Jan 19 '18 09:01 sathishdsgithub

Modify the Title of a rule, to see its name in output of elastalert log when it runs, so you'll know if it picked it up a new version or still shows the old name of the rule :) . I think it might pick it up without restart, but not sure.

On Fri, Jan 19, 2018 at 11:30 AM, sathishdsgithub [email protected] wrote:

@Qmando https://github.com/qmando @Dmitry1987 https://github.com/dmitry1987

When I make changes to YAML rule should I restart elastalert again to take the latest modified YAML rule ? OR is there any option to do it without restarting the elastalert ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Yelp/elastalert/issues/1442#issuecomment-358912469, or mute the thread https://github.com/notifications/unsubscribe-auth/AI71-BMVbj7uBeFx-2hSIX1yjYATHo5Rks5tMGCzgaJpZM4Qwdn9 .

Dmitry1987 avatar Jan 19 '18 10:01 Dmitry1987

@Dmitry1987 Are you running each rule separately by specifying --rule OR the config.yaml ? something like below /bin/python -m elastalert.elastalert --start NOW --verbose --config /opt/elastalert/config.yaml

sathishdsgithub avatar Jan 19 '18 10:01 sathishdsgithub

yes with a config file, it knows rules folder. single rules only when testing it before adding to production.

pay attention you must have ONLY proper YAML files in the rules forlder, anything else will crash the startup of elastalert with error (that's the case of my version, not sure if fixed).

On Fri, Jan 19, 2018 at 12:48 PM, sathishdsgithub [email protected] wrote:

@Dmitry1987 https://github.com/dmitry1987 Are you running each rule separately by specifying --rule OR the config.yaml ? something like below /bin/python -m elastalert.elastalert --start NOW --verbose --config /opt/elastalert/config.yaml

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Yelp/elastalert/issues/1442#issuecomment-358931457, or mute the thread https://github.com/notifications/unsubscribe-auth/AI71-AzXB1fpzxI-1dGScDr7CAWtM76yks5tMHLhgaJpZM4Qwdn9 .

Dmitry1987 avatar Jan 19 '18 12:01 Dmitry1987

@Dmitry1987 @Qmando

I keep getting this warning message does this means elastalert is unable to download the documents and skips to download remaining docs from ES ? .

I tried to set run_every: with different value like 5 min, 10 min, 20 min but still, I get this warning message. Can someone tell me is this normal? OR should I change any parameter to fix this warning?

Jan 20 05:44:33 ealert01 python: WARNING:root:Querying from 2018-01-20 05:01 UTC to 2018-01-20 05:30 UTC took longer than 0:20:00!

Appreciate your help

sathishdsgithub avatar Jan 20 '18 06:01 sathishdsgithub

I think you need bigger ES nodes, 20 seconds is too much. Either the query is bad and causes it to search through too much indexes, or the overall cluster performance is bad, for example too many shards vs nodes, etc'. ES is a whole science which I just started to learn, there are so many things to try and tweak to reach good performance.

The "run_every" doesn't matter here, because it's a single run which takes too long - I am not sure but it looks like it.

You can run this rule with --debug, and take this query to test manually and see why it runs so long, try variations of it, find what causes such long reply, is it the time frame, or bad fields with too much data in them, etc'.

It's a complicated task to make this all work smooth...

On Sat, Jan 20, 2018 at 8:09 AM, sathishdsgithub [email protected] wrote:

@Dmitry1987 https://github.com/dmitry1987 @Qmando https://github.com/qmando

I keep getting this warning message does this means elastalert is unable to download the documents and skips to download remaining docs from ES ? .

I tried to set run_every:with different value like 5 min, 10 min, 20 min but still, I get this warning message. Can someone tell me is this normal? OR should I change any parameter to fix this warning?

Jan 20 05:44:33 ealert01 python: WARNING:root:Querying from 2018-01-20 05:01 UTC to 2018-01-20 05:30 UTC took longer than 0:20:00!

Appreciate your help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Yelp/elastalert/issues/1442#issuecomment-359148837, or mute the thread https://github.com/notifications/unsubscribe-auth/AI71-GDqNX9-yf7ytmiGoQYh6N5v83Azks5tMYMygaJpZM4Qwdn9 .

Dmitry1987 avatar Jan 20 '18 08:01 Dmitry1987

I am facing a similar issue Below is my elastalert rule file, the query in kibana returns the result but elastalerts show 0 hits

name: Stargate Errors
type: any
index: logstash-containers-*
description: "Errors on Stargate"

filter:
- query:
    query_string:
      query: "ecs_cluster_name:stargate AND error AND NOT influxdb AND NOT Broker transport failure AND NOT SSL_accept AND NOT TLS library problem"


aggregation:
  hours: 1

alert: 
- "slack"

alert_subject: "{0} --> Error occured at {1}"
alert_subject_args: ["ecs_cluster_name", "timestamp"]


alert_text: "*Message*: {0}\n *Where*: {1}\n  *Version*: {2}\n  *Customer Host*: {3}"
alert_text_type: alert_text_only
alert_text_args: ["message", "where", "version", "customer_host"]
slack:
slack_webhook_url: "https://hooks.slack.com/services/ 

tariq87 avatar Jun 02 '20 11:06 tariq87