Skip to content

doublemarket/mackerel-amazon-ranking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mackerel-amazon-ranking

Amazonに掲載されている商品のランキングを取得して、Mackerelのサービスメトリクスとして投稿

Post Amazon ranking data as Mackerel service metrics

Screen shot

Usage in English is at the bottom of this page.

使用方法

  1. 以下のアカウントを事前に作成

    • ランキングデータを取得したい国のAmazonアソシエイトアカウント (e.g. 日本)と、Product Advertising APIの利用登録
    • Mackerel
  2. リポジトリをクローン

    git clone [email protected]:doublemarket/mackerel-amazon-ranking.git
    
  3. config.yaml.sampleconfig.yaml にリネームまたはコピー

    mv config.yaml.sample config.yaml
    
  4. 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" # 分散システムデザインパターン
    
  5. 必要なパッケージを取得

    go get github.com/mackerelio/mackerel-client-go
    go get github.com/ngs/go-amazon-product-advertising-api/amazon
    
  6. プログラムを実行。Amazonのランキングデータは1時間おきに更新されるので、cronなどで1時間おきに動かすとよいでしょう。

    # ビルドして実行
    go build amazonrank.go
    ./amazonrank
    
    # そのまま実行
    go run amazonrank.go
    

Usage

  1. 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.
  2. Clone the repository:

    git clone [email protected]:doublemarket/mackerel-amazon-ranking.git
    
  3. Rename or copy config.yaml.sample to config.yaml:

    mv config.yaml.sample config.yaml
    
  4. 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" # 分散システムデザインパターン
    
  5. Get required packages:

    go get github.com/mackerelio/mackerel-client-go
    go get github.com/ngs/go-amazon-product-advertising-api/amazon
    
  6. 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
    

About

Post Amazon ranking data as Mackerel service metrics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages