GithubHelp home page GithubHelp logo

gardart / amazon-mws-elastic Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 12.42 MB

Upload Amazon sellercentral reports into Elastic (ELK stack) - Logstash filters

amazon mws elasticsearch logstash elk elk-stack sellercentral kibana

amazon-mws-elastic's Introduction

amazon-mws-elastic

Upload Amazon sellercentral reports into Elastic (ELK stack). Currently supports the following reports

Installation

Install Elasticsearch

https://www.elastic.co/downloads/elasticsearch

Install Logstash

https://www.elastic.co/downloads/logstash

Install Kibana

https://www.elastic.co/downloads/kibana

Configure Logstash

Install Translate plugin

To install translate plugin, stop logstash service and run the following command on your logstash host

/usr/share/logstash/bin/logstash-plugin install logstash-filter-translate

Elasticsearch template to map geo_point to certain field that contains geo locations

To be able to map byers address to geo_point in Kibana world map we need to translate zip codes to geo location. This is done in the filter section of the Logstash config file like this:

mutate {
        add_field => ["latitude","%{[translation[0]}"]
        add_field => ["longitude","%{[translation[1]}"]
      }
      mutate {
        convert => { "longitude" => "float" }
        convert => { "latitude" => "float" }
      }
      mutate {
        rename => {
          "longitude" => "[location][lon]"
          "latitude" => "[location][lat]"
}

The new location field type then is mapped as geo_point with template inside Elasticsearch. For logstash to be able to upload this template into Elasticsearch, the template path must be defined in the output settings of the logstash config. This template is uploaded into Elasticsearch when Logstash starts up or restarts.

"properties": {
        "@version": { "type": "string", "index": "not_analyzed" },
        "location": { "type": "geo_point" }
}

Manually import template into Elasticsearch

To manually import this template into Elasticsearch, do the following:

curl -XPUT 'http://localhost:9200/_template/mws-collector-reports-fulfillment' -d@/etc/logstash/templates/mws-collector-reports-fulfillment.json

Upload csv data into logstash

Everything should be ready for the Amazon sellercentral csv data sets. First generate Fulfilled shipments data report in sellercentral and then download the report. Copy this file to the path defined in the input settings in the Logstash config file.

input {
  file {
    path => "/tmp/fulfillment/*"

Now, tail the logstash logs and see if the data is flowing correctly through Logstash.

tail -f /var/log/logstash/logstash-plain.log

[2017-03-01T09:38:50,385][DEBUG][logstash.pipeline        ] output received {"event"=>{"bill-country"=>nil, "amazon-order-item-id"=>"45646456", "type"=>"mws-collector-reports-fulfillment", "tracking-number"=>"xxxxxxxxxxxxx", "path"=>"/tmp/fulfillment/AMAZON_FULFILLED_SHIPMENTS_DATA.csv", "amazon-order-id"=>"xxxxxxx", "item-promotion-discount"=>0.0, "estimated-arrival-date"=>"2017-02-07T04:00:00+00:00", "ship-postal-code"=>49404,

Visualize Amazon reports from Sellercentral in Kibana (Elastic v5.2)

Select Management->Index patterns->Add New

2017-03-01 09_36_11-kibana

Make sure that location is defined as type:geo_point (if not, you need to upload the elasticsearch template)

2017-03-01 09_45_58-mws-collector-reports-fulfillment-_ - kibana The template should look like this inside Elasticsearch 2017-03-01 09_44_06-console - kibana

Next create the the map with Visualize->Tile Map Then select your index with location as the geo_point field 2017-03-01 09_50_16-kibana

The map should show the data like this

2017-03-01 09_51_15-kibana

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.