[速報]Elastic Stackの新バージョンがリリースされました(Elasticsearch2.3、Logstash2.3、Kibana4.5、Beats1.2)

2016.03.31

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

藤本です。

本日(現地時間3/30)、Elastic Stackの新バージョンがリリースされました。
つい二ヶ月弱前に新バージョンがリリースされたばかりなのに、もう新バージョンですよ。リリースペースが早いのは開発者にとっては嬉しい限りですね。一方でバージョンアップどうする?的な悩みも出てきますが。。

Elastic{ON}2016のセッションで紹介されていた機能もいくつか盛り込まれています。

概要

まずはリリース情報をお伝えするとともに、インストールだけ試してみました。
新機能は後ほどコツコツと試してエントリします。

Elasticsearch 2.3.0

インストール

公式ページから任意の形式でダウンロードできます。 (YUM Repositoryからインストールしようとしたら404 Not Foundになった)

# rpm -ivh https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.0/elasticsearch-2.3.0.rpm
Retrieving https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.0/elasticsearch-2.3.0.rpm
warning: /var/tmp/rpm-tmp.V2LjO4: Header V4 RSA/SHA1 Signature, key ID d88e42b4: NOKEY
Preparing...                          ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Updating / installing...
   1:elasticsearch-2.3.0-1            ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service

# systemctl daemon-reload

# systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

# systemctl start elasticsearch.service

# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-03-31 01:41:27 UTC; 2s ago
     Docs: http://www.elastic.co
  Process: 11694 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 11695 (java)
   CGroup: /system.slice/elasticsearch.service
           └─11695 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseC...
・・・

いつも通り簡単ですね。

Lucene 5.5.0

ベースとなるApache Luceneが5.4.1から5.5.0にアップグレードされました。

# curl localhost:9200
{
  "name" : "Leonus",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.3.0",
    "build_hash" : "8371be8d5fe5df7fb9c0516c474d77b9feddd888",
    "build_timestamp" : "2016-03-29T07:54:48Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}

Reindex API

今回のリリースの目玉ではないでしょうか?
Elasticsearchでインデックスを再構成するReindex APIが新機能として追加されました。Elasticsearchを運用しているとインデックスのフィールド情報を変更したい、Analyzerを変更したい、といったことがよくあるのではないでしょうか。Logstashにより複製などせずとも、Elasticsearchネイティブの機能として提供を開始しました。

# curl -XPOST "localhost:9200/_reindex?pretty" -d '{
>   "source": {
>     "index": "my-index"
>   },
>   "dest": {
>     "index": "my-new-index"
>   }
> }'
{
  "took" : "506.5ms",
  "timed_out" : false,
  "total" : 1,
  "updated" : 0,
  "created" : 1,
  "batches" : 1,
  "version_conflicts" : 0,
  "noops" : 0,
  "retries" : 0,
  "failures" : [ ]
}

単純なインデックスの複製だけではなく、Queryで絞ったり、Typeで絞ったり、複数のインデックスをまとめたり、といったことも可能です。

今後もdynamic throttling、reindex-in-place、reindexing from remote clustersなどといった機能を追加予定とのことですが、どういった機能になるか期待したいです。reindex-in-placeは新しいインデックスを作らずとも構成変更ができるということでしょうか。

Logstash 2.3.0

インストール

公式ページから任意の形式でダウンロードできます。RedHat系OSであれば、YUM Repositoryからのインストールも可能です。

# vi /etc/yum.repos.d/elastic.repo
[logstash-2.3]
name=Logstash repository for 2.3.x packages
baseurl=http://packages.elastic.co/logstash/2.3/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

# yum install logstash
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package logstash.noarch 1:2.3.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package               Arch                Version                 Repository                 Size
===================================================================================================
Installing:
 logstash              noarch              1:2.3.0-1               logstash-2.3               71 M

Transaction Summary
===================================================================================================
Install  1 Package

Total download size: 71 M
Installed size: 125 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/logstash-2.3/packages/logstash-2.3.0-1.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID d88e42b4: NOKEY
Public key for logstash-2.3.0-1.noarch.rpm is not installed
logstash-2.3.0-1.noarch.rpm                                                 |  71 MB  00:00:36
Retrieving key from http://packages.elastic.co/GPG-KEY-elasticsearch
Importing GPG key 0xD88E42B4:
 Userid     : "Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org>"
 Fingerprint: 4609 5acc 8548 582c 1a26 99a9 d27d 666c d88e 42b4
 From       : http://packages.elastic.co/GPG-KEY-elasticsearch
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:logstash-2.3.0-1.noarch                                                       1/1
  Verifying  : 1:logstash-2.3.0-1.noarch                                                       1/1

Installed:
  logstash.noarch 1:2.3.0-1

Complete!

# /opt/logstash/bin/logstash --version
logstash 2.3.0

Dynamic Config Reload

Logstashのセッションでも紹介があった設定のリロードです。起動オプションを与えることで設定ファイルを変更すると動的に反映されます。

Environment Variables In Configuration

Logstashの設定ファイルに環境変数を利用できるようになりました。

# export TCP_PORT=12345
[設定ファイル]
input {
  tcp {
    port => "$TCP_PORT"
  }
}
 ↓
input {
  tcp {
    port => 12345
  }
}

Java Event: Performance Gains Across The Board

Logstashのスループットが向上しました。ケースによっては79%も向上したようです。

Per_comparision_image

Kibana 4.5.0

インストール

公式ページから任意の形式でダウンロードできます。RedHat系OSであれば、YUM Repositoryからのインストールも可能です。

# vi /etc/yum.repos.d/elastic.repo
[kibana-4.5]
name=Kibana repository for 4.5.x packages
baseurl=http://packages.elastic.co/kibana/4.5/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

# yum install kibana
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kibana.x86_64 0:4.5.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package              Arch                 Version                  Repository                Size
===================================================================================================
Installing:
 kibana               x86_64               4.5.0-1                  kibana-4.5                32 M

Transaction Summary
===================================================================================================
Install  1 Package

Total download size: 32 M
Installed size: 118 M
Is this ok [y/d/N]: y
Downloading packages:
kibana-4.5.0-1.x86_64.rpm                                                   |  32 MB  00:00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kibana-4.5.0-1.x86_64                                                           1/1
  Verifying  : kibana-4.5.0-1.x86_64                                                           1/1

Installed:
  kibana.x86_64 0:4.5.0-1

Complete!

# systemctl start kibana

# systemctl status kibana
● kibana.service - no description given
   Loaded: loaded (/usr/lib/systemd/system/kibana.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-03-31 02:47:39 UTC; 5s ago
 Main PID: 12252 (node)
   CGroup: /system.slice/kibana.service
           └─12252 /opt/kibana/bin/../node/bin/node /opt/kibana/bin/../src/cli

Settings_-_Kibana

Graph Release

Kibana PluginにGraphがリリースされました。Graphはデータ間の関係性を視覚化することで潜在的な繋がりを発見できるような可視化ツールとなります。こちらは別途エントリします。

Metric Labels

Visualizeでメトリックに対して任意の名称(Label)を付与することが可能となりました。

Visualize_-_Kibana

Beats 1.2.0

インストール

公式ページから任意の形式でダウンロードできます。RedHat系OSであれば、YUM Repositoryからのインストールも可能です。

今回は代表としてFilebeatをインストールします。

# vi /etc/yum.repos.d/elastic.repo
[beats]
name=Elastic Beats Repository
baseurl=https://packages.elastic.co/beats/yum/el/$basearch
enabled=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
gpgcheck=1

# yum install filebeat
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
logstash-2.3                                                                                   1/1
Resolving Dependencies
--> Running transaction check
---> Package filebeat.x86_64 0:1.2.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package                 Arch                  Version                  Repository            Size
===================================================================================================
Installing:
 filebeat                x86_64                1.2.0-1                  beats                3.9 M

Transaction Summary
===================================================================================================
Install  1 Package

Total download size: 3.9 M
Installed size: 3.9 M
Is this ok [y/d/N]: y
Downloading packages:
filebeat-1.2.0-x86_64.rpm                                                   | 3.9 MB  00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : filebeat-1.2.0-1.x86_64                                                         1/1
  Verifying  : filebeat-1.2.0-1.x86_64                                                         1/1

Installed:
  filebeat.x86_64 0:1.2.0-1

Complete!

# /usr/bin/filebeat --version
filebeat version 1.2.0 (amd64)

# systemctl start filebeat
# systemctl status filebeat
● filebeat.service - filebeat
   Loaded: loaded (/usr/lib/systemd/system/filebeat.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-03-31 03:14:47 UTC; 3s ago
     Docs: https://www.elastic.co/guide/en/beats/filebeat/current/index.html
 Main PID: 12487 (filebeat)
   CGroup: /system.slice/filebeat.service
           └─12487 /usr/bin/filebeat -c /etc/filebeat/filebeat.yml

Expand environment variables in configuration files

Logstashと同じく設定ファイルに環境変数を利用できるようになりました。更にBeatsの場合、環境変数がなかった時のデフォルト値の指定も可能となっています。

例えば、以下は環境変数にElasticsearchがあればその値を、環境変数が定義されていなければlocalhostを設定します。

output:      
    elasticsearch:        
        hosts: [“${ELASTICSEARCH:localhost}:9200”]

Managing the Elasticsearch template

Index Templateを事前にElasticsearchに定義しなくても、BeatsにTemplate設定ファイルを定義することで自動でIndex Templateを生成します。

# vi /etc/filebeat/filebeat.yml
output:
  elasticsearch:
    template:
      name: "filebeat"
      path: "/etc/filebeat/filebeat.template.json"

# systemctl restart filebeat

# curl "localhost:9200/_template/filebeat?pretty"
{
  "filebeat" : {
    "order" : 0,
    "template" : "filebeat-*",
    "settings" : {
      "index" : {
        "refresh_interval" : "5s"
      }
    },
    "mappings" : {
      "_default_" : {
        "dynamic_templates" : [ {
          "template1" : {
            "mapping" : {
              "ignore_above" : 1024,
              "index" : "not_analyzed",
              "type" : "{dynamic_type}",
              "doc_values" : true
            },
            "match" : "*"
          }
        } ],
        "_all" : {
          "norms" : {
            "enabled" : false
          },
          "enabled" : true
        },
        "properties" : {
          "@timestamp" : {
            "type" : "date"
          },
          "offset" : {
            "type" : "long",
            "doc_values" : "true"
          },
          "message" : {
            "index" : "analyzed",
            "type" : "string"
          }
        }
      }
    },
    "aliases" : { }
  }
}

4/12(火) Elastic社と共催でイベントを開催決定!!

【Developers.IO 特別編】Elastic 勉強会 #cmdevioから申し込み可能ですが、既に定員オーバー。。すみません。
増枠、キャンセルの可能性もありますので是非お申し込みいただければ、と思います!

まとめ

いかがでしたでしょうか?気になる機能はありましたか?
これから機能レベルで試してみてブログエントリします。