Skip to content

Commit 5a50f56

Browse files
committed
🐛 addresses bug with the window function not behaving correctly
1 parent 78d383e commit 5a50f56

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "barky",
3-
"version": "1.7.6",
3+
"version": "1.7.7",
44
"description": "A simple cloud services watchdog with digest notification support & no external dependencies",
55
"homepage": "https://github.com/Rohland/barky#readme",
66
"main": "dist/cli.js",

src/digest/digest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function evaluateNewFailureResult(
277277
context.addSnapshotForResult(result);
278278
break;
279279
default:
280-
throw new Error(`Unhandled rule type: ${ rule.type }`);
280+
throw new Error(`Unhandled rule type: ${rule.type}`);
281281
}
282282
}
283283

@@ -304,7 +304,7 @@ function evaluateNewSuccessResult(
304304
context.deleteLogs(previousLogs);
305305
break;
306306
default:
307-
throw new Error(`Unhandled rule type: ${ rule.type }`);
307+
throw new Error(`Unhandled rule type: ${rule.type}`);
308308
}
309309
}
310310

src/evaluators/base.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,15 @@ export abstract class BaseEvaluator {
226226
if (object) {
227227
if (isArray) {
228228
value = identifier
229-
.map(x => object[x])
229+
// try grab the identifier from the object using both the case provided, and lowercase, as some
230+
// providers (like sumo), seem to randomly lowercase the field name
231+
.map(x => object[x] ?? object[x?.toLowerCase()])
230232
.filter(x => x)
231233
.join(separator);
232234
} else {
233-
value = object[identifier];
235+
// try grab the identifier from the object using both the case provided, and lowercase, as some
236+
// providers (like sumo), seem to randomly lowercase the field name
237+
value = object[identifier] ?? object[identifier?.toLowerCase()];
234238
}
235239
if (typeof value === "string" && value.trim() === "") {
236240
value = null;

src/evaluators/sumo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class SumoEvaluator extends BaseEvaluator {
254254
return app._job;
255255
}
256256
try {
257-
const result = await executeSumoRequest(app.token, () => axios.get(`${SumoLogsUrl}/${app._job}/records?offset=0&limit=100`, getRequestConfig(app.token)));
257+
const result = await executeSumoRequest(app.token, () => axios.get(`${SumoLogsUrl}/${app._job}/records?offset=0&limit=1000`, getRequestConfig(app.token)));
258258
log(`successfully completed sumo job search for '${app.name}', result:`, result.data);
259259
return result.data;
260260
} catch (err) {

src/models/alert_configuration.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ describe("AlertRule", () => {
2121
it("should set values and return correct type", () => {
2222
// arrange
2323
const config = {
24-
any: 1
24+
any: 1,
25+
window: "-100m"
2526
} as IAlertRule;
2627

2728
// act
2829
const rule = new AlertRule(config);
2930
// assert
3031
expect(rule.any).toEqual(1);
3132
expect(rule.type).toEqual(AlertRuleType.AnyInWindow);
33+
// we need the window on the object, even though it doesn't appear to be used, because
34+
// the type is serialised when a snapshot is taken
35+
expect(rule.window).toEqual("-100m");
3236
});
3337
describe("with no window defined", () => {
3438
it("should define window of -5m ", async () => {

src/models/alert_configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class AlertRule {
4141
public any?: number;
4242
public fromDate?: Date;
4343
public match?: string;
44+
public window?: string;
4445
private _isDefault: boolean;
4546
private _dayAndTimeEvaluator: DayAndTimeEvaluator;
4647

@@ -50,6 +51,7 @@ export class AlertRule {
5051
this.count = rule.count;
5152
this.any = rule.any;
5253
this.match = rule.match;
54+
this.window = rule.window;
5355
const noTypeConfigured = !this.count && !this.any;
5456
if (noTypeConfigured) {
5557
this.count = 1;

0 commit comments

Comments
 (0)