output-logfile.asciidoc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. [role="xpack"]
  2. [[audit-log-output]]
  3. === Logfile audit output
  4. The `logfile` audit output is the only output for auditing. It writes data to
  5. the `<clustername>_audit.json` file in the logs directory.
  6. NOTE: If you overwrite the `log4j2.properties` and do not specify appenders for
  7. any of the audit trails, audit events are forwarded to the root appender, which
  8. by default points to the `elasticsearch.log` file.
  9. [discrete]
  10. [[audit-log-entry-format]]
  11. === Log entry format
  12. The audit events are formatted as JSON documents, and each event is printed on a separate
  13. line in the `<clustername>_audit.json` file. The entries themselves do not contain the
  14. end-of-line delimiter.
  15. The audit event JSON format is somewhat particular, as *most* fields follow a dotted
  16. name syntax, are ordered, and contain non-null string values. This format creates a
  17. structured columnar aspect, similar to a CSV, that can be more easily inspected visually
  18. (compared to an equivalent nested JSON document).
  19. There are however a few attributes that are exceptions to the above format. The `put`,
  20. `delete`, `change`, `create` and `invalidate` attributes, which are only present for
  21. events with the `event.type: "security_config_change"` attribute, contain the *nested JSON*
  22. representation of the security change taking effect. The contents of the security config change
  23. are hence not displayed as top-level dot-named fields in the audit event document. That's because
  24. the fields are specific to the particular kind of security change and do not show up in
  25. any other audit events. The benefits of a columnar format are therefore much more limited; the
  26. space-saving benefits of the nested structure is the favoured trade-off in this case.
  27. When the `request.body` attribute is present (see <<auditing-search-queries>>), it contains a
  28. string value containing the full HTTP request body, escaped as per the JSON RFC 4677.
  29. There is a list of <<audit-event-types, audit event types>> specifying the
  30. set of fields, as well as examples, for each entry type.
  31. [discrete]
  32. [[audit-log-settings]]
  33. === Logfile output settings
  34. The events and some other information about what gets logged can be
  35. controlled using settings in the `elasticsearch.yml` file. See
  36. <<event-audit-settings>> and
  37. <<node-audit-settings>>.
  38. IMPORTANT: Be advised that *sensitive data may be audited in plain text* when including
  39. the request body in audit events, even though all the security APIs, such as those that
  40. change the user’s password, have the credentials filtered out when audited.
  41. You can also configure how the logfile is written in the `log4j2.properties`
  42. file located in `ES_PATH_CONF` (or check out the relevant portion of
  43. the https://github.com/elastic/elasticsearch/blob/{branch}/x-pack/plugin/core/src/main/config/log4j2.properties[log4j2.properties in the sources]).
  44. By default, audit information is appended to the
  45. `<clustername>_audit.json` file located in the standard Elasticsearch `logs` directory
  46. (typically located at `$ES_HOME/logs`).
  47. The file is also rotated and archived daily or upon reaching the 1GB file size limit.