我的計算機上安裝了 Windows 10,并且 Elasticsearch/Kibana 在 docker 容器中運行。
我正在嘗試使用 Fluentd 將我的應用程式生成的日志重定向到 Elasticsearch。這是 td-agent.conf 檔案:
<source>
@type tail
path C:/Projects/log.json
pos_file C:/Projects/log.json.pos
tag *
format json
time_key @timestamp
</source>
<match **>
@type elasticsearch
logstash_format false
host localhost
port 9200
index_name appname-api-*
type_name fluentd
flush_interval 1s
</match>
這是 appsettings 的一部分,我指定我想要 elasticsearch 格式的 json 檔案:
{
"Name": "File",
"Args": {
"path": "c:/Projects/log.json",
"formatter": "Serilog.Formatting.Elasticsearch.ElasticsearchJsonFormatter, Serilog.Formatting.Elasticsearch"
}
}
這是日志檔案中的一行:
{"@timestamp":"2021-10-22T11:13:39.4325643 03:00","level":"Information","messageTemplate":"Now listening on: {address}","message":"Now listening on: \"http://localhost:5001\"","fields":{"address":"http://localhost:5001","SourceContext":"Microsoft.Hosting.Lifetime","MachineName":"MACHINENAME"}}
但它不起作用。我懷疑我的 td-agent.conf。你能給我提供一些例子嗎?
或者也許切換到 Filebeat 或其他東西更容易?
uj5u.com熱心網友回復:
知道了!這是正確的 td-agent.conf
<system>
log_level debug
</system>
<source>
@type tail
path C:/Projects/log.json
pos_file C:/Projects/log.json.pos
tag log_test
emit_unmatched_lines true
<parse>
@type json
</parse>
</source>
<match log_test>
@type elasticsearch
host localhost
port 9200
index_name appname-api-2021-10
type_name _doc
flush_interval 1s
</match>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/335554.html
上一篇:同一欄位的彈性搜索多個過濾器值
