gpt4 book ai didi

elasticsearch - 如何获取ElasticSearch输出?

转载 作者:行者123 更新时间:2023-12-02 23:16:28 25 4
gpt4 key购买 nike

我想将日志文档添加到ElasticSearch中,然后在ElasticSearch中检查该文档。
以下是日志文件的内容:

Jan  1 06:25:43 mailserver14 postfix/cleanup[21403]: BEF25A72965: message-id=<20130101142543.5828399CCAF@mailserver14.example.com>
Feb 2 06:25:43 mailserver15 postfix/cleanup[21403]: BEF25A72999: message-id=<20130101142543.5828399CCAF@mailserver15.example.com>
Mar 3 06:25:43 mailserver16 postfix/cleanup[21403]: BEF25A72998: message-id=<20130101142543.5828399CCAF@mailserver16.example.com>

我可以使用以下logstast配置文件运行logstash实例:
input {
file {
path => "/Myserver/mnt/appln/somefolder/somefolder2/testData/fileValidator-access.LOG"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}

filter {
grok {
patterns_dir => ["/Myserver/mnt/appln/somefolder/somefolder2/logstash/pattern"]
match => { "message" => "%{SYSLOGBASE} %{POSTFIX_QUEUEID:queue_id}: %{GREEDYDATA:syslog_message}" }
}
}

output{
elasticsearch{
hosts => "localhost:9200"
document_id => "test"
index => "testindex"
action => "update"
}
stdout { codec => rubydebug }
}

我将自己的grok模式定义为:

POSTFIX_QUEUEID [0-9A-F]{10,11}



当我运行logstash实例时,我成功地将数据发送到了elasticsearch,它提供了以下输出: enter image description here

现在,我已经将索引存储在 testindex 下的 flex 搜索中,但是当我使用 curl -X GET "localhost:9200/testindex"时,我得到以下输出:
{
"depositorypayin" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date" : "1547795277865",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "5TKW2BfDS66cuoHPe8k5lg",
"version" : {
"created" : "6050499"
},
"provided_name" : "depositorypayin"
}
}
}
}

这不是索引内存储的内容。我想查询索引内的文档。请帮忙。 (PS:请原谅我的错字)

最佳答案

您上面使用的API仅返回有关索引本身的信息(docs here)。您需要使用Query DSL搜索文档。以下Match All Query将返回索引testindex中的所有文档:

curl -X GET "localhost:9200/testindex/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
}
}
'

关于elasticsearch - 如何获取ElasticSearch输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54249752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com