Not getting alerts but acknowledgement of the alerts on dashboard work - bosun

I have been trying to get Bosun to work with little success. Here are my problems:
1) I am able to see alerts appearing in my dashboard, but the alerts never come thru to the notification mode of my choice, be it e-mail, slack or json.
2) When I acknowledge the alerts on the dashboard, only one notification from the notification chain (first one) will be received. I.e. If I set up {email -> slack -> json}, only e-mail notification will be received, no slack and json.
Any help will be appreciated. Below is my dev.config
-------------- dev.conf ---------------
tsdbHost = qa1-sjc005-031:4242
emailFrom = bosun-alert#noreply.com
smtpHost = stmp.somedomain.com:25
checkFrequency = 1m
httpListen = :8070
# Post to an endpoint
notification json {
post = http://somedomain.com/HealthCheck/bosunAlert
body = {"text": {{.|json}}}
contentType = application/json
print = true
next = json
timeout = 5m
}
# Post to a Slack channel via Incoming Webhooks integration
notification slack {
post = https://hooks.slack.com/services/T03DNM0UU/B04QH37J6/ypn0
Uy2JwLa676soomXwItjq
body = payload={"channel": "#testing", "username": "webhookbot"
, "text" : "This is a test!"}
print = true
next = json
timeout = 5m
}
# Send out e-mail notification
notification email {
email = username#somedomain.com
print = true
next = slack
timeout = 5m
}
template test {
subject = {{.Last.Status}}: {{.Alert.Name}} on {{.Group.measurem
ent}} for {{.Group.pod}}
body = `<p>Name: {{.Alert.Name}}
<p>Tags:
<table>
{{range $k, $v := .Group}}
<tr><td>{{$k}}</td><td>{{$v}}</td></tr>
{{end}}
</table>`
}
alert test {
template = test
crit = avg(q("avg:mq1{measurement=*,pod=pod3}", "1h", ""))
warn = avg(q("avg:mq1{measurement=*,pod=pod3}", "30m", ""))
critNotification = email
warnNotification = email
}

Acknowledgements stop notification chains. So the purpose of them is really for the escalation of incidents; escalation stops when an incident has been acknowledged. As per the documentation on notifications:
notification
A notification is a chained action to perform. The chaining continues until the chain ends or the alert is acknowledged.
It seems like you might want to send to multiple notifications at the same time. To do this list them out in warnNotification and/or critNotification as appropriate:
critNotification: comma-separated list of notifications to trigger on critical.
Both the quotes are from the configuration documentation (documentation isn't that well organized currently, so I don't blame you for missing either of these)

Related

Sending FCM Batch request for legacy HTTP API

Using the legacy FCM HTTPS API is it possible to send messages to a device or a device group as stated in the documentation here, but their is not information regarding sending a bath of messages via an HTTP post request, we are aware that is it possible to send batch messages using the Admin SDK
as shown here in
FCM Admin SDK
// Create a list containing up to 500 messages.
var messages = new List<Message>()
{
new Message()
{
Notification = new Notification()
{
Title = "Price drop",
Body = "5% off all electronics",
},
Token = registrationToken,
},
new Message()
{
Notification = new Notification()
{
Title = "Price drop",
Body = "2% off all books",
},
Topic = "readers-club",
},
};
var response = await FirebaseMessaging.DefaultInstance.SendAllAsync(messages);
We are unable to confirm if it its possible to send batch messages via the HTTPS post request.
The Admin SDK wraps the FCM REST API that is documented here. From there:
HTTP request
POST https://fcm.googleapis.com/v1/{parent=projects/*}/messages:send
The URL uses gRPC Transcoding syntax.
So it looks like the REST API expects a post request.

Why can't I collapse my push notifications when I use Firebase FCM?

const options = {
priority: 'high',
collapseKey: user_id
};
const deviceTokensPromise = db.ref('/users-fcm-tokens/' + user_id).once('value');
deviceTokensPromise.then(tokensSnapshot => {
if (!tokensSnapshot.hasChildren()) {
return console.log('There are no device tokens to send to.');
}
const tokens = Object.keys(tokensSnapshot.val());
console.log(tokens);
console.log(payload);
return admin.messaging().sendToDevice(tokens, payload, options).then(response => {
console.log(response);
return removeInvalidFCMTokens(tokensSnapshot, response);
});
});
I have a collapse-Key field in my options.
When this code is ran, the iPhone receives multiple notifications, all on top of each other. I'd like to have most recent notification replace the previous ones.
#Timex you can pass same notification id for all notifications with the same collapse_id. For this you need to implement your own SendNotification method.
Check out the "Delivery Options" section in Firebase's FCM Messages documentation.
"collapsible" message behavior is supported on Android via FCM's collapse_key, on iOS via apns-collapse-id, and on JavaScript/Web via Topic.
Intuitively you might expect that the apns-collapse-id setting might go into the options parameter passed into the sendToMessage method you are using. However, this is not the case. Instead try patching it into the payload object, like this:
const patchedPayload = Object.assign({}, payload, {
apns: {
headers: {
'apns-collapse-id': user_id
}
}
});
This follows the payload format presented in the documentation linked above.
Once you've constructed this patched payload don't forget to update sendToDevice(tokens, payload, options) to sendToDevice(tokens, patchedPayload, options).
Hope this works out for you!
For iOS:
Use apns-collapse-id see the docs.
if you use collapsible messages, remember that FCM only allows a maximum of four different collapse keys to be used by the FCM connection server per registration token at any given time. You must not exceed this number, or it could cause unpredictable consequences.
Collapsible:
Use scenario
When there is a newer message that renders an older, related message irrelevant to the client app, FCM replaces the older message. For example: messages used to initiate a data sync from the server, or outdated notification messages.
How to send
Set the appropriate parameter in your message request:
collapseKey on Android
apns-collapse-id on iOS
Topic on Web
collapse_key in legacy protocols (all platforms)
See the implementation of apns-collapse-id in the article:
# Script to send push notifications for each song in a Phish Setlist via an updateable Push Notification.
# Place a config.yml in the same directory as the script and your push notification PEM file.
#
# Config Format:
# push_token: XXXXXXXXXXXXXX
# phish_api_key: XXXXXXXXXXXXXX
# push_mode: XXXXXXXXXXXXXX # development or production
require 'apnotic'
require 'phish_dot_net_client'
require 'awesome_print'
require 'yaml'
show_date = ARGV[0]
if show_date
script_config = YAML.load(File.read(File.expand_path('../config.yml', __FILE__)))
PhishDotNetClient.apikey = script_config["phish_api_key"]
the_show = PhishDotNetClient.shows_setlists_get :showdate => show_date
push_body = ""
if script_config["push_mode"] == "development"
connection = Apnotic::Connection.new(cert_path: "pushcert.pem", url: "https://api.development.push.apple.com:443")
else
connection = Apnotic::Connection.new(cert_path: "pushcert.pem")
end
token = script_config["push_token"]
notification = Apnotic::Notification.new(token)
notification.apns_id = SecureRandom.uuid
notification.apns_collapse_id = "Phish " + the_show[0]["showdate"] + ": "
notification.mutable_content = true
the_show[0]["setlistdata"].sets.each do |set_data|
set_name = set_data.name + ": "
set_data.songs.each do |song|
song_str = set_name + song.title
push_body = push_body + set_name + song.title + "\n"
set_name = ""
push_content = {'title' => song_str, 'body' => push_body}
puts push_content
notification.alert = push_content
response = connection.push(notification)
# read the response
puts ""
puts response.ok? # => true
puts response.status # => '200'
puts response.headers # => {":status"=>"200", "apns-id"=>"XXXX"}
puts response.body # => ""
puts ""
sleep(5)
end
end
connection.close
else
puts "Usage ruby send_push.rb SHOWDATE(Format:YYYY-MM-DD)"
end
For Android:
Use a tag variable in your notification payload.
"notification":{
"title":"Huawei",
"body":"21 Notification received",
"sound":"default",
"badge":4,
"tag":"1",
"click_action":"Your_Activity"
"icon":"Push_Icon"
}
I recommend using the latest send function from the firebase-admin, usage described here.

How to get push notification payload inside local notification

I am developing a webRTC (video calling) application in ios. I am receiving a APNS push notification from server,whenever user receive a incoming video call on the device.
{
"aps" : {
"alert" : "Incoming video call from - Bob",
"badge" : 1,
"sound" : "bingbong.mp3",
"userdata" : {JSON}
}
}
How can I store it inside Local Notification?
If you want to store data in local push notification then you can add the data like this,
let interval = TimeInterval(1)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: false)
let content = UNMutableNotificationContent()
content.title = "Incoming video call from - Bob"
content.body = "Your body"
content.sound = UNNotificationSound.init(named: "CustomSound.mp3")
content.badge = "Your badge number"
content.userInfo = ["userData": YOUR_USER_DATA from remote]
let req = UNNotificationRequest(identifier: "localPushNotification", content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.add(req, withCompletionHandler: nil)

Timeout error for AWS SNSClient Publish request

Here is the piece of code :
//Publishing the topic
snsClient.Publish(new PublishRequest
{
Subject = Constants.SNSTopicMessage,
Message = snsMessageObj.ToString(),
TopicArn = Settings.TopicArn
});
I am getting the below error :
The underlying connection was closed: A connection that was expected
to be kept alive was closed by the server.
And here is the screenshot of detailed error:
But not able to get an idea how to solve this. Any hint or link will helpful.
We had the exact same issue happen to us. We got this error about 40 times a day, which was less than 0.1% of the successful push notifications we sent out.
Our solution? Update the AWSSDK NuGet package from 1.5.30.1 to 2.3.52.0 (the latest v2 release for ease-of-upgrade). As soon as we updated, the errors stopped happening. I looked through lots of release notes and couldn't find anything specifically mentioning this issue. We have no idea why the update worked, but it did.
I hope this helps you and anyone else fix this issue.
This problem may occur when one or more of the following conditions are true:
• A network outage occurs.
• A proxy server blocks the HTTP request.
• A Domain Name System (DNS) problem occurs.
• A network authentication problem occurs.
[https://nilangshah.wordpress.com/2007/03/01/the-underlying-connection-was-closed-unable-to-connect-to-the-remote-server/]1
make sure your payloads size should not exceed more than 256 kb
make sure you had configured timeout property of the PutObjectRequest
Take a look sample aws sns request code (from https://stackoverflow.com/a/13016803/2318852)
// Create topic
string topicArn = client.CreateTopic(new CreateTopicRequest
{
Name = topicName
}).CreateTopicResult.TopicArn;
// Set display name to a friendly value
client.SetTopicAttributes(new SetTopicAttributesRequest
{
TopicArn = topicArn,
AttributeName = "DisplayName",
AttributeValue = "StackOverflow Sample Notifications"
});
// Subscribe an endpoint - in this case, an email address
client.Subscribe(new SubscribeRequest
{
TopicArn = topicArn,
Protocol = "email",
Endpoint = "sample#example.com"
});
// When using email, recipient must confirm subscription
Console.WriteLine("Please check your email and press enter when you are subscribed...");
Console.ReadLine();
// Publish message
client.Publish(new PublishRequest
{
Subject = "Test",
Message = "Testing testing 1 2 3",
TopicArn = topicArn
});
// Verify email receieved
Console.WriteLine("Please check your email and press enter when you receive the message...");
Console.ReadLine();
// Delete topic
client.DeleteTopic(new DeleteTopicRequest
{
TopicArn = topicArn
});

Repeating email notifications in Bosun

in notification of Bosun configuration, I set the timeout as 5m i.e. 5 minutes.
I am receiving emails for the interval of either 5 minutes or 10 minutes.
I am not able to debug as why is this happening.
Please help.
notification default {
email =jon#rohit.com
print = true
next = default
timeout = 5m
}
template tags {
subject =`Testing Emails Sample`
body = `<p><strong>Tags</strong>
<table>
{{range $k, $v := .Group}}
{{if eq $k "api"}}
<tr><td>{{$k}} : {{$v}}</td></tr>
{{end}}
{{end}}
</table>`
}
alert testSampleAlert5 {
template = tags
$notes = This alert monitors the percentage of 5XX on arm APIs
crit = 1
warn = 0
warnNotification = default
critNotification = default
}
alert testSampleAlert4 {
template = tags
$notes = This alert monitors the percentage of 5XX on arm APIs
crit = 0
warn = 1
warnNotification = default
critNotification = default
}
What you are encountering is bosun's feature of "chained notifications". The next and timeout parameters specify that the default notification will be triggered again after 5 minutes as you have configured it. Since it references itself, it will trigger every 5 minutes until the alert is acknowledged or closed.
You have a few options if this is not what you want.
Acknowledge the alert on the dashboard. This will stop all notification chains from repeating.
Remove the next parameter if you do not want to be re-notified every 5 minutes, or increase the timeout, or something like that.
What is your desired behaviour?

Resources