pub struct Selector<'a> { /* private fields */ }
Expand description
A time series selector that is gradually built from a metric name and/or a set of label matchers.
Implementations§
Source§impl<'a> Selector<'a>
impl<'a> Selector<'a>
Sourcepub fn metric(self, metric: &'a str) -> Selfwhere
Self: Sized,
pub fn metric(self, metric: &'a str) -> Selfwhere
Self: Sized,
Select a metric name for this Selector.
use prometheus_http_query::Selector;
let select = Selector::new().metric("http_requests_total");
// This is equal to:
let other_select = Selector::new().eq("__name__", "http_requests_total");
assert_eq!(select, other_select);
Sourcepub fn eq(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
pub fn eq(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
Append a label matcher to the set of matchers of Selector that
selects labels that match the provided string.
PromQL equivalent: http_requests_total{job="apiserver"}
use prometheus_http_query::Selector;
let select = Selector::new()
.metric("http_requests_total")
.eq("job", "apiserver")
.to_string();
let expected = r#"{__name__="http_requests_total",job="apiserver"}"#.to_string();
assert_eq!(select, expected);
Sourcepub fn ne(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
pub fn ne(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
Append a label matcher to the set of matchers of Selector that
selects labels that do not match the provided string.
PromQL equivalent: http_requests_total{job!="apiserver"}
use prometheus_http_query::Selector;
let select = Selector::new()
.metric("http_requests_total")
.ne("job", "apiserver")
.to_string();
let expected = r#"{__name__="http_requests_total",job!="apiserver"}"#.to_string();
assert_eq!(select, expected);
Sourcepub fn regex_eq(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
pub fn regex_eq(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
Append a label matcher to the set of matchers of Selector that
selects labels that regex-match the provided string.
PromQL equivalent: http_requests_total{job=~"apiserver"}
use prometheus_http_query::Selector;
let select = Selector::new()
.metric("http_requests_total")
.regex_eq("job", "apiserver")
.to_string();
let expected = r#"{__name__="http_requests_total",job=~"apiserver"}"#.to_string();
assert_eq!(select, expected);
Sourcepub fn regex_ne(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
pub fn regex_ne(self, label: &'a str, value: &'a str) -> Selfwhere
Self: Sized,
Append a label matcher to the set of matchers of Selector that
selects labels that do not regex-match the provided string.
PromQL equivalent: http_requests_total{job!~"apiserver"}
use prometheus_http_query::Selector;
let select = Selector::new()
.metric("http_requests_total")
.regex_ne("job", "apiserver")
.to_string();
let expected = r#"{__name__="http_requests_total",job!~"apiserver"}"#.to_string();
assert_eq!(select, expected);
Trait Implementations§
impl<'a> StructuralPartialEq for Selector<'a>
Auto Trait Implementations§
impl<'a> Freeze for Selector<'a>
impl<'a> RefUnwindSafe for Selector<'a>
impl<'a> Send for Selector<'a>
impl<'a> Sync for Selector<'a>
impl<'a> Unpin for Selector<'a>
impl<'a> UnwindSafe for Selector<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.