搜索查询在整个部署中运行搜索,并允许您根据指定的搜索词查找所有类型的实体。此外,VMware Aria Operations for Networks 还提供构建查询的建议,其中包括与在全局搜索栏中键入的文本匹配的已保存搜索和近期搜索。

搜索查询可以分为以下类别:
  1. 结构化查询

    结构化查询包含以下组件:

    结构化查询包含 projection、实体类型、filter、group by 和 order by 等部分。

    • 实体类型:实体类型表示要搜索的对象的类型。可以采用单数形式或复数形式。实体类型在结构化查询中必不可少。

      实体类型可以是虚拟机、主机、安全组、VLAN、VXLAN、路由器、流、问题、事件等。

      以下是一些示例:
      1. Virtual machines
      2. Hosts
      3. Flows
      4. MTU Mismatch Alerts
      5. Problems
    • 筛选器:筛选器的语法如下所示:

      filter 必须具有后跟条件的 where 子句。

      条件的语法如下所示:

      条件的语法包括属性、运算符(如等于、大于、in、is set 等)和值。

      可使用筛选器子句筛选搜索结果。筛选器子句中的条件包含属性、比较运算符和值。可以将条件与逻辑运算符组合以形成复杂条件。以下是可以使用的运算符列表:
      运算符 示例
      =

      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%
      like vms where name like 'app'
      not like

      vms where name not like 'app'

      in

      flows where port in (22, 23, 80, 443)

      vm where ip address in (192.168.91.11, 192.168.91.10)

      not in

      flows where port not in (22, 23, 80, 443)

      vm where ip address not in (192.168.91.11, 192.168.91.10)

      is set vms where firewall rule is set
      is not set vms where firewall rule is not set
      () flows where (src tier = ‘App’ and destination tier = ‘DB’) OR (destination tier = ‘App’ and source tier = ‘DB’)
      and flows where src tier = 'App' and destinationtier = 'DB'
      or flows 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')

      投影:查询中的投影子句确定了必须显示筛选后实体中的哪些字段。这是可选子句。如果未指定投影子句,则在搜索结果中显示默认字段集。投影子句可以包含以下任何一项:
      1. 属性
      2. 计数
      3. 列表
      4. 聚合
      5. 级数

      “”(空文本)

      1. 属性:按实体类型搜索实体时,搜索结果中将显示默认属性集。使用投影,可以选择应在搜索结果中显示的字段。例如,os of vms 在搜索结果中列出具有 OS property 的所有虚拟机。
        下面列出了更多这样的示例:
        • cpu cores of vms
        • source ip address of flows

        如果使用衡量指标属性,则会为每个实体显示一个图形,其中衡量指标属性作为 y-axis,时间作为 x-axis

      2. 计数:计数查询可用于计算实体类型的对象数。以下是一些示例:
        • count of vms
        • count of hosts
        • count of flows
      3. 列表:如果无法在您提取的实体上应用筛选条件,则列表运算符很有用。

        例如:

        List(host) of vms where memory <= 2gb

        此查询提取主机列表,但是在虚拟机上应用了筛选条件。例如, List(ip address)of vms where cpu cores = 1

        聚合函数:聚合函数允许根据数字 configmetric 属性计算单个值。搜索查询语言支持以下聚合函数:
        • max
        • sum
        • min
        • avg
        以下是一些示例:
        • sum(memory) of hosts
        • sum(memory), sum(cpu cores) of vms
        • sum(bytes) of flows
      4. 级数:级数运算符用于对衡量指标属性执行聚合。例如:

        series(avg(cpu usage)) of vms where cpu cores = 4

        此查询显示的图形中包含具有 4 个 cpu 内核的所有虚拟机的平均 cpu 使用情况。以下是一些示例:
        • 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 子句中仅允许一个字段。默认情况下,结果按降序进行排序。

      “”(空文本)

      以下是一些示例:

      1. vms order by cpu cores
      2. vms order by cpu cores asc
      3. flows order by bytes

      可以使用 limit 子句限制结果数。此子句前面必须有 order by 子句。例如:

      vms order by memory limit 5
    • 分组:可以按属性对实体进行分组。按属性对实体分组时,默认情况下会显示每个组中的结果数。通过添加投影,可以计算任何属性的总和/最大值/最小值。添加 order by 子句可对结果进行排序。如果查询中存在 order byprojection 子句,则必须存在聚合函数。

      “”(空文本)

      sum(bytes) of flows group by dest vm

      此查询有效,因为查询在投影子句中具有聚合函数。诸如 bytes of flows group by dest vm 之类的查询无效,因为投影子句中没有聚合函数。

      以下是一些示例:
      1. vms group by host
      2. sum (bytes) of flows group by dest vm order by sum(bytes)
  2. 实体查询

    “”(空文本)

    按实体类型搜索:通过搜索实体类型,可以列出该实体类型的所有实体。

    示例:vmshostsflowsnsx managers

    1. 按实体名称搜索
      • 按完整名称搜索:如果知道实体的完整名称,则可以通过将名称括在单引号中对其进行搜索。

        示例:'prod-68-1''app1-72-1'

      • 按部分名称搜索:按单个词或多个词搜索将提取与输入词匹配的所有实体。

        示例:prodapp1

        注: 如果输入包含关键字或实体类型,则可能会将其作为搜索查询进行处理。
      • 按实体类型和名称搜索:如果知道实体的名称和类型,则可以通过一起查询实体类型和实体名称来进行搜索。

        示例:搜索查询 'vm app1' 会返回包含 app1 的所有虚拟机。

  3. 规划查询

    这些查询可以用于通过分析流来规划数据中心的安全性。

    “”(空文本)

    示例:
    1. plan securitygroup1
    2. plan host1
    3. plan security
  4. 路径查询

    这些查询可用于显示两个虚拟机之间的路径或者从虚拟机到 Internet 的路径。

    “”(空文本)

    示例:
    1. Vm 'vm1' to Vm 'vm2'
    2. VM 'vm1' to Internet
注:
  • 搜索查询不区分大小写。
  • 实体类型或配置属性可具有同义词。例如,实体类型 'virtual machine' 具有同义词 'vm'