fixups after deployment
This commit is contained in:
@@ -15,10 +15,10 @@ use std::time::Duration;
|
||||
#[conf(serde)]
|
||||
pub struct AdminHttpConfig {
|
||||
/// URL to POST admin commands to
|
||||
#[conf(long, env)]
|
||||
#[conf(long, env = "ADMIN_HTTP_URL")]
|
||||
pub url: String,
|
||||
/// Timeout for the HTTP request
|
||||
#[conf(long, env, default_value = "5s", value_parser = conf_extra::parse_duration)]
|
||||
#[conf(long, env = "ADMIN_HTTP_TIMEOUT", default_value = "5s", value_parser = conf_extra::parse_duration)]
|
||||
pub timeout: Duration,
|
||||
}
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ impl Gateway {
|
||||
if let Some(prometheus) = self.prometheus.as_ref() {
|
||||
prometheus.purge_old_plots();
|
||||
for alert in alert_msg.alerts.iter() {
|
||||
match prometheus.create_alert_plot(alert).await {
|
||||
match prometheus.create_alert_plot(alert, false).await {
|
||||
Ok(path) => {
|
||||
attachment_paths.push(path);
|
||||
}
|
||||
|
||||
@@ -108,8 +108,15 @@ impl Prometheus {
|
||||
self.config.plot.purge_old_plots();
|
||||
}
|
||||
|
||||
/// Create a new plot corresponding to a given alert. Returns a pathbuf if it is present
|
||||
pub async fn create_alert_plot(&self, alert: &Alert) -> Result<PathBuf, BoxError> {
|
||||
/// Create a new plot corresponding to a given alert. Returns a pathbuf if it is present.
|
||||
///
|
||||
/// If `add_label_selector` is true, appends alert labels as a label selector to the query.
|
||||
/// This only works for simple metric queries, not for function calls like `rate(...)`.
|
||||
pub async fn create_alert_plot(
|
||||
&self,
|
||||
alert: &Alert,
|
||||
add_label_selector: bool,
|
||||
) -> Result<PathBuf, BoxError> {
|
||||
use chrono::{TimeDelta, Utc};
|
||||
|
||||
let expr = alert.parse_expr_from_generator_url()?;
|
||||
@@ -118,12 +125,16 @@ impl Prometheus {
|
||||
// We look for comparison operators and extract the threshold
|
||||
let (base_query, threshold) = parse_alert_expr(&expr)?;
|
||||
|
||||
// Build label selector from alert labels (excluding job/instance)
|
||||
let label_selector = build_label_selector(&alert.labels, &[]);
|
||||
let query = if label_selector.is_empty() {
|
||||
base_query.to_owned()
|
||||
// Optionally add label selector from alert labels
|
||||
let query = if add_label_selector {
|
||||
let label_selector = build_label_selector(&alert.labels, &[]);
|
||||
if label_selector.is_empty() {
|
||||
base_query
|
||||
} else {
|
||||
format!("{base_query}{{{label_selector}}}")
|
||||
}
|
||||
} else {
|
||||
format!("{base_query}{{{label_selector}}}")
|
||||
base_query
|
||||
};
|
||||
|
||||
let now = Utc::now();
|
||||
|
||||
Reference in New Issue
Block a user