24.4. 搜索事件
events 集合提供了和其它资源相似的搜索查询。在对 events 集合进行搜索时,可以只对特定的事件进行搜索,它会查询从一个特定事件后发生的所有事件。
从一个事件开始查询需要在搜索查询前添加一个额外的
from 参数。from 的参数值代表了一个事件的 id 代码。
例 24.3. 从一个事件开始搜索
GET /api/events;from=1012?search=type%3D30 HTTP/1.1
Accept: application/xml
显示事件
id="1012" 后 type 为 30 的所有事件
HTTP/1.1 200 OK
Content-Type: application/xml
<events>
<event id="1018" href="/api/events/1018">
<description>User admin logged in.</description>
<code>30</code>
<severity>normal</severity>
<time>2011-07-11T14:03:22.485+10:00</time>
<user id="80b71bae-98a1-11e0-8f20-525400866c73"
href="/api/users/80b71bae-98a1-11e0-8f20-525400866c73"/>
</event>
<event id="1016" href="/api/events/1016">
<description>User admin logged in.</description>
<code>30</code>
<severity>normal</severity>
<time>2011-07-11T14:03:07.236+10:00</time>
<user id="80b71bae-98a1-11e0-8f20-525400866c73"
href="/api/users/80b71bae-98a1-11e0-8f20-525400866c73"/>
</event>
<event id="1014" href="/api/events/1014">
<description>User admin logged in.</description>
<code>30</code>
<severity>normal</severity>
<time>2011-07-11T14:02:16.009+10:00</time>
<user id="80b71bae-98a1-11e0-8f20-525400866c73"
href="/api/users/80b71bae-98a1-11e0-8f20-525400866c73"/>
</event>
</events>
例 24.4. 使用一个特定的事件严重性进行搜索
GET /api/events?search=severity>normal HTTP/1.1
Accept: application/xml
这会显示所有严重性高于
normal 的事件。严重性级别包括 normal、warning、error 和 alert。
HTTP/1.1 200 OK
Content-Type: application/xml
<events>
<event id="2823" href="/api/events/2823">
<description>Host Host-05 has time-drift of 36002 seconds while maximum configured value is 300 seconds.</description>
<code>604</code>
<severity>warning</severity>
<time>2015-07-11T14:03:22.485+10:00</time>
<host href= "/api/hosts/44e52bb2-27d6-4d35-8038-0c4b4db89789" id="44e52bb2-27d6-4d35-8038-0c4b4db89789"/>
<cluster href= "/api/clusters/00000001-0001-0001-0001-00000000021b" id="00000001-0001-0001-0001-00000000021b"/>
<origin>oVirt</origin>
<custom_id>-1</custom_id>
<flood_rate>30</flood_rate>
</event>
...
</events>