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

已提问 1 年前626 查看次数
2 回答
1
已接受的回答

Try writing the filter like this:

WHERE timestamp>=to_unixtime(date_add('hour', -1, now()))*1000
专家
已回答 1 年前
profile pictureAWS
专家
已审核 1 个月前
  • 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
专家
已回答 1 年前
  • 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.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则