|
@@ -103,9 +103,9 @@ func processSeries(
|
103
|
103
|
data script_data.Data,
|
104
|
104
|
) error {
|
105
|
105
|
series, err := client.ReadSeriesOfNumbers(script.Script)
|
106
|
|
-
|
107
|
106
|
for _, serie := range series {
|
108
|
|
- if !isRecentEnough(serie.Datapoints[0]) {
|
|
107
|
+ mostRecentDataPoint := serie.Datapoints[len(serie.Datapoints)-1]
|
|
108
|
+ if !isRecentEnough(mostRecentDataPoint) {
|
109
|
109
|
// If the serie hasn't been active in the last 10min, don't consider
|
110
|
110
|
// it
|
111
|
111
|
// TODO: If the serie was active at the previous run, send an alert
|
|
@@ -122,7 +122,7 @@ func processSeries(
|
122
|
122
|
// to find when the situation began so we can add info about time in the
|
123
|
123
|
// alert.
|
124
|
124
|
if err = processFloat(
|
125
|
|
- serie.Datapoints[0][1], script, alerter, serie.Labels, data,
|
|
125
|
+ mostRecentDataPoint[1], script, alerter, serie.Labels, data,
|
126
|
126
|
); err != nil {
|
127
|
127
|
return err
|
128
|
128
|
}
|
|
@@ -157,5 +157,4 @@ func isRecentEnough(datapoint []float64) bool {
|
157
|
157
|
now := time.Now().UnixNano() / 1000 // Current timestamp (seconds)
|
158
|
158
|
|
159
|
159
|
return now-int64(datapoint[0]) <= allowedOffset
|
160
|
|
- return false
|
161
|
160
|
}
|