'2018/07'에 해당되는 글 11건

  1. 2018.07.25 [Beats] 오랜만에 Filebeat 설치 1
  2. 2018.07.25 [Elasticsearch] Dynamic template - _default_ deprecated.
  3. 2018.07.24 [GIT] git submodule 삭제 하기
  4. 2018.07.17 [Java] BufferedReader 사용 시 size 설정
  5. 2018.07.13 [Curator] 5.5 사용해 보기
  6. 2018.07.09 [Logstash] http output plugin - slack chat
  7. 2018.07.05 [Elasticsearch] Default field type 값.
  8. 2018.07.05 [Kibana] start and stop 스크립트
  9. 2018.07.04 [Elasticsearch] 그냥 settings, mappings, template 예제
  10. 2018.07.04 [Jenkins] Gradle 을 이용한 submodule update 이슈

[Beats] 오랜만에 Filebeat 설치

Elastic/Beats 2018. 7. 25. 20:23

설치환경)

AWS EC2

Ubuntu


다운로드)

https://www.elastic.co/kr/downloads/beats/filebeat

https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.3.1-linux-x86_64.tar.gz


다운 받으시고 그냥 압축 해제 하시면 됩니다.


tree 는 그냥 제 맥북 기준으로 보여 드립니다.


filebeat-6.3.2-darwin-x86_64

├── LICENSE.txt

├── NOTICE.txt

├── README.md

├── fields.yml

├── filebeat

├── filebeat.reference.yml

├── filebeat.yml

├── kibana

│   ├── 5

│   │   ├── dashboard

│   │   │   ├── 0d3f2380-fa78-11e6-ae9b-81e5311e8cab.json

│   │   │   ├── 26309570-2419-11e7-a83b-d5f4cebac9ff.json

│   │   │   ├── 277876d0-fa2c-11e6-bbd3-29c986c96e5a.json

│   │   │   ├── 5517a150-f9ce-11e6-8115-a7c18106d86a.json

│   │   │   ├── 7fea2930-478e-11e7-b1f0-cb29bac6bf8b.json

│   │   │   ├── Filebeat-Apache2-Dashboard.json

│   │   │   ├── Filebeat-MySQL-Dashboard.json

│   │   │   ├── Filebeat-Nginx-Dashboard.json

│   │   │   ├── Filebeat-Traefik-Dashboard.json

│   │   │   ├── Filebeat-syslog-dashboard.json

│   │   │   ├── ML-Nginx-Access-Remote-IP-Count-Explorer.json

│   │   │   ├── ML-Nginx-Remote-IP-URL-Explorer.json

│   │   │   ├── ML-Traefik-Access-Remote-IP-Count-Explorer.json

│   │   │   ├── ML-Traefik-Remote-IP-URL-Explorer.json

│   │   │   ├── b9163ea0-2417-11e7-a83b-d5f4cebac9ff.json

│   │   │   ├── dfbb49f0-0a0f-11e7-8a62-2d05eaaac5cb.json

│   │   │   └── f693d260-2417-11e7-a83b-d5f4cebac9ff.json

│   │   ├── index-pattern

│   │   │   └── filebeat.json

│   │   ├── search

│   │   │   ├── 0ab87b80-478e-11e7-b1f0-cb29bac6bf8b.json

│   │   │   ├── 4ac0a370-0a11-11e7-8b04-eb22a5669f27.json

│   │   │   ├── 62439dc0-f9c9-11e6-a747-6121780e0414.json

│   │   │   ├── 710043e0-2417-11e7-a83b-d5f4cebac9ff.json

│   │   │   ├── 73613570-4791-11e7-be88-2ddb32f3df97.json

│   │   │   ├── 8030c1b0-fa77-11e6-ae9b-81e5311e8cab.json

│   │   │   ├── Apache2-access-logs.json

│   │   │   ├── Apache2-errors-log.json

│   │   │   ├── Filebeat-MySQL-Slow-log.json

│   │   │   ├── Filebeat-MySQL-error-log.json

│   │   │   ├── Filebeat-Nginx-module.json

│   │   │   ├── Filebeat-Traefik-module.json

│   │   │   ├── ML-Filebeat-Nginx-Access.json

│   │   │   ├── ML-Filebeat-Traefik-Access.json

│   │   │   ├── Syslog-system-logs.json

│   │   │   ├── b6f321e0-fa25-11e6-bbd3-29c986c96e5a.json

│   │   │   ├── c876e6a0-2418-11e7-a83b-d5f4cebac9ff.json

│   │   │   ├── eb0039f0-fa7f-11e6-a1df-a78bd7504d38.json

│   │   │   └── ffaf5a30-2413-11e7-a0d9-39604d45ca7f.json

│   │   └── visualization

│   │       ├── 0bc34b60-2419-11e7-a83b-d5f4cebac9ff.json

│   │       ├── 12667040-fa80-11e6-a1df-a78bd7504d38.json

│   │       ├── 2bb0fa70-0a11-11e7-9e84-43da493ad0c7.json

│   │       ├── 2cf77780-2418-11e7-a83b-d5f4cebac9ff.json

│   │       ├── 341ffe70-f9ce-11e6-8115-a7c18106d86a.json

│   │       ├── 346bb290-fa80-11e6-a1df-a78bd7504d38.json

│   │       ├── 3cec3eb0-f9d3-11e6-8a3e-2b904044ea1d.json

│   │       ├── 51164310-fa2b-11e6-bbd3-29c986c96e5a.json

│   │       ├── 5c7af030-fa2a-11e6-bbd3-29c986c96e5a.json

│   │       ├── 5dd15c00-fa78-11e6-ae9b-81e5311e8cab.json

│   │       ├── 5ebdbe50-0a0f-11e7-825f-6748cda7d858.json

│   │       ├── 6295bdd0-0a0e-11e7-825f-6748cda7d858.json

│   │       ├── 78b74f30-f9cd-11e6-8115-a7c18106d86a.json

│   │       ├── 78b9afe0-478f-11e7-b1f0-cb29bac6bf8b.json

│   │       ├── Apache2-access-unique-IPs-map.json

│   │       ├── Apache2-browsers.json

│   │       ├── Apache2-error-logs-over-time.json

│   │       ├── Apache2-operating-systems.json

│   │       ├── Apache2-response-codes-of-top-URLs.json

│   │       ├── Apache2-response-codes-over-time.json

│   │       ├── Errors-over-time.json

│   │       ├── ML-Nginx-Access-Map.json

│   │       ├── ML-Nginx-Access-Remote-IP-Timechart.json

│   │       ├── ML-Nginx-Access-Response-Code-Timechart.json

│   │       ├── ML-Nginx-Access-Top-Remote-IPs-Table.json

│   │       ├── ML-Nginx-Access-Top-URLs-Table.json

│   │       ├── ML-Nginx-Access-Unique-Count-URL-Timechart.json

│   │       ├── ML-Traefik-Access-Map.json

│   │       ├── ML-Traefik-Access-Remote-IP-Timechart.json

│   │       ├── ML-Traefik-Access-Response-Code-Timechart.json

│   │       ├── ML-Traefik-Access-Top-Remote-IPs-Table.json

│   │       ├── ML-Traefik-Access-Top-URLs-Table.json

│   │       ├── ML-Traefik-Access-Unique-Count-URL-Timechart.json

│   │       ├── MySQL-Error-logs-levels.json

│   │       ├── MySQL-Slow-logs-by-count.json

│   │       ├── MySQL-Slow-queries-over-time.json

│   │       ├── MySQL-error-logs.json

│   │       ├── MySQL-slowest-queries.json

│   │       ├── New-Visualization.json

│   │       ├── Nginx-Access-Browsers.json

│   │       ├── Nginx-Access-Map.json

│   │       ├── Nginx-Access-OSes.json

│   │       ├── Nginx-Access-Response-codes-by-top-URLs.json

│   │       ├── Sent-sizes.json

│   │       ├── Syslog-events-by-hostname.json

│   │       ├── Syslog-hostnames-and-processes.json

│   │       ├── Traefik-Access-Browsers.json

│   │       ├── Traefik-Access-Map.json

│   │       ├── Traefik-Access-OSes.json

│   │       ├── Traefik-Access-Response-codes-by-top-URLs.json

│   │       ├── a59b5e00-2417-11e7-a83b-d5f4cebac9ff.json

│   │       ├── c5411910-0a87-11e7-8b04-eb22a5669f27.json

│   │       ├── d16bb400-f9cc-11e6-8115-a7c18106d86a.json

│   │       ├── d1726930-0a7f-11e7-8b04-eb22a5669f27.json

│   │       ├── d2864600-478f-11e7-be88-2ddb32f3df97.json

│   │       ├── d56ee420-fa79-11e6-a1df-a78bd7504d38.json

│   │       ├── d8e5dc40-2417-11e7-a83b-d5f4cebac9ff.json

│   │       ├── dc589770-fa2b-11e6-bbd3-29c986c96e5a.json

│   │       ├── dcccaa80-4791-11e7-be88-2ddb32f3df97.json

│   │       ├── e121b140-fa78-11e6-a1df-a78bd7504d38.json

│   │       ├── f398d2f0-fa77-11e6-ae9b-81e5311e8cab.json

│   │       └── fb09d4b0-2418-11e7-a83b-d5f4cebac9ff.json

│   └── 6

│       ├── dashboard

│       │   ├── Filebeat-Kafka-overview.json

│       │   ├── Filebeat-Mongodb-overview.json

│       │   ├── Filebeat-Postgresql-overview.json

│       │   ├── Filebeat-Postgresql-slowlogs.json

│       │   ├── Filebeat-apache2.json

│       │   ├── Filebeat-auditd.json

│       │   ├── Filebeat-auth-sudo-commands.json

│       │   ├── Filebeat-icinga-debug-log.json

│       │   ├── Filebeat-icinga-main-log.json

│       │   ├── Filebeat-icinga-startup-errors.json

│       │   ├── Filebeat-iis.json

│       │   ├── Filebeat-logstash-log.json

│       │   ├── Filebeat-logstash-slowlog.json

│       │   ├── Filebeat-mysql.json

│       │   ├── Filebeat-new-users-and-groups.json

│       │   ├── Filebeat-nginx-logs.json

│       │   ├── Filebeat-nginx-overview.json

│       │   ├── Filebeat-redis.json

│       │   ├── Filebeat-ssh-login-attempts.json

│       │   ├── Filebeat-syslog.json

│       │   ├── Filebeat-traefik-overview.json

│       │   ├── ml-nginx-access-remote-ip-count-explorer.json

│       │   ├── ml-nginx-remote-ip-url-explorer.json

│       │   ├── ml-traefik-access-remote-ip-count-explorer.json

│       │   ├── ml-traefik-remote-ip-url-explorer.json

│       │   ├── osquery-compliance.json

│       │   └── osquery-rootkit.json

│       └── index-pattern

│           └── filebeat.json

├── module

│   ├── apache2

│   │   ├── access

│   │   │   ├── config

│   │   │   │   └── access.yml

│   │   │   ├── ingest

│   │   │   │   └── default.json

│   │   │   └── manifest.yml

│   │   ├── error

│   │   │   ├── config

│   │   │   │   └── error.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── auditd

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── icinga

│   │   ├── debug

│   │   │   ├── config

│   │   │   │   └── debug.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   ├── main

│   │   │   ├── config

│   │   │   │   └── main.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   ├── module.yml

│   │   └── startup

│   │       ├── config

│   │       │   └── startup.yml

│   │       ├── ingest

│   │       │   └── pipeline.json

│   │       └── manifest.yml

│   ├── iis

│   │   ├── access

│   │   │   ├── config

│   │   │   │   └── iis-access.yml

│   │   │   ├── ingest

│   │   │   │   └── default.json

│   │   │   └── manifest.yml

│   │   └── error

│   │       ├── config

│   │       │   └── iis-error.yml

│   │       ├── ingest

│   │       │   └── default.json

│   │       └── manifest.yml

│   ├── kafka

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── logstash

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   ├── pipeline-json.json

│   │   │   │   └── pipeline-plain.json

│   │   │   └── manifest.yml

│   │   ├── module.yml

│   │   └── slowlog

│   │       ├── config

│   │       │   └── slowlog.yml

│   │       ├── ingest

│   │       │   ├── pipeline-json.json

│   │       │   └── pipeline-plain.json

│   │       └── manifest.yml

│   ├── mongodb

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── mysql

│   │   ├── error

│   │   │   ├── config

│   │   │   │   └── error.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   ├── module.yml

│   │   └── slowlog

│   │       ├── config

│   │       │   └── slowlog.yml

│   │       ├── ingest

│   │       │   └── pipeline.json

│   │       └── manifest.yml

│   ├── nginx

│   │   ├── access

│   │   │   ├── config

│   │   │   │   └── nginx-access.yml

│   │   │   ├── ingest

│   │   │   │   └── default.json

│   │   │   ├── machine_learning

│   │   │   │   ├── datafeed_low_request_rate.json

│   │   │   │   ├── datafeed_remote_ip_request_rate.json

│   │   │   │   ├── datafeed_remote_ip_url_count.json

│   │   │   │   ├── datafeed_response_code.json

│   │   │   │   ├── datafeed_visitor_rate.json

│   │   │   │   ├── low_request_rate.json

│   │   │   │   ├── remote_ip_request_rate.json

│   │   │   │   ├── remote_ip_url_count.json

│   │   │   │   ├── response_code.json

│   │   │   │   └── visitor_rate.json

│   │   │   └── manifest.yml

│   │   ├── error

│   │   │   ├── config

│   │   │   │   └── nginx-error.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── osquery

│   │   ├── module.yml

│   │   └── result

│   │       ├── config

│   │       │   └── result.yml

│   │       ├── ingest

│   │       │   └── pipeline.json

│   │       └── manifest.yml

│   ├── postgresql

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   └── module.yml

│   ├── redis

│   │   ├── log

│   │   │   ├── config

│   │   │   │   └── log.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   ├── module.yml

│   │   └── slowlog

│   │       ├── config

│   │       │   └── slowlog.yml

│   │       ├── ingest

│   │       │   └── pipeline.json

│   │       └── manifest.yml

│   ├── system

│   │   ├── auth

│   │   │   ├── config

│   │   │   │   └── auth.yml

│   │   │   ├── ingest

│   │   │   │   └── pipeline.json

│   │   │   └── manifest.yml

│   │   ├── module.yml

│   │   └── syslog

│   │       ├── config

│   │       │   └── syslog.yml

│   │       ├── ingest

│   │       │   └── pipeline.json

│   │       └── manifest.yml

│   └── traefik

│       ├── access

│       │   ├── config

│       │   │   └── traefik-access.yml

│       │   ├── ingest

│       │   │   └── pipeline.json

│       │   ├── machine_learning

│       │   │   ├── datafeed_low_request_rate.json

│       │   │   ├── datafeed_remote_ip_request_rate.json

│       │   │   ├── datafeed_remote_ip_url_count.json

│       │   │   ├── datafeed_response_code.json

│       │   │   ├── datafeed_visitor_rate.json

│       │   │   ├── low_request_rate.json

│       │   │   ├── remote_ip_request_rate.json

│       │   │   ├── remote_ip_url_count.json

│       │   │   ├── response_code.json

│       │   │   └── visitor_rate.json

│       │   ├── manifest.yml

│       │   └── tests

│       │       ├── test.log

│       │       └── test.log-expected.json

│       └── module.yml

└── modules.d

    ├── apache2.yml.disabled

    ├── auditd.yml.disabled

    ├── icinga.yml.disabled

    ├── iis.yml.disabled

    ├── kafka.yml.disabled

    ├── logstash.yml.disabled

    ├── mongodb.yml.disabled

    ├── mysql.yml.disabled

    ├── nginx.yml.disabled

    ├── osquery.yml.disabled

    ├── postgresql.yml.disabled

    ├── redis.yml.disabled

    ├── system.yml.disabled

    └── traefik.yml.disabled


97 directories, 254 files


도움말)

Usage:

  filebeat [flags]

  filebeat [command]


Available Commands:

  export      Export current config or index template

  help        Help about any command

  keystore    Manage secrets keystore

  modules     Manage configured modules

  run         Run filebeat

  setup       Setup index template, dashboards and ML jobs

  test        Test config

  version     Show current version info


Flags:

  -E, --E setting=value      Configuration overwrite

  -M, --M setting=value      Module configuration overwrite

  -N, --N                    Disable actual publishing for testing

  -c, --c string             Configuration file, relative to path.config (default "filebeat.yml")

      --cpuprofile string    Write cpu profile to file

  -d, --d string             Enable certain debug selectors

  -e, --e                    Log to stderr and disable syslog/file output

  -h, --help                 help for filebeat

      --httpprof string      Start pprof http server

      --memprofile string    Write memory profile to this file

      --modules string       List of enabled modules (comma separated)

      --once                 Run filebeat only once until all harvesters reach EOF

      --path.config string   Configuration path

      --path.data string     Data path

      --path.home string     Home path

      --path.logs string     Logs path

      --setup                Load sample Kibana dashboards and setup Machine Learning

      --strict.perms         Strict permission checking on config files (default true)

  -v, --v                    Log at INFO level


Use "filebeat [command] --help" for more information about a command.


filebeat.yml 예제)

filebeat:

  prospectors:

    -

      paths:

        - /mnt/apps/apache-tomcat/logs/catalina.out

      encoding: utf-8

      input_type: log


      exclude_lines: ['DEBUG', 'INFO']

      include_lines: ['(E|e)rror', 'ERROR', '(E|e)xception', 'EXCEPTION']


      document_type: error-log


      ignore_older: 5m


      scan_frequency: 10s


      multiline:

        pattern: '^[[:space:]]+|^Caused by:'

        negate: false

        match: after

        max_lines: 10

        timeout: 5s


      tail_files: true


      backoff: 1s

      max_backoff: 10s

      backoff_factor: 2


  registry_file: /mnt/config/filebeat/.filebeat-tomcat


output:

  logstash:

    hosts: ["localhost:5044"]


shipper:


logging:

  to_syslog: false

  to_files: true


  level: warning


  files:

    path: /mnt/logs/filebeat

    name: filebeat-tomcat.log

    rotateeverybytes: 10485760 # = 10MB


logstash 예제)

input {

  beats {

    port => 5044

  }

}


output {

  stdout { codec => rubydebug }


  http {

    url => "https://slack.com/api/chat.postMessage"

    content_type => "application/json"

    http_method => "post"

    format => "json"

    mapping => [ "channel", "slack-bot", "text", "%{message}" ]

    headers => ["Authorization", "Bearer xoxb-XXXXXXXXXXXXXXXXXXXXX"]

  }

#  elasticsearch {

#    host => "localhost"

#    port => "9200"

#    protocol => "http"

#    index => "%{[@metadata][index]}"

#    document_type => "%{[@metadata][type]}"

#  }

}


위 예제는 그냥 filebeat 이 log file 을 리스닝 하고 있다가 error 또는 exception 발생 시 바로 slack 으로 해당 에러는 보내주는 예제 입니다.

:

[Elasticsearch] Dynamic template - _default_ deprecated.

Elastic/Elasticsearch 2018. 7. 25. 09:49

늘 그렇지만 다 기억 못합니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/default-mapping.html


_default_ 가 deprecated 되었습니다.


이와 더불어 사용시 아래와 같은 에러가 발생을 경험 할 수 있는데요.


org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping [_default_]: No field type matched on [integer], possible values are [object, string, long, double, boolean, date, binary]


"mappings": {
"_default_": {
"dynamic_templates": [
{

...중략...

우선  _default_ 는 다른 type name 을 작성해 주시면 됩니다.

원문에서와 같이 _doc 이나 _log 나 default 와 같은...


그리고 저 위에 에러는 dynamic templates 사용 시 field type 정보를 보시면 이해가 되실 겁니다.

우리가 흔히 알고 있는 mapping field type 과 조금 다르기 때문에 잘 인지 하고 계시면 삽질은 피하실 수 있습니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type


match_mapping_type

The match_mapping_type matches on the datatype detected by dynamic field mapping, in other words, the datatype that Elasticsearch thinks the field should have. Only the following datatypes can be automatically detected: boolean, date, double, long, object, string. It also accepts * to match all datatypes.


더불어서 잘못 생성된 템플릿을 삭제해야 할 필요가 있습니다.

가끔 아래와 같은 에러가 발생 하는데 이럴 경우 템플릿을 삭제 후 다시 등록 하시면 됩니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#delete


java.lang.IllegalArgumentException: Rejecting mapping update to [monitoring-20180725] as the final mapping would have more than 1 type: [log, doc]


DELETE /_template/template_1


:

[GIT] git submodule 삭제 하기

ITWeb/개발일반 2018. 7. 24. 07:44

이것도 복습 차원에서 정리해 봅니다.


Step 1)

  helloworld project root 로 이동 합니다.

  $ cd helloworld

 

Step 2)

  .gitmodules 를 열어서 삭제할 모듈을 지워 줍니다.

  helloworld$ vi .gitmodules

 

Step 3)

  삭제 하고자 하는 submodule 의 cache 를 삭제 합니다.

  helloworld$ git rm --cached hi-module

   

  아래와 같은 에러는 무시 하시거나 아래 명령 실행 후 위 명령어를 실행 합니다.

  $ git submodule deinit <path_to_submodule>

   

  fatal: Please stage your changes to .gitmodules or stash them to proceed

 

Step 4)

  .git 내 남아 있는 submodule 을 삭제 합니다.

  helloworld$ rm -rf .git/modules/hi-module

   

Step 5)

  해당 프로젝트에서 submodule 을 추가 한 것을 삭제 합니다.

  remove module (into intellij project)

   

Step 6)

  최종 submodule 을 삭제 합니다.

  helloworld$ rm -rf hi-module

   

Step 7)

  commit & push 합니다.

  helloworld$ git commit -m 'remove submodules'

  helloworld$ git push


:

[Java] BufferedReader 사용 시 size 설정

ITWeb/개발일반 2018. 7. 17. 08:34

Text 파일을 라인 단위로 읽어 들이기 위해 많이 사용하는 클래스 입니다.

보통은 default 생성자로 사용을 하는데 라인 한줄이 너무 커서 크기를 조정해 줘야 했습니다.

혹시 잊을까봐 기록해 봅니다.


https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html


BufferedReader(Reader in)


BufferedReader(Reader in, int sz)


JDK8 기준으로 default size  는 8192 bytes 입니다.


private static int defaultCharBufferSize = 8192;


:

[Curator] 5.5 사용해 보기

Elastic/Curator 2018. 7. 13. 19:34

오랜만에 사용해 보려고 했더니 또 기억이나질 않아서 기록해 봅니다.


공식문서)

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/index.html


설치)

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/pip.html


설치 방법이 예전이랑 좀 달라진게 있더군요.

저는 아래 방법으로 설치 했습니다.


$ pip install --user elasticsearch-curator


실행)

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/command-line.html

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/singleton-cli.html


$ curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML 


이 방식으로 이전 3.x 버전에서는 command 를 주고 사용했었으나 4.2 버전 이후 부터는 Singleton command line interface 를 사용해야 합니다. 


- prefix 방식

$ curator_cli --host localhost --port 9200 show_indices --filter_list '{"filtertype":"pattern", "kind":"prefix", "value":"search-"}'


- regex 방식

$ curator_cli --host localhost --port 9200 show_indices --filter_list '{"filtertype":"pattern", "kind":"regex", "value":"^(search-).*$"}'


예제)

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/examples.html


더 많은 예제는 위 문서에서 찾아 보시면서 해보시면 될 것 같습니다.


:

[Logstash] http output plugin - slack chat

Elastic/Logstash 2018. 7. 9. 12:19


예전에는 output slack_chat 이라고 플러그인을 만들어서 사용을 했었는데 logstash output http 가 있어서 그냥 이걸로 바로 사용하겠습니다.


공식문서에 잘못된 정보가 있기 때문에 그대로 보고 따라 하시면 시간을 낭비 하실 수 있습니다.

(6.3.0 에서 테스트 되었습니다.)


Reference)

https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html


input {

stdin {}

}


output {

stdout { codec => rubydebug }

http {

url => "https://slack.com/api/chat.postMessage"

content_type => "application/json"

http_method => "post"

format => "json"

mapping => [ "channel", "CXXXXXXXXX", "text", "%{message}" ]

headers => ["Authorization", "Bearer xoxb-xxxxxxxxxxx"]

}

}


문서 내 잘못된 정보)

https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html#plugins-outputs-http-mapping


mapping 이 hash 로 되어 있는데 실제 나와 있는 예제로는 동작 하지 않습니다.


잘못된 예)

   mapping => {"foo" => "%{host}"
              "bar" => "%{type}"}


바른 예)

mapping => [ "channel", "CXXXXXXXXX", "text", "%{message}" ]



:

[Elasticsearch] Default field type 값.

Elastic/Elasticsearch 2018. 7. 5. 11:04

elasticsearch 문서 모델링 하면서 잘 알고 있다고 생각 하지만 늘 그렇듯 잘 잊어버립니다.

그래서 올려 봅니다. (어딘가에 글 올려 놓은게 있긴 할테지만.. )



우선, FieldMapper 클래스를 확인 합니다.

여기서 보면 MappedFieldType 클래스로 넘어 가게 됩니다.


그래서 default field type 은 아래와 같습니다.


public MappedFieldType() {
setTokenized(true);
setStored(false);
setStoreTermVectors(false);
setOmitNorms(false);
setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
setBoost(1.0f);
}


:

[Kibana] start and stop 스크립트

Elastic/Kibana 2018. 7. 5. 09:52

Kibana 실행 스크립트.

$ bin/kibana 귀찮아서 그냥 es 에서 쓰던거 복붙.


[start.sh]


#!/bin/bash


DIR_NAME=`dirname "$0"`

DIR_HOME=`cd $DIR_NAME; cd ..; pwd`


$DIR_HOME/bin/kibana> /dev/null 2>&1 & KIBANA_PID=$!

echo $KIBANA_PID > $DIR_HOME/bin/kibana.pid



[stop.sh]


#!/bin/bash


DIR_NAME=`dirname "$0"`

DIR_HOME=`cd $DIR_NAME; cd ..; pwd`


KIBANA_PID=`cat $DIR_HOME/bin/kibana.pid`

kill -9 $KIBANA_PID

echo "Kibana Daemon($KIBANA_PID) is killed"

rm -f $DIR_HOME/bin/kibana.pid


:

[Elasticsearch] 그냥 settings, mappings, template 예제

Elastic/Elasticsearch 2018. 7. 4. 14:05


[Settings]

"settings":{

  "number_of_shards":1,

  "number_of_replicas":0,

  "index.refresh_interval":"1h",

  "index.routing.allocation.require.box_type":"indexing",

  "index.similarity.default.type":"BM25",

  "index":{

    "analysis":{

      "analyzer":{

        "arirang_custom_analyzer":{

          "tokenizer":"arirang_tokenizer",

          "filter":[

              "lowercase",

              "trim",

              "arirang_synonym",

              "arirang_filter"

            ]

          }

      },

      "filter":{

        "arirang_synonym":{

            "type":"synonym_graph",

            "synonyms":[]

          }

        }

      }

  }

}


[Mappings]

"mappings" : {

  "product": {

    "_source": {

      "enabled": true

    },

    "dynamic_templates": [

      {

        "strings": {

          "match_mapping_type": "string",

          "mapping": {

            "type": "text",

            "analyzer": "arirang_custom_analyzer",

              "fields": {

                "raw": {

                  "type":  "keyword",

                  "ignore_above": 50

                }

            }

          }

        }

      }

    ]

  }

}


:

[Jenkins] Gradle 을 이용한 submodule update 이슈

ITWeb/개발일반 2018. 7. 4. 07:53

Jenkins 에서 Gradle 을 이용한 multi project(submodule) build 시 참고사항

젠킨스 소스 관리영역에서 Additional Behaviours 설정을 추가 해줘야 합니다.


- Advanced sub-modules behaviours

여기서 총 세 가지 항목을 선택 하게 됩니다.


- Recursively update submodules

이 설정은 --recursive 옵션을 사용합니다.


- Update tracking submodules to tip of branch

이 설정은 --remote 옵션을 사용합니다.


- Use credentials from default remote of parent repository

이 설정은 parent project 의 credential 을 사용 한다는 의미 입니다. 


여기서 제가 경험한 문제는 submodule 이 업데이트 되지 않는 문제였습니다.

intellij 에서 Project Update 기능과 비슷하다고 보시면 될 것 같은데요.


이 와 같은 기능을 적용하기 위해서는 위 2번째 옵션을 선택해줘야 합니다.


- Update tracking submodules to tip of branch

이 옵션의 의미는 submodules 의 변경된 내용을 업데이트 하기 위한 것입니다.


참고문서)

https://git-scm.com/docs/git-submodule#git-submodule---remote



: