pub struct HecClient {
pub serverconfig: ServerConfig,
pub index: Option<String>,
pub sourcetype: Option<String>,
pub source: Option<String>,
pub timeout: u64,
/* private fields */
}
Expand description
HEC Client
Fields§
§serverconfig: ServerConfig
See ServerConfig
index: Option<String>
The target index - if this is None then it’ll just let the server decide
sourcetype: Option<String>
The target sourcetype - if this is None then it’ll just let the server decide
source: Option<String>
The target source - if this is None then it’ll just let the server decide
timeout: u64
Connection timeout, defaults to 60 seconds
Implementations§
source§impl HecClient
impl HecClient
sourcepub fn new(token: impl ToString, hostname: impl ToString) -> Self
pub fn new(token: impl ToString, hostname: impl ToString) -> Self
Create a new HEC client, specifying the token and hostname. Defaults to port 8088
sourcepub fn with_serverconfig(serverconfig: ServerConfig) -> Self
pub fn with_serverconfig(serverconfig: ServerConfig) -> Self
Start the HEC Client with a given server config
sourcepub async fn get_health(&self) -> Result<HecHealthResult, String>
pub async fn get_health(&self) -> Result<HecHealthResult, String>
Do a healthcheck and return the response
sourcepub async fn get_health_ack(&self) -> Result<HecHealthResult, String>
pub async fn get_health_ack(&self) -> Result<HecHealthResult, String>
The separate HEC health endpoint for ACK-related/enabled hosts
sourcepub fn with_index(self, index: impl ToString) -> Self
pub fn with_index(self, index: impl ToString) -> Self
Set the index on the events you’ll send
sourcepub fn with_sourcetype(self, sourcetype: impl ToString) -> Self
pub fn with_sourcetype(self, sourcetype: impl ToString) -> Self
Set the sourcetype on all events you send
sourcepub fn with_source(self, source: impl ToString) -> Self
pub fn with_source(self, source: impl ToString) -> Self
Set the source on all events you send
sourcepub async fn send_event(&self, event: Value) -> Result<(), Error>
pub async fn send_event(&self, event: Value) -> Result<(), Error>
send a single event to the HEC endpoint
sourcepub async fn send_events(&self, events: Vec<Value>) -> Result<(), Error>
pub async fn send_events(&self, events: Vec<Value>) -> Result<(), Error>
send data to the HEC endpoint
sourcepub async fn queue_size(&self) -> usize
pub async fn queue_size(&self) -> usize
get the current queue size