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§
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);