mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Enhancement: support limit crowdsec alerts to 24h (#5981)
Co-authored-by: MountainGod2 <admin@reid.ca>
This commit is contained in:
@@ -8,6 +8,9 @@ Learn more about [Crowdsec](https://crowdsec.net).
|
|||||||
See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines) for information about registering a machine,
|
See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines) for information about registering a machine,
|
||||||
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Without the `limit24h` option, the widget will fetch all alerts which is limited to 100 by the API to avoid performance issues.
|
||||||
|
|
||||||
Allowed fields: `["alerts", "bans"]`.
|
Allowed fields: `["alerts", "bans"]`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -16,4 +19,5 @@ widget:
|
|||||||
url: http://crowdsechostorip:port
|
url: http://crowdsechostorip:port
|
||||||
username: localhost # machine_id in crowdsec
|
username: localhost # machine_id in crowdsec
|
||||||
password: password
|
password: password
|
||||||
|
limit24h: true # optional, limits alerts to last 24h. Default: false
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -279,6 +279,9 @@ export function cleanServiceGroups(groups) {
|
|||||||
slugs,
|
slugs,
|
||||||
symbols,
|
symbols,
|
||||||
|
|
||||||
|
// crowdsec
|
||||||
|
limit24h,
|
||||||
|
|
||||||
// customapi
|
// customapi
|
||||||
mappings,
|
mappings,
|
||||||
display,
|
display,
|
||||||
@@ -473,6 +476,10 @@ export function cleanServiceGroups(groups) {
|
|||||||
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (limit24h !== undefined) {
|
||||||
|
widget.limit24h = !!limit24h;
|
||||||
|
}
|
||||||
|
|
||||||
if (type === "docker") {
|
if (type === "docker") {
|
||||||
if (server) widget.server = server;
|
if (server) widget.server = server;
|
||||||
if (container) widget.container = container;
|
if (container) widget.container = container;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: alerts, error: alertsError } = useWidgetAPI(widget, "alerts");
|
const { data: alerts, error: alertsError } = useWidgetAPI(widget, !!widget.limit24h ? "alerts24h" : "alerts");
|
||||||
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
||||||
|
|
||||||
if (alertsError || bansError) {
|
if (alertsError || bansError) {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ const widget = {
|
|||||||
alerts: {
|
alerts: {
|
||||||
endpoint: "alerts",
|
endpoint: "alerts",
|
||||||
},
|
},
|
||||||
|
alerts24h: {
|
||||||
|
endpoint: "alerts?limit=0&since=24h",
|
||||||
|
},
|
||||||
bans: {
|
bans: {
|
||||||
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
|
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user