Struct prometheus_http_query::Selector
source · [−]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
sourceimpl<'a> Selector<'a>
impl<'a> Selector<'a>
sourcepub fn metric(self, metric: &'a str) -> Self where
Self: Sized,
pub fn metric(self, metric: &'a str) -> Self where
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) -> Self where
Self: Sized,
pub fn eq(self, label: &'a str, value: &'a str) -> Self where
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) -> Self where
Self: Sized,
pub fn ne(self, label: &'a str, value: &'a str) -> Self where
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) -> Self where
Self: Sized,
pub fn regex_eq(self, label: &'a str, value: &'a str) -> Self where
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) -> Self where
Self: Sized,
pub fn regex_ne(self, label: &'a str, value: &'a str) -> Self where
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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more