Skip to content

Commit 6d7dd0d

Browse files
add usage metrics documentation (#622)
* add usage metrics documentation * up * add explanation about decisions * add metrics_max_age config * enhance: Reword and simplify * enhance: add links to cscli --------- Co-authored-by: Laurence <[email protected]>
1 parent ded00a7 commit 6d7dd0d

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed

crowdsec-docs/docs/configuration/crowdsec_configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ db_config:
150150
flush:
151151
max_items: "<max_alerts_in_db>"
152152
max_age: "<max_age_of_alerts_in_db>"
153+
metrics_max_age: "<max_age_metrics_in_db>"
153154
bouncers_autodelete:
154155
cert: "<max_duration_since_last_pull>"
155156
api_key: "<max_duration_since_last_pull>"
@@ -447,6 +448,7 @@ db_config:
447448
flush:
448449
max_items: "<max_alerts_in_db>"
449450
max_age: "<max_age_of_alerts_in_db>"
451+
metrics_max_age: "<max_age_metrics_in_db>"
450452
bouncers_autodelete:
451453
cert: "<max_duration_since_last_pull>"
452454
api_key: "<max_duration_since_last_pull>"
@@ -593,6 +595,7 @@ When WAL is unspecified you will see the following warning message at startup :
593595
flush:
594596
max_items: <nb_max_alerts_in_database>
595597
max_age: <max_alerts_age_in_database>
598+
metrics_max_age: <max_metrics_age_in_database>
596599
bouncers_autodelete:
597600
cert: "<max_duration_since_last_pull>"
598601
api_key: "<max_duration_since_last_pull>"
@@ -611,6 +614,21 @@ Number max of alerts in database.
611614

612615
Alerts retention time.
613616

617+
Supported units:
618+
619+
- `s`: seconds
620+
621+
- `m`: minutes
622+
623+
- `h`: hours
624+
625+
- `d`: days
626+
627+
#### `metrics_max_age`
628+
> string
629+
630+
Usage metrics retention time.
631+
614632
Supported units:
615633

616634
- `s`: seconds
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
id: usage_metrics
3+
title: Usage Metrics
4+
sidebar_position: 6
5+
---
6+
7+
:::info
8+
Usage metrics require at least CrowdSec v1.6.3
9+
10+
Support on Remediation Components are rolling out progressively. Please check the relevant [documentation](/u/bouncers/intro) to see if your Remediation Component has support.
11+
:::
12+
13+
Logs processors and Remediation Components can provide detailed usage data to the [Local API (LAPI)](local_api/intro.md), allowing for a unified view of their behavior and better insights.
14+
15+
## Remediation Components
16+
17+
Remediation Components can send detailed information about themselves and what decisions they are acting on.
18+
19+
The specific metrics sent vary depending on the type of Remediation Component used.
20+
21+
For example, the [firewall Remediation Component](/u/bouncers/firewall) can report metrics on dropped bytes or packets, while the [OpenResty Remediation Component](/u/bouncers/openresty) can report metrics on dropped HTTP requests.
22+
23+
The same applies to interpreting the metrics: when blocking at the firewall level, most bots or attackers stop once they realize they can't connect to the target server. Therefore, the dropped packets or bytes should be seen as relative indicators of effectiveness between different blocking sources, not as the exact number of packets that would have been transmitted if the IP weren't blocked.
24+
25+
In contrast, HTTP-based Remediation Components typically count each handled request, as attackers are less likely to stop after receiving a 403 response or a Captcha challenge.
26+
27+
Whenever possible, the Remediation Components will break down the remediated traffic by the source of the decision.
28+
29+
Currently, CrowdSec supports the following origins:
30+
- `crowdsec`: an automated decision based on behavioral analysis of your logs
31+
- `CAPI`: a decision coming from the Community Blocklist
32+
- `cscli`: a manual decision added with [`cscli decisions add`](cscli/cscli_decisions_add.md)
33+
- `cscli-import`: decisions that were imported with [`cscli decisions import`](cscli/cscli_decisions_import.md)
34+
- `appsec`: the request was blocked by an appsec rule
35+
- `console`: a manual decision added from the [console](https://app.crowdsec.net)
36+
- `lists:XXX`: a decision coming from a blocklist subscribed in the [console](https://app.crowdsec.net). `XXX` is the name of the blocklist.
37+
38+
39+
You can view the metrics locally using [`cscli metrics show bouncers`](cscli/cscli_metrics_show.md):
40+
41+
![usage metrics csli](/img/usage_metrics_cscli_example.png)
42+
43+
The Remediation Components will send the number of decisions that are actually enforced.
44+
45+
These numbers may differ from what is shown by [`cscli decisions list`](cscli/cscli_decisions_list.md) for several reasons:
46+
- Filters are applied when querying LAPI (such as scope, scenarios, etc.).
47+
- LAPI deduplicates decisions before sending. If an IP is listed in multiple sources, only the decision with the longest remaining time is sent (useful for assessing blocklist overlap).
48+
49+
Remediation components will also send the version of the OS they are running on. You can see this information with [`cscli bouncers inspect XXX`](cscli/cscli_bouncers_inspect.md):
50+
51+
![usage metrics bouncer OS](/img/usage_metrics_bouncer_os.png)
52+
53+
## Log Processors
54+
55+
:::info
56+
Log Processors are the underlying component within the Security Engine that processes logs and sends Alerts to the LAPI. If you are running a multi-server setup, you will have multiple Log Processors.
57+
:::
58+
59+
Logs processors can also send more information about themselves to LAPI:
60+
- Operating system information (version, distribution/platform)
61+
- Number of [datasources](data_sources/introduction.md) configured per type
62+
- Enabled [features flags](configuration/feature_flags.md)
63+
- Installed Hub files (including [custom / tainted](/u/troubleshooting/intro#why-are-some-scenariosparsers-tainted-or-custom-) files):
64+
- AppSec-Config
65+
- AppSec-Rules
66+
- Collections
67+
- Contexts
68+
- Parsers
69+
- Scenarios
70+
71+
72+
You can show this data by using [`cscli machines inspect XXX`](cscli/cscli_machines_inspect.md):
73+
74+
![usage metrics LP](/img/usage_metrics_lp_cscli.png)
75+
76+
By default, only the collections are shown in order to keep the output readable.
77+
78+
If you want to see the entire hub state of a given Log Processor, you can use `cscli machines inspect --hub XXX`.

crowdsec-docs/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
items: [
274274
"observability/cscli",
275275
"observability/prometheus",
276+
"observability/usage_metrics",
276277
"observability/dashboard",
277278
"observability/pprof",
278279
],
49.4 KB
Loading
51.9 KB
Loading
103 KB
Loading

0 commit comments

Comments
 (0)