Skip to content

Commit

Permalink
agent: add hostname to event
Browse files Browse the repository at this point in the history
Adds the hostname of the machine the event was read from to the
"evebox" object of the event.
  • Loading branch information
jasonish committed Aug 7, 2023
1 parent 1721f1c commit c603d27
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## unreleased

- [agent] Add hostname of machine the alert was read from. This
includes the server when instructed to input events. The hostname of
the machine generating the alert is added to "evebox" field.

## 0.17.2 - 2023-05-27

- [elastic] Fixing negation queries using '-':
Expand Down
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ libc = { version = "0.2.140", default_features = false }

rcgen = { git = "https://github.com/jasonish/rcgen", branch = "0.11.0-disable-botan" }
directories = "5.0.1"
gethostname = "0.4.3"

[patch.crates-io]
# Patch Rusqlite for now. 0.28.0 uses SQLite 3.39, but 3.40 is much
Expand Down
5 changes: 5 additions & 0 deletions src/eve/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ impl EveBoxMetadataFilter {
}
}

// Add the hostname.
if let Ok(hostname) = gethostname::gethostname().into_string() {
event["evebox"]["hostname"] = hostname.into();
}

// Add a tags object.
if event.get("tags").is_none() {
event["tags"] = serde_json::Value::Array(vec![]);
Expand Down

0 comments on commit c603d27

Please sign in to comment.