Struct splunk::hec::HecClient

source ·
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§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

source

pub fn new(token: impl ToString, hostname: impl ToString) -> Self

Create a new HEC client, specifying the token and hostname. Defaults to port 8088

source

pub fn with_serverconfig(serverconfig: ServerConfig) -> Self

Start the HEC Client with a given server config

source

pub fn useragent(&mut self, useragent: impl ToString)

Configure a custom user-agent string

source

pub async fn get_health(&self) -> Result<HecHealthResult, String>

Do a healthcheck and return the response

source

pub async fn get_health_ack(&self) -> Result<HecHealthResult, String>

The separate HEC health endpoint for ACK-related/enabled hosts

source

pub fn with_index(self, index: impl ToString) -> Self

Set the index on the events you’ll send

source

pub fn with_sourcetype(self, sourcetype: impl ToString) -> Self

Set the sourcetype on all events you send

source

pub fn with_source(self, source: impl ToString) -> Self

Set the source on all events you send

source

pub async fn send_event(&self, event: Value) -> Result<(), Error>

send a single event to the HEC endpoint

source

pub async fn send_events(&self, events: Vec<Value>) -> Result<(), Error>

send data to the HEC endpoint

source

pub async fn enqueue(&mut self, event: Value)

add a new queue item

source

pub async fn queue_size(&self) -> usize

get the current queue size

source

pub async fn flush(&mut self, batch_size: Option<u32>) -> Result<usize, Error>

Flush the queue out to HEC, defaults to batches of 1000

Trait Implementations§

source§

impl Debug for HecClient

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for HecClient

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more