elasticsearch - Elasticsearch、Kibana、Vega Sankey - 自定义查询以仅针对 Top Talker IP 地址显示 Sankey
问题描述
我想在 Kibana 中创建 Sankey 图,仅用于网络流量上的顶级谈话者 IP 地址。Elasticsearch 有数千个关于连接的文档。文档包含源 IP、目标 IP 和字节数。目前我使用 Kibana 的 Vega 插件来显示所有连接(所有源 ips)的桑基图。 https://www.elastic.co/blog/sankey-visualization-with-vega-in-kibana
Vega 的 Elasticsearch 查询如下所示:
{
$schema: https://vega.github.io/schema/vega/v3.0.json
title: Source/Destination Flows
data: [
{
name: rawData
url: {
%context%: true
%timefield%: ts
index: graylog*
body: {
size: 0
aggs: {
table: {
composite: {
size: 30
sources: [
{
stk1: {
terms: {field: "srcip"}
}
}
{
stk2: {
terms: {field: "dstip"}
}
}
]
}
}
}
}
}
format: {property: "aggregations.table.buckets"}
transform: [
{type: "formula", expr: "datum.key.stk1", as: "stk1"}
{type: "formula", expr: "datum.key.stk2", as: "stk2"}
{type: "formula", expr: "datum.doc_count", as: "size"}
]
}
...
为了捕捉顶级谈话者 IP,我创建了这样的查询:
GET /graylog_0/_search
{
"size": 0,
"aggs": {
"top_talker_by_traffic_value": {
"terms": {
"field": "srcip",
"size": 1,
"order": {
"total_bytes": "desc"
}
},
"aggs": {
"total_bytes": {
"sum": {
"field": "byt"
}
}
}
}
}
}
我的问题是,我可以使用该查询结果中的 IP 地址在 Vega 插件中进行另一个查询(类似于“WHERE srcip =“{IP Address from first query}”。如果是,我可以只通过一个查询来完成吗?
解决方案
推荐阅读
- android - 为什么我会收到“Gradle task assembleDebug failed with exit code 1”?
- reactjs - React 中选项的唯一键
- sql - SQL 查询以查找一天中有 3 笔交易的人的详细信息
- flutter - 拒绝设置不安全的标头“User-Agent”
- flutter - 有什么方法可以添加 CircularProgressIndicator 以获取响应表单 dio 请求
- java - Swagger Schema - 模式不适用于字符串数组
- r - 基于 glmnet 包最能区分组的变量
- sql - 如何在 TypeORM 中按字符串长度排序?
- javascript - 未捕获的 ReferenceError:未定义 jQuery(Thymeleaf)
- sql - 连接具有不同数据类型的 2 个表