1

Twitter から Web サービス データを受け取り、ファイルにログを記録しています。その後、そのデータを Logstash に送信して、Elasticsearch にインデックスを作成できるようにする必要があります。

私は以下の設定を使用していますが、それはjsonparsefailureを例外として与えています

JSON 解析の失敗。プレーンテキストへのフォールバック {:error=>#> LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a >valid value (number, String, array, object, 'true' 、「false」または「null」)

私のlogstash confファイルは次のようになります:

input
    {
        file
        {
            path => ["/mnt/volume2/ELK_Prashant/at/events.json"]
            codec => json
            type => json
        start_position => "beginning"
            sincedb_path => "/dev/null"
        }
    }
    output
    {
        stdout { codec => rubydebug }
    }

また、events.json のデータは、以下のサンプルを使用して https://dev.twitter.com/rest/reference/get/search/tweetsから参照できます。events.json

[
{ "location": "LA, CA",
        "follow_request_sent": null,
        "profile_link_color": "0084B4",
        "is_translator": false,
        "id_str": "137238150",
        "entities": {
          "url": {
            "urls": [
              {
                "expanded_url": null,
                "url": ""
              }
            ]
          }
        }
}
]
4

1 に答える 1

1

サンプルevents.jsonファイルから、logstash プラグインへの入力として完全な json オブジェクトを使用していることは明らかですfileが、プラグインはデフォルトで各イベントが 1 行であると想定しており、そのため、入ってくる新しいイベントを検出して追跡することしかできません。現在位置。

したがって、入力ファイルは次のようになります。各イベントは改行文字で区切られています

{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}}
{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}}
{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}}

または、入力プラグインで複数行のコーデックまたはフィルターを使用する必要があります。詳細については、こちらをご覧ください

于 2016-08-07T19:21:35.917 に答える