|
2 | 2 | JSON Format |
3 | 3 | ########### |
4 | 4 |
|
5 | | -At this time we have one alert JSON formatted messages. |
| 5 | +OSSEC can write alerts in JSON format to ``/var/ossec/logs/alerts/alerts.json`` when |
| 6 | +``jsonout_output`` is enabled in ``<global>``. Each line is one JSON object. |
6 | 7 |
|
7 | | -Also see manual/output/json-alert-log-output. |
| 8 | +Enable JSON output |
| 9 | +------------------ |
| 10 | + |
| 11 | +.. code-block:: xml |
| 12 | +
|
| 13 | + <global> |
| 14 | + <jsonout_output>yes</jsonout_output> |
| 15 | + </global> |
| 16 | +
|
| 17 | +Example alert |
| 18 | +------------- |
8 | 19 |
|
9 | 20 | .. code-block:: json |
10 | 21 |
|
11 | | - { |
12 | | - "rule":1000, |
13 | | - "level":1, |
14 | | - "comment":"This is a comment", |
15 | | - "sidid":1111, |
16 | | - "cve":"cve-1001-1000", |
17 | | - "action":"drop", |
18 | | - "srcip":"10.1.1.1", |
19 | | - "srcport":"1000", |
20 | | - "srcuser":"root", |
21 | | - "dstip":"10.2.2.2", |
22 | | - "dstport":"2000", |
23 | | - "dstuser":"root", |
24 | | - "location":"/var/log/auth.log", |
25 | | - "full_log":"This is the full log message", |
26 | | - "file":{ |
27 | | - "path":"/etc/", |
28 | | - "md5_before":"XXXXXXXXXXXXXXXXXXXX", |
29 | | - "md5_after":"YYYYYYYYYYYYYYYYYYYY", |
30 | | - "sha1_before":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", |
31 | | - "sha1_after":"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY", |
32 | | - "owner_before":"root", |
33 | | - "owner_after":"nobody", |
34 | | - "gowner_before":"root", |
35 | | - "gowner_after":"nodody", |
36 | | - "perm_before":660, |
37 | | - "perm_after":777, |
38 | | - } |
39 | | - } |
| 22 | + { |
| 23 | + "timestamp": "2026-06-28T12:00:00.000+0000", |
| 24 | + "rule": { |
| 25 | + "level": 5, |
| 26 | + "description": "SSHD authentication success.", |
| 27 | + "id": "5715", |
| 28 | + "groups": ["syslog", "sshd", "authentication_success"] |
| 29 | + }, |
| 30 | + "agent": { |
| 31 | + "id": "001", |
| 32 | + "name": "agent01" |
| 33 | + }, |
| 34 | + "manager": { |
| 35 | + "name": "ossec-manager" |
| 36 | + }, |
| 37 | + "id": "1234567890.12345", |
| 38 | + "full_log": "Jun 28 12:00:00 agent01 sshd[1234]: Accepted publickey for user", |
| 39 | + "decoder": { |
| 40 | + "name": "sshd" |
| 41 | + }, |
| 42 | + "location": "/var/log/auth.log" |
| 43 | + } |
| 44 | +
|
| 45 | +Common fields |
| 46 | +------------- |
| 47 | + |
| 48 | ++------------------+----------------------------------------------------------+ |
| 49 | +| Field | Description | |
| 50 | ++==================+==========================================================+ |
| 51 | +| ``timestamp`` | When OSSEC processed the event | |
| 52 | +| ``rule.level`` | Alert severity (0–16) | |
| 53 | +| ``rule.id`` | Rule ID that matched | |
| 54 | +| ``rule.description`` | Rule text | |
| 55 | +| ``rule.groups`` | Rule groups (also exposed as ``rule.group`` in some builds) | |
| 56 | +| ``agent.id`` | Agent ID (manager/local if absent) | |
| 57 | +| ``agent.name`` | Agent hostname | |
| 58 | +| ``full_log`` | Original log line or message | |
| 59 | +| ``srcip`` | Source IP when extracted by decoder | |
| 60 | +| ``dstuser`` | Destination user when extracted | |
| 61 | +| ``location`` | Log source path or label | |
| 62 | +| ``syscheck`` | FIM details when present (hashes, paths, ownership) | |
| 63 | +| ``GeoLocation`` | Present when GeoIP is enabled and ``analysisd.geoip_jsonout=1`` | |
| 64 | ++------------------+----------------------------------------------------------+ |
| 65 | + |
| 66 | +File integrity (syscheck) alerts may include ``md5``, ``sha1``, and ``sha256`` before/after |
| 67 | +fields inside the ``syscheck`` object. |
40 | 68 |
|
| 69 | +Also see :ref:`manual-out-json` and :doc:`alerts </docs/formats/alerts>`. |
0 commit comments