Skip to content

Conversation

@jrodewig
Copy link
Contributor

Adds documentation for the any keyword to the EQL syntax docs.

Includes:

  • Definition of an event type and its relationship to the event type
    field.
  • Example matching all event types using any keyword
  • Example matching event types beginning with a digit
  • Example using any with where true

Depends on #52526

Adds documentation for the `any` keyword to the EQL syntax docs.

Includes:

* Definition of an event type and its relationship to the event type
  field.
* Example matching all event types using `any` keyword
* Example matching event types beginning with a digit
* Example using `any` with `where true`
@jrodewig jrodewig added >docs General docs changes :Analytics/EQL EQL querying labels Feb 26, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/EQL)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs (>docs)

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Unrelated to the changes in this PR, is the in and not in lookup operator already supported?

[[eql-syntax-event-types-starting-with-digits]]
===== Event types starting with digits

EQL queries cannot start with a digit. To match event types starting with a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to drop this section, since we've never suggested anywhere else that this should be supported behavior.
There is an issue that was created for this (#51853), but I think that's more of a feature request than a bug.

My worry here is that the emphasis on digits could cause confusion. You also currently run into the same problem if there are hyphens or special characters in the event type.

One thing we could do, is reuse or merge this section with the previous mention that documents that don't have an "event type" and can't that be queried with the form <event type> where <condition>, can use any where. I think it's good that you show cases where any where ... is convenient, and also when it's necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @rw-access. With ea38a56, I added a sentence to the previous section stating that any where can be used for documents without an event type field. Feels much less corner-case-y.

@jrodewig
Copy link
Contributor Author

jrodewig commented Feb 27, 2020

@astefan It appears that in and not in are both already supported:

in

POST my_index/_doc
{
  "@timestamp": "2020-12-07T11:06:07.000Z",
  "event": {
    "category": "process"
  },
  "process": {
    "name": "cmd.exe"
  }
}
GET my_index/_eql/search
{
  "event_type_field": "event.category",
  "rule": "process where process.name in (\"cmd.exe\")"
}
{
  "took" : 5,
  "timed_out" : false,
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "events" : [
      {
        "_index" : "my_index",
        "_id" : "1BwChnABDtlfLF_OwhVR",
        "_score" : 0.5753642,
        "_source" : {
          "process" : {
            "name" : "cmd.exe"
          },
          "event" : {
            "category" : "process"
          }
        },
        "fields" : {
          "event.category.keyword" : [
            "process"
          ],
          "@timestamp" : [
            "1607339167000"
          ],
          "process.name.keyword" : [
            "cmd.exe"
          ]
        }
      }
    ]
  }
}

not in

POST my_index/_doc
{
  "@timestamp": "2020-12-07T11:06:07.000Z",
  "event": {
    "category": "process"
  },
  "process": {
    "name": "cmd.exe"
  }
}
GET my_index/_eql/search
{
  "event_type_field": "event.category",
  "rule": "process where process.name not in (\"foo.exe\")"
}
{
  "took" : 5,
  "timed_out" : false,
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "events" : [
      {
        "_index" : "my_index",
        "_id" : "1BwChnABDtlfLF_OwhVR",
        "_score" : 0.5753642,
        "_source" : {
          "process" : {
            "name" : "cmd.exe"
          },
          "event" : {
            "category" : "process"
          }
        },
        "fields" : {
          "event.category.keyword" : [
            "process"
          ],
          "@timestamp" : [
            "1607339167000"
          ],
          "process.name.keyword" : [
            "cmd.exe"
          ]
        }
      }
    ]
  }
}

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jrodewig jrodewig merged commit c6334ee into elastic:master Mar 5, 2020
@jrodewig jrodewig deleted the docs__eql-any-where branch March 5, 2020 09:44
jrodewig added a commit that referenced this pull request Mar 5, 2020
Adds documentation for the `any` keyword to the EQL syntax docs.

Includes:

* Definition of an event category and its relationship to the event
   category field.
* Example matching all event categories using `any` keyword
* Example using `any` with `where true`
@jrodewig
Copy link
Contributor Author

jrodewig commented Mar 5, 2020

Backport commits

master c6334ee
7.x e46bb54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/EQL EQL querying >docs General docs changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants