Amazonに掲載されている商品のランキングを取得して、Mackerelのサービスメトリクスとして投稿
Post Amazon ranking data as Mackerel service metrics
Usage in English is at the bottom of this page.
-
以下のアカウントを事前に作成
-
リポジトリをクローン
git clone git@github.com:doublemarket/mackerel-amazon-ranking.git
-
config.yaml.sample
をconfig.yaml
にリネームまたはコピーmv config.yaml.sample config.yaml
-
config.yaml
を更新。amazon_region
は使用しているライブラリのコードを参照して入力してください。asins
にはISBNコードではなくASINを入れてください。amazon_region: "REPLACE-WITH-YOURS" amazon_access_key: "REPLACE-WITH-YOURS" amazon_access_secret: "REPLACE-WITH-YOURS" amazon_account: "REPLACE-WITH-YOURS" mackerel_key: "REPLACE-WITH-YOURS" metric_prefix: "replace.with.your.preferred.prefix" asins: - "3950307842" # SQLパフォーマンス詳解 - "4873118409" # 入門Kubernetes - "4873118646" # 入門監視 - "4873118751" # 分散システムデザインパターン
-
必要なパッケージを取得
go get github.com/mackerelio/mackerel-client-go go get github.com/ngs/go-amazon-product-advertising-api/amazon
-
プログラムを実行。Amazonのランキングデータは1時間おきに更新されるので、cronなどで1時間おきに動かすとよいでしょう。
# ビルドして実行 go build amazonrank.go ./amazonrank # そのまま実行 go run amazonrank.go
-
Make sure you have accounts for:
-
Clone the repository:
git clone git@github.com:doublemarket/mackerel-amazon-ranking.git
-
Rename or copy
config.yaml.sample
toconfig.yaml
:mv config.yaml.sample config.yaml
-
Update
config.yaml
.amazon_region
should be one of the available region code. Note that theasins
should have ASINs, not ISBN codes.amazon_region: "REPLACE-WITH-YOURS" amazon_access_key: "REPLACE-WITH-YOURS" amazon_access_secret: "REPLACE-WITH-YOURS" amazon_account: "REPLACE-WITH-YOURS" mackerel_key: "REPLACE-WITH-YOURS" metric_prefix: "replace.with.your.preferred.prefix" asins: - "3950307842" # SQLパフォーマンス詳解 - "4873118409" # 入門Kubernetes - "4873118646" # 入門監視 - "4873118751" # 分散システムデザインパターン
-
Get required packages:
go get github.com/mackerelio/mackerel-client-go go get github.com/ngs/go-amazon-product-advertising-api/amazon
-
Build or just run the code. Ranking data on Amazon should be updated every hour so you may want to run it once per hour with cron etc.
# Build and run go build amazonrank.go ./amazonrank # Run go run amazonrank.go