System Functions
The following system functions are provided.
transform
- transform(stream, lambda)
- create a new stream. The data series of the new stream is the result of the lambda function.
- lambda function interface: (ts, key, value) ⇒ { }
let duration = AWS_GetMetric("Duration", options, filters)
let invocation = AWS_GetMetric("Invocations", options, filters)
let durationCost = transform(duration, (ts, key, value) => (value/1000) * assetTable[key].lambdaMemoryRate)
let invocationCost = transform(invocation, (ts, key, value) => value * assetTable[key].lambdaRequestRate)
anomaly
- anomaly(stream, {seasonal:"auto", minDiff: 3.0, minDiffPercent: 10.0})
- anomaly detection on one stream
- seasonal: auto | weekday-end-hourly | hourly | weekday-hourly | ""
- minDiff: absolute difference over mean: abs(value - mean)
- minDiffPercent: relative percent over mean: (value - mean)/mean
- return FplAlert object
alert
- alert(
<stream>
, window(condition,n,m))- sliding window detection
function queueAlerts(queues) {
let options = {from: "-1h@h", to: "@h", dimensions: ["QueueName"], namespace: "AWS/SQS", period: "5m", stat: "Maximum", unit:"Second"}
let filters = {QueueName: queues}
let ages = AWS_GetMetric("ApproximateAgeOfOldestMessage", options, filters)
let ageAlerts = alert(ages, window(ages > 3600, 2, 2))
options.stat = "Sum"
let received = AWS_GetMetric("NumberOfMessagesReceived", options, filters)
options.stat = "Average"
let queueLength = AWS_GetMetric("ApproximateNumberOfMessagesVisible", options, filters)
let consumerStopAlerts = alert(queueLength, window(received == 0 && queueLength > 1, 2, 2))
return {ageAlerts, consumerStopAlerts}
}