2
2

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 5 years have passed since last update.

lambdaでGoogleAnalyticsを定期的にSlackにレポートする

Last updated at Posted at 2016-12-14

nodeからGoogleAnalyticsにアクセスする方法

こちらを参考に

ざっくり説明すると・・・

Google Developers Console から下記を設定

(0. プロジェクト作成)

  1. APIを有効にする
  2. サービス アカウント キーを作成(※1)

Google Analytics

  1. ビューIDの確認
  2. ユーザー管理から「表示と分析」が可能なメールアドレスを追加(※1のアドレス)

Developer Consoleから取得したJSONのclient_emailを利用します。

パラメータの説明、取得できるデータ

Core Reporting API

Core Reporting API - 一般的なクエリ
Core Reporting API - リファレンス ガイド

Dimensions & Metrics

本家のサイト
日本語で説明があるサイト

Lambdaの定期実行

「Configure triggers」の設定で「CloudWatch Events - Schedule」を指定します。
中身の指定の仕方は下記を参照して下さい。
Rate または Cron を使用したスケジュール式

Slackへの通知

Select blueprintの設定で「cloudwatch-alarm-to-slack」を選択してください。
slack側の設定やkmsを利用してURLを暗号化する方法など、
ほぼソースのコメントに書いてありますので読んでください。

こことか参考になるかな。
Webhook URLの暗号化はAWSコンソール上でワンクリックでできるので上記通りにやる必要はないです。

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?