Get alerts linked to a fqdn
Hi everyone,
I use Crowdsec on a NginX reverse proxy hosting around 2000 vhosts, and it works like a charm, thank you!
The question I often get from customers is "my website blahblah.com is not online", with no IP address. To track false positives, I'm looking for a way to get Crowdsec's decisions related to this blahblah.com website. If there is only one IP I'm sure this is the customer's IP, otherwise I'm often able to tell which IP is the right one with the AS number.
I added he following context so I get the fqdn when I use "cscli alert inspect":
context:
target_fqdn:
- evt.Meta.target_fqdn
The closest attempt I did is listing all decisions, extract alert ID, then run a "cscli alert inspect" and then looking for the right target_fqdn, but it is far from optimal.
I would like to search all alerts/decisions with blahblah.com in their context.
8 Replies
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type
/unresolve
© Created By WhyAydan for CrowdSec ❤️
Yeah this is difficult via
cscli
since its just directly api requests to the local api.
Unless you are sending notifications to an external system like elastic where you can filter down this context, then it would be the console since we allow filtering by alert context to alerts as we dont expose a way to filter via the local api as it would be a pain since the data is held a string in the database.Hmm I see... Thanks for your answer! I will dig the elastic topic
Elasticsearch | CrowdSec
CrowdSec can forward Alerts to Elasticsearch using the HTTP plugin. This guide will show you how to configure the plugin to send alerts to your Elasticsearch instance.
Would it be possible to write notification logfiles via the file plugin and setting
log_path
to something like {{GetMeta $alert "target_fqdn")}}
?yeah but at that point you might as well do
cscli alerts list -ojson | grep blahblah.com
or just use something jq
to filter.
here an example bash script:
then you can use it like:
then it will list all ips that matched the target fqdn (from my example):
you can expand it to log alert id or decision id, the world you is your oyster, just remember there a limitation that cscli alert list
only return the last 100 alerts hence why elastic or console is better 😄Also works with cscli decision list -a -ojson for input 🥳 .
This is way enough for my problem! Many thanks!
Resolving Get alerts linked to a fqdn
This has now been resolved. If you think this is a mistake please run
/unresolve