command
module
Version:
v0.0.0-...-4819268
Opens a new window with list of versions in this module.
Published: May 23, 2019
License: MIT
Opens a new window with license information.
Imports: 8
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
mackerel-amazon-ranking
Amazonに掲載されている商品のランキングを取得して、Mackerelのサービスメトリクスとして投稿
Post Amazon ranking data as Mackerel service metrics

Usage in English is at the bottom of this page.
使用方法
-
以下のアカウントを事前に作成
- ランキングデータを取得したい国のAmazonアソシエイトアカウント (e.g. 日本)と、Product Advertising APIの利用登録
- Mackerel
-
リポジトリをクローン
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
Usage
-
Make sure you have accounts for:
- Amazon Associates in the country you want to get the ranking data (e.g. US).
- Mackerel to post and show the ranking data.
-
Clone the repository:
git clone git@github.com:doublemarket/mackerel-amazon-ranking.git
-
Rename or copy config.yaml.sample to config.yaml:
mv config.yaml.sample config.yaml
-
Update config.yaml. amazon_region should be one of the available region code. Note that the asins 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
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.