# Compact ban statistics

**URL:** <https://discourse.crowdsec.net/t/compact-ban-statistics/830>\
**Category:** Uncategorized\
**Created:** [May 31, 2022, 3:26am UTC](https://discourse.crowdsec.net/t/compact-ban-statistics/830 "2022-05-31T03:26:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fayataf488](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@fayataf488](https://discourse.crowdsec.net/u/fayataf488)\
**Post date:** [May 31, 2022, 3:26am UTC](https://discourse.crowdsec.net/t/compact-ban-statistics/830/1 "2022-05-31T03:26:07Z")

</div>

How to see the statistics of the number of banned ip in general? cscli decisions list -all - this is an incomprehensible huge list, you can somehow get a table of how many bans there were in a compact and understandable form

---

<div class="post-metadata">

**Author:** ![ne20002](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/ne20002/32/1012_2.png) [@ne20002](https://discourse.crowdsec.net/u/ne20002)\
**Post date:** [May 31, 2022, 7:30am UTC](https://discourse.crowdsec.net/t/compact-ban-statistics/830/2 "2022-05-31T07:30:24Z")

</div>

Not as far as I know.  
For my router where I have a crowdsec bouncer running I built a detection for collecting all occurring blocks of ips from the crowdsec banlist.  
At the moment it’s 160 to 240 different ips per day. The logs on the web servers are much smaller now. 🙂

I may share my solution if asked for.

---

<div class="post-metadata">

**Author:** ![blotus](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/blotus/32/109_2.png) [@blotus](https://discourse.crowdsec.net/u/blotus)\
**Post date:** [June 1, 2022, 10:11pm UTC](https://discourse.crowdsec.net/t/compact-ban-statistics/830/3 "2022-06-01T22:11:20Z")

</div>

Hello,

cscli can output JSON, so you can use `jq` to parse the output.  
For example:

- To get the number of local decisions: `cscli decisions list -o json | jq '[.[] | .decisions | .[]] | length '`
- To get the total numbers of decisions (local + CAPI): `cscli decisions list -a -o json | jq '[.[] | .decisions | .[]] | length '`
- To get the number of decisions from CAPI only: `cscli decisions list -a -o json | jq '[.[] | .decisions | .[] | select(.origin == "CAPI")] | length '`
- To get the number of decisions for the `crowdsecurity/ssh-bf` scenario: `cscli decisions list -a -o json | jq '[.[] | .decisions | .[] | select(.scenario == "crowdsecurity/ssh-bf")] | length '`
- To get the number of decisions per scenario: `cscli decisions list -a -o json | jq '[.[] | .decisions | .[]] | group_by(.scenario) | map({key: (.[] | .scenario), value: .|length}) | from_entries '`
