0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

各種ログAthenaSELECTクエリメモ

Posted at

■TGWのVPCフローログ

datetimeが別カラムのため、CONCATする

SELECT
  CAST(CONCAT(CAST(date AS VARCHAR),' ', time, ' +00:00') AS TIMESTAMP WITH TIME ZONE) AT TIME ZONE '+09:00' AS dt_jst,
  request_ip,
  request_protocol,
  host_header,
  uri,
  method,
  status
FROM <table>
WHERE 
  CAST(CONCAT(CAST(date AS VARCHAR),' ', time, ' +00:00') AS TIMESTAMP WITH TIME ZONE) >= CAST('<YYYY-MM-DD HH:mm:SS> +09:00' AS TIMESTAMP WITH TIME ZONE)
  AND CAST(CONCAT(CAST(date AS VARCHAR),' ', time, ' +00:00') AS TIMESTAMP WITH TIME ZONE) < CAST('<YYYY-MM-DD HH:mm:SS> +09:00' AS TIMESTAMP WITH TIME ZONE)
ORDER BY dt_jst;

■WAFログ

timestampは/1000する

SELECT 
  FROM_UNIXTIME(timestamp/1000, 9, 0) AS timestamp_jst,
  terminatingruleid,
  action,
  httprequest.clientip,
  httprequest.country,
  CAST(httprequest.headers AS JSON) AS headers,
  httprequest.uri,
  httprequest.httpmethod,
  labels
FROM table
ORDER BY timestamp;

■CloudFrontログ

-'で囲む

SELECT
  start,
  srcaddr,
  dstaddr,
  srcport,
  dstport,
  'flow-direction',
  protocol,
  'packets-lost-no-route' AS noroute,
  'packets-lost-blackhole' AS blackhole,
  'packets-lost-mtu-exceeded' AS mtuexceeded,
  'packets-lost-ttl-expired' AS ttlexpired
FROM <table>;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?