搜索查询
搜索查询在整个部署中运行搜索,并允许您根据指定的搜索词查找所有类型的实体。此外,
VMware Aria Operations for Networks
还提供构建查询的建议,其中包括与在全局搜索栏中键入的文本匹配的已保存搜索和近期搜索。 搜索查询可以分为以下类别:
- 结构化查询结构化查询包含以下组件:
- 实体类型:实体类型表示要搜索的对象的类型。可以采用单数形式或复数形式。实体类型在结构化查询中必不可少。以下是一些示例:
- Virtual machines
- Hosts
- Flows
- MTU Mismatch Alerts
- Problems
- 筛选器:筛选器的语法如下所示:条件的语法如下所示:可使用筛选器子句筛选搜索结果。筛选器子句中的条件包含属性、比较运算符和值。可以将条件与逻辑运算符组合以形成复杂条件。以下是可以使用的运算符列表:运算符示例=flows where source ip address = '10.16.240.0/24'flows where flow type = 'Source is VM'! =vms where ip address != '10.17.0.0/16'>vms where memory > 4096 mb<vms where cpu usage rate < 70%>=vms where memory >= 4096 mb<=vms where cpu usage rate <= 70%likevms where name like 'app'not likevms where name not like 'app'inflows where port in (22, 23, 80, 443)vm where ip address in (192.168.91.11, 192.168.91.10)not inflows where port not in (22, 23, 80, 443)vm where ip address not in (192.168.91.11, 192.168.91.10)is setvms where firewall rule is setis not setvms where firewall rule is not set()flows where (src tier = ‘App’ and destination tier = ‘DB’) OR (destination tier = ‘App’ and source tier = ‘DB’)andflows where src tier = 'App' and destinationtier = 'DB'orflows where flow type = 'Source is VMKNIC' or flow type = 'Destination is VMKNIC'匹配vm where name matches '.*'vm where name matches 'a.*'vm where name matches '[a-z]vm-delta[0-9]'不匹配vm where name not matches '.*'vm where name not matches 'a.*'vm where name not matches '[a-z]vm-delta[0-9]'嵌套“in”运算符vm where in (vm where name = 'x')vm where in (vm of host where name = 'x')vm where host in (host of vm where name = 'x')vm where name in (name of vm where name = 'x')投影:查询中的投影子句确定了必须显示筛选后实体中的哪些字段。这是可选子句。如果未指定投影子句,则在搜索结果中显示默认字段集。投影子句可以包含以下任何一项:
- 属性
- 计数
- 列表
- 聚合
- 级数
- 属性:按实体类型搜索实体时,搜索结果中将显示默认属性集。使用投影,可以选择应在搜索结果中显示的字段。例如,os of vms在搜索结果中列出具有OS property的所有虚拟机。下面列出了更多这样的示例:
- cpu cores of vms
- source ip address of flows
如果使用衡量指标属性,则会为每个实体显示一个图形,其中衡量指标属性作为y-axis,时间作为x-axis。 - 计数:计数查询可用于计算实体类型的对象数。以下是一些示例:
- count of vms
- count of hosts
- count of flows
- 列表:如果无法在您提取的实体上应用筛选条件,则列表运算符很有用。例如:List(host) of vms where memory <= 2gb此查询提取主机列表,但是在虚拟机上应用了筛选条件。例如,List(ip address)of vms where cpu cores = 1聚合函数:聚合函数允许根据数字config或metric属性计算单个值。搜索查询语言支持以下聚合函数:
- max
- sum
- min
- avg
- sum(memory) of hosts
- sum(memory), sum(cpu cores) of vms
- sum(bytes) of flows
- 级数:级数运算符用于对衡量指标属性执行聚合。例如:此查询显示的图形中包含具有 4 个 cpu 内核的所有虚拟机的平均 cpu 使用情况。以下是一些示例:series(avg(cpu usage)) of vms where cpu cores = 4
- series(sum(network usage)) of vms where name like 'app'
- series(sum(memory usage)) of vms where name like 'db'
- series(avg(cpu usage)), series(avg(memory usage)) of vms
- 排序:可以使用order by子句对搜索结果进行排序。order by子句中仅允许一个字段。默认情况下,结果按降序进行排序。以下是一些示例:
- vms order by cpu cores
- vms order by cpu cores asc
- flows order by bytes
可以使用limit子句限制结果数。此子句前面必须有order by子句。例如:vms order by memory limit 5 - 分组:可以按属性对实体进行分组。按属性对实体分组时,默认情况下会显示每个组中的结果数。通过添加投影,可以计算任何属性的总和/最大值/最小值。添加order by子句可对结果进行排序。如果查询中存在order by或projection子句,则必须存在聚合函数。sum(bytes) of flows group by dest vm以下是一些示例:此查询有效,因为查询在投影子句中具有聚合函数。诸如bytes of flows group by dest vm之类的查询无效,因为投影子句中没有聚合函数。
- vms group by host
- sum (bytes) of flows group by dest vm order by sum(bytes)
- 实体查询按实体类型搜索:通过搜索实体类型,可以列出该实体类型的所有实体。示例:vms、hosts、flows、nsx managers
- 按实体名称搜索
- 按完整名称搜索:如果知道实体的完整名称,则可以通过将名称括在单引号中对其进行搜索。示例:'prod-68-1'、'app1-72-1'
- 按部分名称搜索:按单个词或多个词搜索将提取与输入词匹配的所有实体。示例:prod、app1如果输入包含关键字或实体类型,则可能会将其作为搜索查询进行处理。
- 按实体类型和名称搜索:如果知道实体的名称和类型,则可以通过一起查询实体类型和实体名称来进行搜索。示例:搜索查询'vm app1'会返回包含app1的所有虚拟机。
- 规划查询这些查询可以用于通过分析流来规划数据中心的安全性。示例:
- plan securitygroup1
- plan host1
- plan security
- 路径查询这些查询可用于显示两个虚拟机之间的路径或者从虚拟机到 Internet 的路径。示例:
- Vm 'vm1' to Vm 'vm2'
- VM 'vm1' to Internet
- 搜索查询不区分大小写。
- 实体类型或配置属性可具有同义词。例如,实体类型'virtual machine'具有同义词'vm'。