我已經建立了像這樣的彈性堆棧。我正在嘗試通過Filebeat和Topbeat提供自定義索引名稱來提供日誌和頂級數據。Logstash無法爲Filebeat和Packetbeat創建正確的索引
儘管Logstash沒有爲自定義索引名稱傳遞的數據創建任何索引。
Logstash配置:
input{
beats{
port => 27080
congestion_threshold => 1500
}
jmx {
path => "file://Machine01/Users/username/projects/Logstash/logstash/bin/jmx"
polling_frequency => 15
type => "jmx"
nb_thread => 4
}
}
filter {
if [type] == "Type1"{
grok{
break_on_match => false
patterns_dir => ["C:\Users\users\projects\Logstash\logstash\bin\patterns"]
match => { "message" => "%{YEAR:Year}%{MONTHNUM:Month}%{MONTHDAY:Day} %{HOUR:Hour}%{MINUTE:Minute}%{SECOND:Second} %{LogLevel:LogVerbosity} %{MODULE:MODULENAME}%{SPACE}%{MESSAGEID:MESSAGEID} %{SUBMODULE:SUBMODULE} %{MESSAGE:MESSAGE}"}
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
add_tag => ["Groked"]
}
if "_grokparsefailure" in [tags] {
drop { }
}
if [type] == "jmx" {
if ("OperatingSystem.ProcessCpuLoad" in [metric_path] or "OperatingSystem.SystemCpuLoad" in [metric_path]) {
ruby {
code => "event['cpuLoad'] = event['metric_value_number'] * 100"
add_tag => [ "cpuLoad" ]
}
}
}
}
}
output {
if [type] == "jmx" {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "jmx-%{+YYYY.MM.dd}"
}
} else {
elasticsearch {
hosts => ["http://localhost:9200"]
manage_template => true
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
if [type] == "dbtable" {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "dbtable-%{+YYYY.MM.dd}"
}
}
}
}
Filebeat配置:
filebeat:
prospectors:
- paths:
- test.log
input_type: log
tail_files: false
scan_frequency: 3s
backoff: 20s
backoff_factor: 1
document_type: custom
registry:
fields:
type: custom
spool_size: 10000
idle_timeout: 2s
output:
logstash:
index: custom
hosts: ["valid hostname"]
logging:
to_files: true
files:
path: ./
name: filebeat.log
rotateeverybytes: 10485760
level: debug
我期待當我設置index: custom
,應該建立在Elasticsearch索引爲 「定製YYYY.MM.DD」。但它只是在Elasticsearch中創建索引爲「%{[@metadata][beat]}-%{+YYYY.MM.dd}
」。
如果我對#index: custom
發表評論,它會在Elasticsearch中創建索引filebeat-YYYY.MM.dd
。
我錯了,爲什麼它不適用於自定義索引模式?