Enhancement: support limit crowdsec alerts to 24h (#5981)

Co-authored-by: MountainGod2 <admin@reid.ca>
This commit is contained in:
shamoon
2025-11-16 16:38:55 -08:00
committed by GitHub
parent 17c9b2631e
commit 196c51bf73
4 changed files with 15 additions and 1 deletions

View File

@@ -279,6 +279,9 @@ export function cleanServiceGroups(groups) {
slugs,
symbols,
// crowdsec
limit24h,
// customapi
mappings,
display,
@@ -473,6 +476,10 @@ export function cleanServiceGroups(groups) {
if (defaultinterval) widget.defaultinterval = defaultinterval;
}
if (limit24h !== undefined) {
widget.limit24h = !!limit24h;
}
if (type === "docker") {
if (server) widget.server = server;
if (container) widget.container = container;

View File

@@ -9,7 +9,7 @@ export default function Component({ 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");
if (alertsError || bansError) {

View File

@@ -9,6 +9,9 @@ const widget = {
alerts: {
endpoint: "alerts",
},
alerts24h: {
endpoint: "alerts?limit=0&since=24h",
},
bans: {
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
},