Learning Elastic Stack 6.0 보는데..... 정말 저자를 패고 싶다.

테스트를 안한 건지.... 버전업이 되면서 바뀐건지....


logstash를 윈도우에 설치하고 테스트 해 보는 예제인데....

single quote(작은 따음표)를 주고 실행하면 아래와 같은 오류가 발생한다.


C:\logstash-6.6.0\bin>logstash.bat -e 'input { stdin { } } output { stdout { } }'

ERROR: Unknown command '{'


See: 'bin/logstash --help'

[ERROR] 2019-02-11 00:58:05.745 [main] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit


double quote(큰 따음표)로 변경해서 실행하면 잘 되는거 같은데....


C:\logstash-6.6.0\bin>logstash.bat -e "input { stdin { } } output { stdout { } }"

Sending Logstash logs to C:/logstash-6.6.0/logs which is now configured via log4j2.properties

[2019-02-11T01:01:54,037][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified

[2019-02-11T01:01:54,051][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.6.0"}

[2019-02-11T01:01:59,024][INFO ][logstash.pipeline        ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}

[2019-02-11T01:01:59,138][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x402ecfea run>"}

The stdin plugin is now waiting for input:

[2019-02-11T01:01:59,172][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}

[2019-02-11T01:01:59,445][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}




Posted by gt1000

logstash를 이용해서 csv 파일을 elasticsearch에 입력하는 테스트를 하는데..... 

아래 url 대로 하면 윈도우에서 되지 않는다.

https://github.com/pranav-shukla/learningelasticstack/tree/master/chapter-03


작업 순서는

1 elasticsearch에 index 를 생성하고

2 csv 파일 수정

3 logstash  설정 파일을 수정하고

4 command prompt에서 logstash를 실행한다.


1. kibana Dev Tools를 이용해서 elasticsearch 에 index 생성 합니다.

 - 원래 price 가

   "price" : {

            "type" : "scaled_float",

            "scaling_factor" : 100.0

          },

 sacled_float 타입인데... 이렇게 하고 실행하면 아래 오류가 나는데... 

"Field [price] misses required parameter [scaling_factor]"

검색해도 원인을 몰라서 타입을 integer로 수정했다.


PUT /my_products

{

  "settings": {

    "number_of_shards": 1,

    "number_of_replicas": 0,

    "analysis": {

      "analyzer": {}

    }

  },

  "mapping": {

    "products": {

      "properties": {

        "description": {

          "type": "text"

        },

        "id": {

          "type": "keyword"

        },

        "manufacturer": {

          "type": "text",

          "fields": {

            "raw": {

              "type": "keyword"

            }

          }

        },

        "price": {

          "type": "integer"

        },

        "title": {

          "type": "text"

        }

      }

    }

  }

}


2 csv 변경 

http://dbs.uni-leipzig.de/file/Amazon-GoogleProducts.zip

에서 csv 을 다운 받아서..... Amazon.csv 에서 price 를 숫자 타입으로 변경 후 products1.csv 파일로 저장

products1.csv



3 logstash 설정 파일 수정

logstash가 설치된 bin 디렉토리 밑에 files 폴더를 만들고.... config 디렉토리로 부터 logstash-sample.conf 파일을 복사 후에 아래와 같이 수정 후 files 폴더에 logstash_products.conf 파일로 저장

# Sample Logstash configuration for creating a simple

# Beats -> Logstash -> Elasticsearch pipeline.


input {

  file {

    path => "D:/logstash-6.5.4/bin/files/products1.csv"

    start_position => "beginning"

    sincedb_path => "nul"

    codec => plain {

      charset => "ISO-8859-1"   ----> 이건 원본이 그래서 UTF-8로 하지 않았음

    }

  }

}

filter {

  csv {

    separator => ","

    columns => ["id","title","description","manufacturer","price"]

  }


  mutate {

    remove_field => ["@version","@timestamp","path","host", "tags", "message"]

  } 

}

output {

  elasticsearch {

    hosts => "http://localhost:9200"

    index => "my_products"

    #document_type => "products" --------> 7 버전에서 deprecated 된다고 함

  }

  stdout {}

}


이 때 주의해야 할 것이 path 부분을 절대 \ 로 입력하지 마라. 반드시 리눅스 경로 / 로 입력


4 실행

Cheon JeongDae@DESKTOP-49U0CRN D:\logstash-6.5.4\bin

> logstash.bat -f files\logstash_products.conf


이렇게 하면 잘 들어 간다.


elasticsearch 7 버전부터 index는 하나의 type 타입을 가져서 

#document_type => "products"

를 주석을 했더니...


kibana에서

GET /my_products/products/_search 로 검색하면 안되고

GET /my_products/_search 로 해야 한다.

csv 파일 price를 만들때 공백을 제거해 줘야 하는거 같다. 전부 공백이 같이 들어 가서 range 검색이 안된다.






'elasticsearch' 카테고리의 다른 글

window logstash.bat -e 실행시 single quote error  (0) 2019.02.11
Posted by gt1000

2018. 10. 20. 21:35 웹전반(표준)

Spinner

근데 사실 다 복잡하고 별루다.


http://cfoucht.com/loadlab/

'웹전반(표준)' 카테고리의 다른 글

https 인증서  (0) 2019.03.04
chrome visual inspector 엄청 편리함  (0) 2018.10.04
css un minify site  (0) 2018.05.11
Http 요청 헤더  (0) 2015.01.10
크롬 브라우저 확장 툴  (0) 2014.12.23
Posted by gt1000

블로그 이미지
gt1000

태그목록

공지사항

어제
오늘

달력

 « |  » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함