mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
fix: send notification error (#351)
* fix: send notication error * fix: change log level
This commit is contained in:
@@ -53,6 +53,13 @@ pub async fn send_notification(
|
||||
}
|
||||
|
||||
let msg: Value = serde_json::from_str(&resp).unwrap();
|
||||
let msg: Value = match &msg {
|
||||
Value::String(obj) => match serde_json::from_str(obj) {
|
||||
Ok(obj) => obj,
|
||||
Err(_) => msg,
|
||||
},
|
||||
_ => msg,
|
||||
};
|
||||
let url = url::Url::parse(&local_dest.url);
|
||||
let mut req = match local_dest.method {
|
||||
alert::AlertHTTPType::POST => client.post(url.unwrap()),
|
||||
@@ -64,20 +71,26 @@ pub async fn send_notification(
|
||||
// Add additional headers if any from destination description
|
||||
if local_dest.headers.is_some() {
|
||||
for (key, value) in local_dest.headers.unwrap() {
|
||||
req = req.header(key, value);
|
||||
if !key.is_empty() && !value.is_empty() {
|
||||
req = req.header(key, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let resp = req.json(&msg).send().await;
|
||||
match resp {
|
||||
Ok(_) => log::info!("Notification Sent"),
|
||||
Err(err) => log::info!("Error sending notification {:?}", err),
|
||||
Ok(resp) => {
|
||||
if !resp.status().is_success() {
|
||||
log::error!("Notification sent error: {:?}", resp.bytes().await);
|
||||
}
|
||||
}
|
||||
Err(err) => log::error!("Notification sending error {:?}", err),
|
||||
}
|
||||
}
|
||||
|
||||
None => log::info!("Destination Not found"),
|
||||
None => log::error!("Destination Not found"),
|
||||
},
|
||||
Err(err) => log::info!("Error sending notification {:?}", err),
|
||||
Err(err) => log::error!("Error sending notification {:?}", err),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user