MCPcopy Create free account
hub / github.com/assertible/lambda-cloudwatch-slack / handleElasticache

Function handleElasticache

index.js:196–228  ·  view source on GitHub ↗
(event, context)

Source from the content-addressed store, hash-verified

194};
195
196var handleElasticache = function(event, context) {
197 var subject = "AWS ElastiCache Notification"
198 var message = JSON.parse(event.Records[0].Sns.Message);
199 var timestamp = (new Date(event.Records[0].Sns.Timestamp)).getTime()/1000;
200 var region = event.Records[0].EventSubscriptionArn.split(":")[3];
201 var eventname, nodename;
202 var color = "good";
203
204 for(key in message){
205 eventname = key;
206 nodename = message[key];
207 break;
208 }
209 var slackMessage = {
210 text: "*" + subject + "*",
211 attachments: [
212 {
213 "color": color,
214 "fields": [
215 { "title": "Event", "value": eventname.split(":")[1], "short": true },
216 { "title": "Node", "value": nodename, "short": true },
217 {
218 "title": "Link to cache node",
219 "value": "https://console.aws.amazon.com/elasticache/home?region=" + region + "#cache-nodes:id=" + nodename + ";nodes",
220 "short": false
221 }
222 ],
223 "ts": timestamp
224 }
225 ]
226 };
227 return _.merge(slackMessage, baseSlackMessage);
228};
229
230var handleCloudWatch = function(event, context) {
231 var timestamp = (new Date(event.Records[0].Sns.Timestamp)).getTime()/1000;

Callers 1

processEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected