File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 9191//! }
9292//! ```
9393//!
94+ //! ## Rules & Alerts
95+ //!
96+ //! Retrieve recording/alerting rules and active alerts.
97+ //!
98+ //! ```rust
99+ //! use prometheus_http_query::{Client, Scheme, Error, RuleType};
100+ //!
101+ //! fn main() -> Result<(), Error> {
102+ //! let client = Client::new(Scheme::Http, "localhost", 9090);
103+ //!
104+ //! let response = tokio_test::block_on( async { client.rules(None).await });
105+ //!
106+ //! assert!(response.is_ok());
107+ //!
108+ //! // Only request alerting rules instead:
109+ //! let response = tokio_test::block_on( async { client.rules(Some(RuleType::Alert)).await });
110+ //!
111+ //! assert!(response.is_ok());
112+ //!
113+ //! // Request active alerts:
114+ //! let response = tokio_test::block_on( async { client.alerts().await });
115+ //!
116+ //! assert!(response.is_ok());
117+ //!
118+ //! Ok(())
119+ //! }
120+ //! ```
121+ //!
94122//! This is just one example. See [Client] for examples of other types of metadata queries.
95123//!
96124//! # Supported operations
118146//!
119147//! # Limitations
120148//!
121- //! * Some query types (rules/alerts ) are not supported (yet)
149+ //! * Some query types (e.g. Prometheus status, metric & target metadata ) are not supported (yet)
122150//! * reqwest client configuration cannot be customized (yet)
123151//! * Subqueries are not supported (only as custom query)
124152//! * PromQL functions that do not take a range / instant vector as an argument are not supported (only as custom query)
Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ pub struct RecordingRule {
276276 pub ( crate ) health : RuleHealth ,
277277 pub ( crate ) name : String ,
278278 pub ( crate ) query : String ,
279- pub ( crate ) labels : HashMap < String , String > ,
279+ pub ( crate ) labels : Option < HashMap < String , String > > ,
280280}
281281
282282impl RecordingRule {
@@ -296,7 +296,7 @@ impl RecordingRule {
296296 }
297297
298298 /// Get a set of labels defined for this rule.
299- pub fn labels ( & self ) -> & HashMap < String , String > {
299+ pub fn labels ( & self ) -> & Option < HashMap < String , String > > {
300300 & self . labels
301301 }
302302}
You can’t perform that action at this time.
0 commit comments