【发布时间】:2021-10-22 08:29:14
【问题描述】:
我的计算机上安装了 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 或其他方式更容易?
【问题讨论】:
标签: elasticsearch serilog fluentd