[doc] add example of complex target query

This commit is contained in:
Julien Vehent 2014-09-19 15:01:56 -04:00
Родитель 658a51a73b
Коммит 16a1982f2f
2 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -145,7 +145,7 @@ The format for compliance items is simple, to be easily graphed and aggregated.
.. code:: javascript .. code:: javascript
{ {
"target": "server1.prod.example.net", "target": "agents.name='server1.prod.example.net'",
"policy": { "policy": {
"level": "medium", "level": "medium",
"name": "system", "name": "system",

Просмотреть файл

@ -158,6 +158,25 @@ The parameters are:
queries, like running an action against a specific operating system, or queries, like running an action against a specific operating system, or
against an endpoint that has a given public IP, etc... against an endpoint that has a given public IP, etc...
The most simple query that targets all agents is `name like '%'` (the `%`
character is a wildcard in SQL pattern matching). Targetting by OS family can
be done on the `os` parameters such as `os='linux'` or `os='darwin'`.
Combining conditions is also trivial: `version='201409171023+c4d6f50.prod'
and heartbeattime > NOW() - interval '1 minute'` will only target agents that
run a specific version and have sent a heartbeat during the last minute.
Complex queries are also possible.
For example: imagine an action with ID 1 launched against 10,000 endpoints,
which returned 300 endpoints with positive results. We want to launch action
2 on those 300 endpoints only. It can be accomplished with the following
`target` condition. (note: you can reuse this condition by simply changing
the value of `actionid`)
.. code:: sql
id IN (select agentid from commands, json_array_elements(commands.results) as r where actionid=1 and r#>>'{foundanything}' = 'true')
.. _`agents`: data.rst.html#entity-relationship-diagram .. _`agents`: data.rst.html#entity-relationship-diagram
* **description** and **threat**: additional fields to describe the action * **description** and **threat**: additional fields to describe the action