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

질문됨 일 년 전626회 조회
2개 답변
1
수락된 답변

Try writing the filter like this:

WHERE timestamp>=to_unixtime(date_add('hour', -1, now()))*1000
전문가
답변함 일 년 전
profile pictureAWS
전문가
검토됨 한 달 전
  • 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
전문가
답변함 일 년 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인