pub struct QueryRule { /* private fields */ }Expand description
A KQL or Lucene query rule. Rules start disabled unless explicitly enabled.
Other rule types can be created by passing their JSON definition to
Security::create_rule.
Implementations§
Source§impl QueryRule
impl QueryRule
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
query: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, query: impl Into<String>, ) -> Self
A disabled KQL rule over logs-* with medium severity, on the default
RuleSchedule: every 5 minutes, searching the last 6.
use security_client_rs::security::{QueryRule, RuleSchedule};
use serde_json::to_value;
use std::time::Duration;
let rule = QueryRule::new("Failed logins", "Repeated failures", "event.outcome: failure")
.schedule(RuleSchedule::every(Duration::from_secs(600))?);
let body = to_value(rule)?;
assert_eq!(body["enabled"], false);
assert_eq!(body["interval"], "10m");
assert_eq!(body["from"], "now-11m");pub fn language(self, language: QueryLanguage) -> Self
pub fn index<I: IntoIterator<Item = S>, S: Into<String>>( self, patterns: I, ) -> Self
pub fn severity(self, severity: Severity) -> Self
pub fn risk_score(self, score: RiskScore) -> Self
pub fn enabled(self, enabled: bool) -> Self
Sourcepub fn schedule(self, schedule: RuleSchedule) -> Self
pub fn schedule(self, schedule: RuleSchedule) -> Self
Sets how often the rule runs and how far back each run searches.
Sourcepub fn custom_schedule(
self,
interval: impl Into<String>,
from: impl Into<String>,
) -> Self
pub fn custom_schedule( self, interval: impl Into<String>, from: impl Into<String>, ) -> Self
Sets Kibana’s interval, such as 15m, and from, such as now-20m
or other date math, directly. Keep from at least one interval back,
or runs leave gaps; prefer schedule.
Sourcepub fn rule_id(self, rule_id: impl Into<String>) -> Self
pub fn rule_id(self, rule_id: impl Into<String>) -> Self
A stable identifier, generated by Kibana when omitted.
pub fn exceptions_list(self, lists: Vec<ListReference>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryRule
impl RefUnwindSafe for QueryRule
impl Send for QueryRule
impl Sync for QueryRule
impl Unpin for QueryRule
impl UnsafeUnpin for QueryRule
impl UnwindSafe for QueryRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more