Athena query that filter result from the last 1 hour ?

0

Do anyone know how to filter athena waf log from the last hour?

for example SELECT count(*) AS countRequests,httprequest.clientip, terminatingruleid, httprequest.uri FROM "waf_logs" WHERE date >=date_format(current_date - interval '7' day, '%Y/%m/%d') GROUP BY httprequest.clientip,terminatingruleid, httprequest.uri ORDER BY count(*) DESC

gefragt vor einem Jahr626 Aufrufe
2 Antworten
1
Akzeptierte Antwort

Try writing the filter like this:

WHERE timestamp>=to_unixtime(date_add('hour', -1, now()))*1000
EXPERTE
beantwortet vor einem Jahr
profile pictureAWS
EXPERTE
überprüft vor einem Monat
  • works! many thanks

0

Try this

SELECT 
    count(*) AS countRequests,
    httprequest.clientip,
    terminatingruleid,
    httprequest.uri
FROM 
    "waf_logs"
WHERE 
    date_diff('hour', from_iso8601_timestamp(timestamp), now()) <= 1
GROUP BY 
    httprequest.clientip,
    terminatingruleid,
    httprequest.uri
ORDER BY 
    countRequests DESC;
profile picture
EXPERTE
beantwortet vor einem Jahr
  • FUNCTION_NOT_FOUND: line 9:23: Unexpected parameters (bigint) for function from_iso8601_timestamp. Expected: from_iso8601_timestamp(varchar(x)), from_iso8601_timestamp(char(x)) This query ran against the "default" database, unless qualified by the query.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen