Compare fields using enhancement
Hi, I am having problem like issue #964. I wonder if I use enhancement, can use a filter in the rule? My demand compares to Web access IPs with threat IPs, does this solve my problem?
I'm starting with the solution and we were in doubt how I can do this
Thank you for help!
Yes, you can use filters and enhancements at the same time.
I don't know whether that solution solves your problem or not. You haven't given much details. Did you try it?
Well, I think this enhancements model does not work well in my case because I have to do the two field searches and after that compare. Do you have any suggestions not too advanced to solve this problem?
Can you explain the scenario you want?
You have web access IP logs, and you want to compare that to a list of threat IPs? Are the threat IPs also stored in Elasticsearch? Is it a static list?
If it's stored in Elasticsearch, like I think you are implying, why does the enhancement from the other issue not work?
Yes, all information is on elasticsearch. I have a field in an index called client_ip and another field in another index called threat_ip.
Why would the enhancement from the other issue not work?
I've been researching and I think this improvement solves my problem but I had trouble running. I changed all the required fields but an error occurred.
Can you help me? Thank you.

Instead of
super(IsIPMalicious, self)
you want
super(IsIPMalicious, self).__init__(*args)
It worked, but again an error occurred

Leave the line as I posted it, es = Elasticsearch(host=self.rule['es_host'], port=self.rule['es_port'])
This worked perfectly. Just as a remark to anyone who uses this kind of rule, search_type is not necessary in elasticsearch 5.
One last question, would it be possible to record in the email alert the IP that had relation between the two indexes and the timestamp?
I made this rule but it did not work.

Your config looks correct. It shows up as <MISSING VALUE>?
If you remove alert_text_type: alert_text_only it will show all the available fields in the alert.
I tested both ways, with or without alert_text_only. The strange thing is that it doesn't send in both ways and in kibana doesn't appear the email error status only the status of hits and matches.
Can there be something in the improvement that is causing the problem?
Please tell me you're not actually sending it to "[email protected]"
No, it's just a test. Because if you were send the email would give an elastalert_error smtp
You think this doesn't work because it doesn't give you an error?
Are you actually running elastalert or just using "elastalert-test-rule"?
Yes, it's running as a daemon. I already tried sending gmail the alert, but it does not work.
Even with the little experience I have with the tool I know I should have feedback from the alert, if worked or not. This doesn't even occur.
Are you running it with --verbose flag and capturing the output? It will say Email sent to [email protected] if it succeeds. It will also create a document in elasticsearch with _type: elastalert with either alert_sent: false or alert_sent: true if it fails or succeeds.
Yes, it's matching but the alert isn't being triggered. The alert_sent message isn't created in elasticsearch.

Ignoring match for silenced rule means that you ran the rule at some point with a realert setting, causing a silence stash to be created. The default is actually 1 minute, but if you see this message all the time, it's seems like it's been set previously.
You can bypass this by either changing the rule's name, or, deleting all documents of _type: elastalert_silence from Elasticsearch and restarting Elastalert.
You'll still get only 1 alert per query unless you add
realert:
minutes: 0
to the config.
Interesting. I made the modifications that you suggest to me but the rule continues with the same problem.