浏览量 4871
2019/10/24 21:37
es query查询
es同一字段多条件合并查询:
{
"query":{
"bool":{
"must":[
{
"match_phrase":{
"message":"request"
}
},
{
"match_phrase":{
"message":this.openid
}
}
]
}
},
"_source":[
"message",
"@timestamp"
]
}
axios调用es接口认证解决方法
通过headers中设置:Authorization 来通过验证,Authorization通过正常登陆页面后在headers中获取。此方法牺牲了安全。
JSON.parse(jsonstr):用来解析json字符串,转为json对象。 json.hasOwnProperty(key):用来判断json中是否有此key。
axios.post(es_url, es_data,
{
headers: {
'Authorization': 'Basic ********',
'Content-Type': 'application/json'
}
}
).then((res) => {
res.data.hits.hits.forEach(function (item, index) {
let message = JSON.parse(item['_source']['message'].substring(12))
console.log(message)
let path = ''
let globalticket = ''
let body = ''
if (message.hasOwnProperty("path")) {
path = message['path']
}
if (message.hasOwnProperty('url')) {
path = message['url']
}
if (message.hasOwnProperty('headers')) {
globalticket = '*******=' + message['headers']['globalticket']
}
if (message.hasOwnProperty('body')) {
body = JSON.stringify(message['body'])
}
messsages.push({
"path": path,
"globalticket": globalticket,
"body": body,
"timestamp": item['_source']['@timestamp']
})
})
})
表格设置:
表格内内嵌跳转链接:
<template slot-scope="scope"> <a :href="'http://'+scope.row.globalticket" target="_blank" class="buttonText">{{scope.row.globalticket.split('=')[1]}}</a> </template>
超长隐藏:
<el-table-column
prop="body"
label="body" :show-overflow-tooltip="true">
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
width="240"
sortable
prop="timestamp"
label="timestamp">
</el-table-column>
<el-table-column
width="500"
prop="path"
label="path">
</el-table-column>
<el-table-column
width="500"
prop="globalticket"
label="globalticket" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a :href="'http://'+scope.row.globalticket"
target="_blank"
class="buttonText">{{scope.row.globalticket.split('=')[1]}}</a>
</template>
</el-table-column>
<el-table-column
prop="body"
label="body" :show-overflow-tooltip="true">
</el-table-column>
</el-table>
上一篇 搜索 下一篇