搜尋查詢
搜尋查詢會在整個部署中執行搜尋,並且可讓您根據指定的搜尋詞彙尋找所有類型的實體。此外,
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
- 路徑查詢這些查詢可用於顯示兩個虛擬機器之間的路徑或從虛擬機器至網際網路的路徑。範例:
- Vm 'vm1' to Vm 'vm2'
- VM 'vm1' to Internet
- 搜尋查詢不區分大小寫。
- 實體類型或組態內容可具有同義詞。例如,實體類型'virtual machine'具有同義詞'vm'。