Watcher email messages are not UTF-8 encoded


(Yu Watanabe) #1

I have a environment as below .

[root@Test-Env mail]# rpm -qa | grep elasticsearch
elasticsearch-5.0.0_beta1-1.noarch
[root@Test-Env mail]# /usr/share/elasticsearch/bin/elasticsearch-plugin list
x-pack@5.0.0-beta1

However, I want to use UTF-8 charcters in email subject and body but Watcher is not encoding with UTF-8.

Thus the strings gets corrupted.

Message-ID: test_8-2016-09-30T08:40:35.492Z
Subject: =?UTF-8?B?55Ww5bi444OX44Ot44K744K55Lu25pWwIDU=?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_4_284485771.1475224835571"
X-Priority: 2
From: elasticsearch@BS-POC-Test-Env.localdomain

------=_Part_4_284485771.1475224835571
Content-Type: multipart/related;
boundary="----=_Part_5_1375459366.1475224835571"

------=_Part_5_1375459366.1475224835571
Content-Type: multipart/alternative;
boundary="----=_Part_6_1756655719.1475224835571"

------=_Part_6_1756655719.1475224835571
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64

55Ww5bi444OX44Ot44K744K544Gu5LiA6Kan

Is there a way to encode the messages in subject and body with UTF-8?
Specifically, I am using Japanese characters.


(Lee Drengenberg) #2

Hi,

If we focus first on the email subject. Can you do a get on that watch after you load it and confirm that your subject was stored correctly in Elasticsearch? I'm just trying to understand if the problem is in the creation of the watch or when it executes and sends the email.

Thanks,
Lee


(Yu Watanabe) #3

Ok.

I now use the elasticsearch beta .

[root@BS-POC-Test-Env y-watanabe]# rpm -qa | grep elasticsearch
elasticsearch-5.0.0_beta1-1.noarch

Below is the definition I have inserted with PUT request.
Subject is in Japanese.

PUT _xpack/watcher/watch/test_20161012
{
  "metadata" : { 
    "color" : "red"
  },
  "trigger" : { 
    "schedule" : {
      "interval" : "5m"
    }
  },
  "input" : { 
    "search" : {
      "request" : {
        "indices" : "syslog",
        "body" : {
          "query" : {
            "bool" : {
              "must" : [
                {"match" : { "program.keyword" : "kibana" }},
                {"range" : { "@timestamp" : {"gte" : "now-5m", "lte" : "now" } } }
              ]
            }
          }
        }
      }
    }
  },
  "condition" : { 
    "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
  },
  "actions" : { 
    "email_administrator" : {
      "email" : {
        "to" : "root@localhost.localdomain",
        "subject" : "あいうえお {{ctx.payload.hits.total}}",
        "body" : "Error message",
        "attachments" : {
          "attached_data" : {
            "data" : {
              "format" : "json"
            }
          }
        },
        "priority" : "high"
      }
    }
  }
}

I have done a get against test-20161012 and it looks like the terms are stored properly.


(Yu Watanabe) #4

As a execution result , mail subject is corrupted.

From elasticsearch@BS-POC-Test-Env.localdomain  Wed Oct 12 11:02:41 2016
Return-Path: <elasticsearch@BS-POC-Test-Env.localdomain>
X-Original-To: root@localhost.localdomain
Delivered-To: root@localhost.localdomain
Received: from 10.4.0.4 (localhost [127.0.0.1])
        by BS-POC-Test-Env.localdomain (Postfix) with ESMTP id 1039241D2ABF
        for <root@localhost.localdomain>; Wed, 12 Oct 2016 11:02:41 +0900 (JST)
Date: Wed, 12 Oct 2016 11:02:40 +0900 (JST)
To: root@localhost.localdomain
Message-ID: test_20161012_0-2016-10-12T02:02:39.140Z
Subject: =?UTF-8?B?44GC44GE44GG44GI44GKIDMx?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
        boundary="----=_Part_13148_1469291581.1476237761031"

Just to be sure, I have checked that my server's LANG setting is UTF-8.

[root@BS-POC-Test-Env mail]# env | grep LANG
LANG=en_US.UTF-8

(Yu Watanabe) #5

Any update with this issue?


(system) #6