elasticsearch - Logstash 文件名作为 ElasticSearch 索引
问题描述
我使用文件夹作为输入:
input {
file {
path => "C:/ProjectName/Uploads/*"
start_position => "beginning"
sincedb_path => "dev/null"
}
}
并作为输出:
output {
elasticsearch {
hosts => "localhost"
index => "manual_index_name" # want filename here
document_type => "_doc"
}
}
我希望 elasticsearch 中的索引是被索引的文件的名称。我尝试了这个答案的变体但没有成功,因为我不清楚它在做什么:https ://stackoverflow.com/a/40156466/6483906
解决方案
您需要使用grok
过滤器来查找文件名的最后一部分:
filter {
grok {
match => ["path", "Uploads/%{GREEDYDATA:index_name}" ]
}
}
然后只需使用索引名称中的部分index => "%{index_name}"
推荐阅读
- python-3.x - Create folders as a function parameter in python
- python - Close flask application when browser gets closed
- ios - Firestore Pagination get next batch of data
- r - Function with optimized parameters does not come close to data using mle2 in R
- python - What is the difference between "import package" versus "from package import ..."?
- shell - “无法创建目录/mnt/.local/share/nano/:没有这样的文件或目录它是保存/加载搜索历史或光标位置所必需的。”
- google-apps-script - 如何使用 Google 应用脚本集成 Google Ads Manager (GAM)
- python - 从python中的列表列表中过滤掉一个列表
- angularjs - ngIf 在我刷新后立即抛出错误消息
- c# - 如何使用 NUnit 和 Moq 模拟视图/控制器?