| No | 日付 | タイトル |
|---|---|---|
| 7 | 2019.11.01 | Twitterのつぶやき履歴を集めてみる 3 |
| 6 | 2019.10.14 | Twitterのつぶやき履歴を集めてみる 2 |
| 5 | 2019.10.10 | Twitterのつぶやき履歴を集めてみる 1 |
| 4 | 2019.10.10 | インストール 3 |
| 3 | 2019.10.09 | インストール 2 |
| 2 | 2019.10.09 | インストール 1 |
| 1 | 2019.10.09 | 基本 |
Elasticsearch, Elastic Stack
| No | 日付 | タイトル |
|---|---|---|
| 7 | 2019.11.01 | Twitterのつぶやき履歴を集めてみる 3 |
| 6 | 2019.10.14 | Twitterのつぶやき履歴を集めてみる 2 |
| 5 | 2019.10.10 | Twitterのつぶやき履歴を集めてみる 1 |
| 4 | 2019.10.10 | インストール 3 |
| 3 | 2019.10.09 | インストール 2 |
| 2 | 2019.10.09 | インストール 1 |
| 1 | 2019.10.09 | 基本 |
output {
stdout {
codec => rubydebug
}
elasticsearch {
hosts => "http://localhost:9200/"
}
}
Elasticsearchの起動は : 省略
{
"@version" => "1",
"path" => "d:/temp/20191011/CSV/work191010.csv",
"host" => "DESKTOP-37HDMPE",
"@timestamp" => 2019-10-31T08:13:09.688Z,
"tags" => [
[0] "csv"
],
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\""
}
filter {
csv {
}
}
この状態でlogstashを起動するとコンソールにCSVの内容が表示される : 省略
{
"tags" => [
[0] "csv"
],
"@version" => "1",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"column1" => "1182187647629873152",
"@timestamp" => 2019-10-31T22:31:34.928Z,
"path" => "d:/temp/20191011/CSV//work191010.csv",
"host" => "DESKTOP-37HDMPE",
"column2" => "191010 155433",
"column3" => "テスト"
}
不要な項目(フィールド)を消したい場合は remove_fieldオプションを指定 "remove_field => [フィールド名,…]"filter {
csv {
remove_field => ["column1","host","path"]
}
}
出力結果{
"column2" => "191010 155433",
"@version" => "1",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"tags" => [
[0] "csv"
],
"@timestamp" => 2019-10-31T22:42:03.559Z,
"column3" => "テスト"
}
@timestampはLogstashがデータを取り込んだ時間。filter {
csv {
convert => {
"column2" => "date_time"
}
remove_field => ["column1","host","path"]
}
date {
match => [ "column2", "YYMMdd HHmmss" ]
}
}
出力結果{
"column2" => "191010 155433",
"message" => "\"1182187647629873152\",\"191010 155433\",\"テスト\"",
"@timestamp" => 2019-10-10T06:54:33.000Z,
"@version" => "1",
"column3" => "テスト",
"tags" => [
[0] "csv"
]
}
input{
file{
path => "d:/temp/20191011/csv//*.CSV"
start_position => "beginning"
tags => "csv"
}
}
output{
stdout{ codec => rubydebug }
}
そういうものか、ということで先に進む。input{
利用するプラグイン名{
設定を記載
}
}
input{
file{
path => "/フォルダのフルパス/logs/**.csv"
}
}
output{
stdout{ codec => rubydebug }
}
input{
file{
path => "d:\temp\20191011\csv\**.csv"
start_position => "beginning"
tags => "csv"
}
}
output{
stdout{ codec => rubydebug }
}
C:\Windows\system32>cd /d c:\apps\logstash-7.4.0 c:\apps\logstash-7.4.0>.\bin\logstash.bat -f .\config\logstash.conf→ コンソールにCSVデータが出力される、らしいが出ない…
[2019-10-11T17:03:53,279][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
#elasticsearch.hosts: ["http://localhost:9200"]↓
elasticsearch.hosts: ["http://localhost:9200"]
input {
stdin { }
}
output {
stdout { codec => rubydebug }
}
D:\>cd /d c:\apps\logstash-7.4.0 c:\apps\logstash-7.4.0>.\bin\logstash -f .\config\logstash.confしばらく待つと Successfully started Logstash API endpoint の表示で待機となる。
Thread.exclusive is deprecated, use Thread::Mutex
Sending Logstash logs to c:/apps/logstash-7.4.0/logs which is now configured via log4j2.properties
[2019-10-10T12:23:46,021][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-10-10T12:23:46,039][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.4.0"}
[2019-10-10T12:23:48,327][INFO ][org.reflections.Reflections] Reflections took 48 ms to scan 1 urls, producing 20 keys and 40 values
[2019-10-10T12:23:51,869][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization. It is recommended to log an issue to the responsible developer/development team.
[2019-10-10T12:23:51,877][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, :thread=>"#"}
[2019-10-10T12:23:52,014][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"}
The stdin plugin is now waiting for input:
[2019-10-10T12:23:52,124][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-10-10T12:23:52,518][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
適当に "hello world" と入力してみるhello world
C:/apps/logstash-7.4.0/vendor/bundle/jruby/2.5.0/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
{
"message" => "hello world\r",
"@version" => "1",
"host" => "DESKTOP-37HDMPE",
"@timestamp" => 2019-10-10T03:26:16.934Z
}
とりあえず問題なし?と思われるC:\Windows\system32>java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
# Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space -Xms1g -Xmx1g
[INFO ][o.e.x.s.s.SecurityStatusChangeListener] [DESKTOP-37HDMPE] Active license is now [BASIC]; Security is disabledから動かなくなったので、おそらく起動完了
{
"name" : "DESKTOP-37HDMPE",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "2Nl7BGrzRM-qwq8P8NhAng",
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}