elasticsearch - 如何从 kibana 获取 JSON?
问题描述
从 Kibana 仪表板中,我得到了这个 JSON。我需要在我的网站中使用“消息”(这是我的脚本的结果),我该怎么做?
注意:脚本是logstash的输入,它被发送到elasticsearch,然后用Kibana可视化,这段代码来自kibana中的JSON部分。
{
"_index": "test",
"_type": "doc",
"_id": "l-RRWncBMkK0B15vMizO",
"_version": 1,
"_score": null,
"_source": {
"command": "sh -c /home/ubuntu/hello.sh",
"host": "elk",
"@version": "1",
"message": "bin\nboot\ndev\netc\nhome\ninitrd.img\ninitrd.img.old\nlib\nlib64\nlost+found\nmedia\nmnt\nopt\nproc\nroot\nrun\nsbin\nsnap\nsrv\nsys\ntmp\nusr\nvar\nvmlinuz\nvmlinuz.old\n",
"@timestamp": "2021-01-31T21:20:06.716Z"
},
"fields": {
"@timestamp": [
"2021-01-31T21:20:06.716Z"
]
},
"sort": [
1612128006716
]
}
解决方案
你的问题似乎不完整。但是,我假设,您正在尝试将事件从 Elasticsearch 访问到您的代码段。
您可以尝试点击 Elasticsearch api 来获取此 json,并访问消息字段。下面的例子:
**SYNTAX**
curl -XGET "<elasticsearch_ip>:<elasticsearchport(default is 9200)>/<index_name>/_search" -H 'Content-Type: application/json' -d'<query to fetch the index documents>'
**EXAMPLE**
curl -XPOST "http://localhost:9200/test/_search" -H 'Content-Type: application/json' -d'{ "query": { "match_all": {} }}'
推荐阅读
- angular - 避免在绑定中调用函数
- html - 根据 rtl 或 ltr 语言自动设置方向和文本对齐
- java - 在 Spring Boot 后端被定向到 404 页面
- amazon-web-services - OSError:libmediainfo.so.0:无法打开共享对象文件:没有来自 aws lambda 的此类文件或目录
- ios - 使用 Facebook 测试深度链接通知在 iOS 中不起作用
- scala - 如何从 Scala 中的向量创建 HashMap
- sql-server - SQL 性能问题:选择 N 行直到找到不同的 200 个客户
- laravel - 拉拉维尔 | 测试
- python - 带有前导/尾随斜杠且不带斜杠的路线
- php - 使用php根据用户输入仅匹配数据库中字段的某些部分从数据库中获取所有数据