Add IDs to metrics
This commit is contained in:
parent
8ae311190f
commit
67b6f30c62
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2474,7 +2474,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reminder-rs"
|
name = "reminder-rs"
|
||||||
version = "1.7.4"
|
version = "1.7.4-2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "reminder-rs"
|
name = "reminder-rs"
|
||||||
version = "1.7.4"
|
version = "1.7.4-2"
|
||||||
authors = ["Jude Southworth <judesouthworth@pm.me>"]
|
authors = ["Jude Southworth <judesouthworth@pm.me>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0 only"
|
license = "AGPL-3.0 only"
|
||||||
@ -59,8 +59,6 @@ assets = [
|
|||||||
["reminder-dashboard/dist/index.html", "lib/reminder-rs/static/index.html", "644"],
|
["reminder-dashboard/dist/index.html", "lib/reminder-rs/static/index.html", "644"],
|
||||||
["conf/default.env", "etc/reminder-rs/config.env", "600"],
|
["conf/default.env", "etc/reminder-rs/config.env", "600"],
|
||||||
["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"],
|
["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"],
|
||||||
["healthcheck", "lib/reminder-rs/healthcheck", "755"],
|
|
||||||
["cron.d/reminder_health", "etc/cron.d/reminder_health", "644"],
|
|
||||||
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
|
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
|
||||||
]
|
]
|
||||||
conf-files = [
|
conf-files = [
|
||||||
|
13
healthcheck
13
healthcheck
@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
export $(grep -v '^#' /etc/reminder-rs/config.env | xargs -d '\n')
|
|
||||||
|
|
||||||
REGEX='mysql://([A-Za-z]+)@(.+)/(.+)'
|
|
||||||
[[ $DATABASE_URL =~ $REGEX ]]
|
|
||||||
|
|
||||||
VAR=$(mysql -u "${BASH_REMATCH[1]}" -h "${BASH_REMATCH[2]}" -N -D "${BASH_REMATCH[3]}" -e "SELECT COUNT(1) FROM reminders WHERE utc_time < NOW() - INTERVAL 10 MINUTE AND enabled = 1 AND status = 'pending'")
|
|
||||||
|
|
||||||
if [ "$VAR" -gt 0 ]
|
|
||||||
then
|
|
||||||
echo "This is to inform that there is a reminder backlog which must be resolved." | mail -s "Backlog: $VAR" "$REPORT_EMAIL"
|
|
||||||
fi
|
|
@ -9,10 +9,11 @@ lazy_static! {
|
|||||||
IntCounterVec::new(Opts::new("requests", "Web requests"), &["method", "status", "route"])
|
IntCounterVec::new(Opts::new("requests", "Web requests"), &["method", "status", "route"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
pub static ref REMINDER_COUNTER: IntCounterVec =
|
pub static ref REMINDER_COUNTER: IntCounterVec =
|
||||||
IntCounterVec::new(Opts::new("reminders_sent", "Reminders sent"), &["channel"]).unwrap();
|
IntCounterVec::new(Opts::new("reminders_sent", "Reminders sent"), &["id", "channel"])
|
||||||
|
.unwrap();
|
||||||
pub static ref REMINDER_FAIL_COUNTER: IntCounterVec = IntCounterVec::new(
|
pub static ref REMINDER_FAIL_COUNTER: IntCounterVec = IntCounterVec::new(
|
||||||
Opts::new("reminders_failed", "Reminders failed"),
|
Opts::new("reminders_failed", "Reminders failed"),
|
||||||
&["channel", "error"]
|
&["id", "channel", "error"]
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
pub static ref COMMAND_COUNTER: IntCounterVec =
|
pub static ref COMMAND_COUNTER: IntCounterVec =
|
||||||
|
@ -446,13 +446,22 @@ impl Reminder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
REMINDER_FAIL_COUNTER
|
REMINDER_FAIL_COUNTER
|
||||||
.with_label_values(&[self.channel_id.to_string().as_str(), &message])
|
.get_metric_with_label_values(&[
|
||||||
.inc();
|
self.id.to_string().as_str(),
|
||||||
|
self.channel_id.to_string().as_str(),
|
||||||
|
&message,
|
||||||
|
])
|
||||||
|
.map_or_else(|e| warn!("Couldn't count failed reminder: {:?}", e), |c| c.inc());
|
||||||
error!("[Reminder {}] {}", self.id, message);
|
error!("[Reminder {}] {}", self.id, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn log_success(&self) {
|
async fn log_success(&self) {
|
||||||
REMINDER_COUNTER.with_label_values(&[self.channel_id.to_string().as_str()]).inc()
|
REMINDER_COUNTER
|
||||||
|
.get_metric_with_label_values(&[
|
||||||
|
self.id.to_string().as_str(),
|
||||||
|
self.channel_id.to_string().as_str(),
|
||||||
|
])
|
||||||
|
.map_or_else(|e| warn!("Couldn't count sent reminder: {:?}", e), |c| c.inc());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
||||||
|
Loading…
Reference in New Issue
Block a user