Subscribed unsubscribe Subscribe Subscribe

ふり返る暇なんて無いね

日々のメモ書きをつらつらと

Elasticsearchを1.4以上に上げたらkibana3がElasticsearchにConnection Failedする際の対処

Elasticsearchを1.4以降からセキュリティの関係でクロスドメイン通信が無効にされています。


この関係で、Elasticsearch1.3系から1.5系に上げたらkibana3がElasticsearchに接続できなくなったので、対処をメモ。

というか、エラーメッセージに書いてある通りのことすればいいんですけどね。

Connection Failed

Possibility #1: Your elasticsearch server is down or unreachable

This can be caused by a network outage, or a failure of the Elasticsearch process. If you have recently run a query that required a terms facet to be executed it is possible the process has run out of memory and stopped. Be sure to check your Elasticsearch logs for any sign of memory pressure.

Possibility #2: You are running Elasticsearch 1.4 or higher

Elasticsearch 1.4 ships with a security setting that prevents Kibana from connecting. You will need to set the following in your elasticsearch.yml:

  1. http.cors.enabled: true
  2. http.cors.allow-origin to the correct protocol, hostname, and port (if not 80) that your access Kibana from. Note that if you are running Kibana in a sub-url, you should exclude the sub-url path and only include the protocol, hostname and port. For example, http://mycompany.com:8080, not http://mycompany.com:8080/kibana.

Click back, or the home button, when you have resolved the connection issue

前提

  • Elasticsearch 1.5.2
  • Kibana 3.1.2
  • Elasticsearchとkibanaはそれぞれ別のhostで動いている
    • elasticsearch.masasuzu.local
    • kibana3.masasuzu.local

対処

elasticsearch.ymlに下記の設定を追記ししてElasticsearchを再起動します。

http.cors.enabled: true
http.cors.allow-origin: http://kibana3.masasuzu.local

http.cors.allow-originはデフォルトだと*になっていて良くないので、変えておきます。この設定は構成によって変わりうります。