0
0

AthenaでSimple Notification Serviceの送信ログを読み込めるようにした

Last updated at Posted at 2024-07-19

S3上にあるログファイルをいい具合に取得したい

最初に、個人的なメモの側面もあるのでご容赦してほしい。

やりたかったことは、送信ログを解析したり、月々の送信数を把握したかった、それだけです。
その為に、s3上のログをいい具合に取り込んで上げる必要があった。参考にしたのは下記のページ。

下記クエリもおいておく。パーティションの使い方が非常によく分かった。

CREATE EXTERNAL TABLE IF NOT EXISTS xxxxxxxxx.sms_usage_report2 (
  `PublishTimeUTC` string,
  `MessageId` string,
  `DestinationPhoneNumber` string,
  `MessageType` string,
  `DeliveryStatus` string,
  `PriceInUSD` float,
  `PartNumber` int,
  `TotalParts` int 
)
PARTITIONED BY (
year INT,
month INT,
day INT
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (  'escapeChar'='\\',  'quoteChar'='\"',  'integerization.format' = ',',  'field.delim' = ',' ) 
LOCATION 's3://[backet-name]/SMSUsageReports/ap-northeast-1/'
TBLPROPERTIES (
'classification'='csv',
'skip.header.line.count'='1',

'projection.enabled' = 'true',

'projection.year.type' = 'integer',
'projection.year.range' = '2010,2100',
'projection.year.digits' = '4',

'projection.month.type' = 'integer',
'projection.month.range' = '1,12',
'projection.month.digits' = '2',

'projection.day.type' = 'integer',
'projection.day.range' = '1,31',
'projection.day.digits' = '2',

'storage.location.template' = 's3://xxxxxxxxxxxxx/SMSUsageReports/ap-northeast-1/${year}/${month}/${day}'
)
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