serverless-plugin-datadog 5.72.0 → 5.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,23 @@ export interface TemplateVariable {
14
14
  name: string;
15
15
  defaults: string[];
16
16
  }
17
+ export interface RecommendedMonitorParams {
18
+ id: string;
19
+ attributes: {
20
+ query: string;
21
+ message: string;
22
+ description: string;
23
+ type: string;
24
+ options: {
25
+ thresholds: {
26
+ [key: string]: any;
27
+ };
28
+ };
29
+ name: string;
30
+ template_variables?: TemplateVariable[];
31
+ tags: string[];
32
+ };
33
+ }
17
34
  export declare function createMonitor(site: string, monitorParams: MonitorParams, monitorsApiKey: string, monitorsAppKey: string): Promise<Response>;
18
35
  export declare function updateMonitor(site: string, monitorId: number, monitorParams: MonitorParams, monitorsApiKey: string, monitorsAppKey: string): Promise<Response>;
19
36
  export declare function deleteMonitor(site: string, monitorId: number, monitorsApiKey: string, monitorsAppKey: string): Promise<Response>;
@@ -25,5 +42,6 @@ export declare function getExistingMonitors(site: string, cloudFormationStackId:
25
42
  export declare function getRecommendedMonitors(site: string, monitorsApiKey: string, monitorsAppKey: string): Promise<{
26
43
  [key: string]: ServerlessMonitor;
27
44
  }>;
45
+ export declare function parseRecommendedMonitorServerlessId(recommendedMonitorParams: RecommendedMonitorParams): string | undefined;
28
46
  export {};
29
47
  //# sourceMappingURL=monitor-api-requests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"monitor-api-requests.d.ts","sourceRoot":"","sources":["../../src/monitor-api-requests.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA4B,MAAM,YAAY,CAAC;AAExF,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,EAAE,MAAM;CAK5B;AAED,UAAU,cAAc;IACtB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,CAAC,CAWnB;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,QAAQ,CAAC,CAYnB;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,QAAQ,CAAC,CAWnB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,cAAc,EAAE,CAAC,CA0B3B;AAED,wBAAsB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAetF;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,qBAAqB,EAAE,MAAM,EAC7B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC,CAiBpC;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;IACT,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC,CAAC,CA6CD;AAED,wBAAgB,mCAAmC,CACjD,wBAAwB,EAAE,wBAAwB,GACjD,MAAM,GAAG,SAAS,CAOpB"}
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getRecommendedMonitors = exports.getExistingMonitors = exports.getCloudFormationStackId = exports.searchMonitors = exports.deleteMonitor = exports.updateMonitor = exports.createMonitor = exports.InvalidAuthenticationError = void 0;
15
+ exports.parseRecommendedMonitorServerlessId = exports.getRecommendedMonitors = exports.getExistingMonitors = exports.getCloudFormationStackId = exports.searchMonitors = exports.deleteMonitor = exports.updateMonitor = exports.createMonitor = exports.InvalidAuthenticationError = void 0;
16
16
  const node_fetch_1 = __importDefault(require("node-fetch"));
17
17
  const monitors_1 = require("./monitors");
18
18
  class InvalidAuthenticationError extends Error {
@@ -128,7 +128,7 @@ function getRecommendedMonitors(site, monitorsApiKey, monitorsAppKey) {
128
128
  return __awaiter(this, void 0, void 0, function* () {
129
129
  const recommendedMonitors = {};
130
130
  // Setting a count of 50 in the hope that all can be fetched at once. The default is 10 per page.
131
- const endpoint = `https://api.${site}/api/v2/monitor/recommended?count=50&start=0&search=tag%3A%22product%3Aserverless%22`;
131
+ const endpoint = `https://api.${site}/api/v2/monitor/recommended?count=50&start=0&search=tag%3A%22product%3Aserverless%22%20AND%20tag%3A%22integration%3Aamazon-lambda%22`;
132
132
  const response = yield (0, node_fetch_1.default)(endpoint, {
133
133
  method: "GET",
134
134
  headers: {
@@ -143,6 +143,10 @@ function getRecommendedMonitors(site, monitorsApiKey, monitorsAppKey) {
143
143
  const json = yield response.json();
144
144
  const recommendedMonitorsData = json.data;
145
145
  recommendedMonitorsData.forEach((recommendedMonitorParam) => {
146
+ const recommendedMonitorId = parseRecommendedMonitorServerlessId(recommendedMonitorParam);
147
+ if (recommendedMonitorId === undefined) {
148
+ return;
149
+ }
146
150
  const recommendedMonitor = {
147
151
  name: recommendedMonitorParam.attributes.name,
148
152
  threshold: recommendedMonitorParam.attributes.options.thresholds.critical,
@@ -159,12 +163,19 @@ function getRecommendedMonitors(site, monitorsApiKey, monitorsAppKey) {
159
163
  },
160
164
  templateVariables: recommendedMonitorParam.attributes.template_variables,
161
165
  };
162
- // recommended monitor params have an id that includes a serverless_ prefix that we have to remove to match the monitor ids we use in the plugin
163
- const recommendedMonitorId = recommendedMonitorParam.id.replace("serverless_", "");
164
166
  recommendedMonitors[recommendedMonitorId] = recommendedMonitor;
165
167
  });
166
168
  return recommendedMonitors;
167
169
  });
168
170
  }
169
171
  exports.getRecommendedMonitors = getRecommendedMonitors;
172
+ function parseRecommendedMonitorServerlessId(recommendedMonitorParams) {
173
+ for (const tag of recommendedMonitorParams.attributes.tags) {
174
+ if (tag.startsWith("serverless_id:")) {
175
+ return tag.substring(tag.indexOf(":") + 1);
176
+ }
177
+ }
178
+ return undefined;
179
+ }
180
+ exports.parseRecommendedMonitorServerlessId = parseRecommendedMonitorServerlessId;
170
181
  //# sourceMappingURL=monitor-api-requests.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"monitor-api-requests.js","sourceRoot":"","sources":["../../src/monitor-api-requests.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA6C;AAE7C,yCAAwF;AAExF,MAAa,0BAA2B,SAAQ,KAAK;IACnD,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAND,gEAMC;AA6BD,SAAsB,aAAa,CACjC,IAAY,EACZ,aAA4B,EAC5B,cAAsB,EACtB,cAAsB;;QAEtB,MAAM,QAAQ,GAAa,MAAM,IAAA,oBAAK,EAAC,eAAe,IAAI,iBAAiB,EAAE;YAC3E,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,YAAY,EAAE,cAAc;gBAC5B,oBAAoB,EAAE,cAAc;gBACpC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;SACpC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAhBD,sCAgBC;AAED,SAAsB,aAAa,CACjC,IAAY,EACZ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AAK,CAAC,OAAO,CAAC,UAAU,EAAE,+BAA+B,qBAAqB,EAAE,CAAC,CAAC;oBAE1F,IAAI,iBAAiB,KAAK,uBAAuB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE;wBACxF,KAAK,GAAG,IAAA,mCAAwB,EAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;qBAC5D;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,iBAAiB,EAAE,uBAAuB,CAAC,UAAU,CAAC,kBAAkB;aACzE,CAAC;YACF,mBAAmB,CAAC,oBAAoB,CAAC,GAAG,kBAAkB,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CAAA;AAnDD,wDAmDC;AAED,SAAgB,mCAAmC,CACjD,wBAAkD;IAElD,KAAK,MAAM,GAAG,IAAI,wBAAwB,CAAC,UAAU,CAAC,IAAI,EAAE;QAC1D,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;YACpC,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC5C;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AATD,kFASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-datadog",
3
- "version": "5.72.0",
3
+ "version": "5.74.0",
4
4
  "description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/DataDog/serverless-plugin-datadog",
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "prebuild": "./scripts/check_layers_json.sh",
11
11
  "build": "tsc",
12
- "test": "jest",
12
+ "test": "jest --config jest.config.js",
13
+ "test:integration": "jest ./integration_tests --config jest.integration.config.js",
13
14
  "test:watch": "jest --watch",
14
15
  "coverage": "jest --coverage",
15
16
  "lint": "tslint --project tsconfig.json",
@@ -63,5 +64,6 @@
63
64
  },
64
65
  "peerDependencies": {
65
66
  "serverless": "4.x || 3.x || 2.x || 1.x"
66
- }
67
+ },
68
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
67
69
  }
@@ -1,3 +0,0 @@
1
- import * as Serverless from "serverless";
2
- export declare function pythonCompileAll(serverless: Serverless): void;
3
- //# sourceMappingURL=compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAGzC,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,QAIvB"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pythonCompileAll = void 0;
4
- const child_process_1 = require("child_process");
5
- function pythonCompileAll(serverless) {
6
- let result = (0, child_process_1.spawnSync)('ls', ['-al', '.serverless']);
7
- serverless.cli.log(result.stdout.toString());
8
- }
9
- exports.pythonCompileAll = pythonCompileAll;
10
- //# sourceMappingURL=compile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":";;;AACA,iDAA0C;AAE1C,SAAgB,gBAAgB,CAC9B,UAAsB;IAEtB,IAAI,MAAM,GAAG,IAAA,yBAAS,EAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IACrD,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/C,CAAC;AALD,4CAKC"}
@@ -1,2 +0,0 @@
1
- export declare function precompilePython(serverless: any): void;
2
- //# sourceMappingURL=precomile-python.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precomile-python.d.ts","sourceRoot":"","sources":["../../src/precomile-python.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,QAW/C"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.precompilePython = void 0;
27
- const child_process_1 = require("child_process");
28
- const fs = __importStar(require("fs"));
29
- const path = __importStar(require("path"));
30
- function precompilePython(serverless) {
31
- serverless.cli.log('Precompiling Python files');
32
- let tempDirName = 'datadog';
33
- let slsDir = serverless.processedInput.options.package || '.serverless';
34
- let tempDir = path.resolve(slsDir, tempDirName);
35
- for (const file of lsDirFiles(slsDir, false)) {
36
- if (file.endsWith('.zip')) {
37
- preCompilePackage(tempDir, file);
38
- }
39
- }
40
- }
41
- exports.precompilePython = precompilePython;
42
- function preCompilePackage(tempDir, zipFile) {
43
- (0, child_process_1.spawnSync)('unzip', ['-d', tempDir, zipFile]);
44
- (0, child_process_1.spawnSync)('python', ['-m', 'compileall', '-b', tempDir]);
45
- replacePyFiles(tempDir);
46
- (0, child_process_1.spawnSync)('rm', [zipFile]);
47
- (0, child_process_1.execSync)(`cd ${tempDir} && zip -r ${zipFile} .`);
48
- (0, child_process_1.spawnSync)('rm', ['-r', tempDir]);
49
- }
50
- function replacePyFiles(dir) {
51
- for (const file of lsDirFiles(dir)) {
52
- if (file.endsWith('.pyc')) {
53
- let pyFile = file.replace('.pyc', '.py');
54
- (0, child_process_1.spawnSync)('rm', [pyFile]);
55
- }
56
- }
57
- }
58
- function* lsDirFiles(dir, recursive = true) {
59
- for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
60
- const res = path.resolve(dir, dirent.name);
61
- if (recursive && dirent.isDirectory()) {
62
- yield* lsDirFiles(res, recursive);
63
- }
64
- else {
65
- yield res;
66
- }
67
- }
68
- }
69
- //# sourceMappingURL=precomile-python.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precomile-python.js","sourceRoot":"","sources":["../../src/precomile-python.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,gBAAgB,CAAC,UAAe;IAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,SAAS,CAAC;IAC5B,IAAI,MAAM,GAAG,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC;IACxE,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEhD,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzB,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAClC;KACF;A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;aAAM;YACL,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function precompilePython(serverless: any): void;
2
- //# sourceMappingURL=precompile-python.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precompile-python.d.ts","sourceRoot":"","sources":["../../src/precompile-python.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,QAW/C"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.precompilePython = void 0;
27
- const child_process_1 = require("child_process");
28
- const fs = __importStar(require("fs"));
29
- const path = __importStar(require("path"));
30
- function precompilePython(serverless) {
31
- serverless.cli.log('Precompiling Python files');
32
- let tempDirName = 'datadog';
33
- let slsDir = serverless.processedInput.options.package || '.serverless';
34
- let tempDir = path.resolve(slsDir, tempDirName);
35
- for (const file of lsDirFiles(slsDir, false)) {
36
- if (file.endsWith('.zip')) {
37
- preCompilePackage(serverless.service.provider.runtime, tempDir, file);
38
- }
39
- }
40
- }
41
- exports.precompilePython = precompilePython;
42
- function preCompilePackage(python, tempDir, zipFile) {
43
- (0, child_process_1.spawnSync)('unzip', ['-d', tempDir, zipFile]);
44
- precompile(python, tempDir);
45
- replacePyFiles(tempDir);
46
- (0, child_process_1.spawnSync)('rm', [zipFile]);
47
- (0, child_process_1.execSync)(`cd ${tempDir} && zip -r ${zipFile} .`);
48
- (0, child_process_1.spawnSync)('rm', ['-r', tempDir]);
49
- }
50
- function precompile(python, dir) {
51
- // TODO: run precompile in docker container
52
- //spawnSync('python', ['-m', 'compileall', '-b', dir]);
53
- console.log("----------------------------------------");
54
- console.log("python: ", python);
55
- console.log("----------------------------------------");
56
- let image = python.replace('python3', 'python:3');
57
- (0, child_process_1.spawnSync)('docker', ['run', '-v', `${dir}:/mnt`, image, 'python', '-m', 'compileall', '-b', '/mnt']);
58
- }
59
- function replacePyFiles(dir) {
60
- for (const file of lsDirFiles(dir)) {
61
- if (file.endsWith('.pyc')) {
62
- let pyFile = file.replace('.pyc', '.py');
63
- (0, child_process_1.spawnSync)('rm', [pyFile]);
64
- }
65
- }
66
- }
67
- function* lsDirFiles(dir, recursive = true) {
68
- for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
69
- const res = path.resolve(dir, dirent.name);
70
- if (recursive && dirent.isDirectory()) {
71
- yield* lsDirFiles(res, recursive);
72
- }
73
- else {
74
- yield res;
75
- }
76
- }
77
- }
78
- //# sourceMappingURL=precompile-python.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precompile-python.js","sourceRoot":"","sources":["../../src/precompile-python.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAoD;AACpD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,gBAAgB,CAAC,UAAe;IAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,SAAS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C,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzC,IAAA,yBAAS,EAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;SAC3B;KACF;AACH,CAAC;AAED,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAW,EAAE,SAAS,GAAG,IAAI;IAChD,KAAK,MAAM,MAAM,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,SAAS,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE;YACrC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;SACnC;aAAM;YACL,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC"}
@@ -1,18 +0,0 @@
1
- export interface ServerlessMonitor {
2
- name: string;
3
- threshold: number;
4
- query: (cloudFormationStackId: string, criticalThreshold: number) => string;
5
- message: string;
6
- type?: string;
7
- }
8
- export declare const HIGH_ERROR_RATE: ServerlessMonitor;
9
- export declare const TIMEOUT: ServerlessMonitor;
10
- export declare const OUT_OF_MEMORY: ServerlessMonitor;
11
- export declare const HIGH_ITERATOR_AGE: ServerlessMonitor;
12
- export declare const HIGH_COLD_START_RATE: ServerlessMonitor;
13
- export declare const HIGH_THROTTLES: ServerlessMonitor;
14
- export declare const INCREASED_COST: ServerlessMonitor;
15
- export declare const SERVERLESS_MONITORS: {
16
- [key: string]: ServerlessMonitor;
17
- };
18
- //# sourceMappingURL=serverless_monitors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverless_monitors.d.ts","sourceRoot":"","sources":["../../src/serverless_monitors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,EAAE,iBAQ7B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,iBAQrB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,iBAQ3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAQ/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,iBAQlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,iBAQ5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,iBAQ5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAQnE,CAAC"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SERVERLESS_MONITORS = exports.INCREASED_COST = exports.HIGH_THROTTLES = exports.HIGH_COLD_START_RATE = exports.HIGH_ITERATOR_AGE = exports.OUT_OF_MEMORY = exports.TIMEOUT = exports.HIGH_ERROR_RATE = void 0;
4
- exports.HIGH_ERROR_RATE = {
5
- name: "High Error Rate on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
6
- threshold: 0.1,
7
- query: (cloudFormationStackId, criticalThreshold) => {
8
- return `avg(last_15m):sum:aws.lambda.errors{aws_cloudformation_stack-id:${cloudFormationStackId}} by {functionname,region,aws_account}.as_count() / sum:aws.lambda.invocations{aws_cloudformation_stack-id:${cloudFormationStackId}} by {functionname,region,aws_account}.as_count() >= ${criticalThreshold}`;
9
- },
10
- message: "More than 10% of the function’s invocations were errors in the selected time range. {{#is_alert}} Resolution: Examine the function’s logs, check for recent code or configuration changes with [Deployment Tracking](https://docs.datadoghq.com/serverless/deployment_tracking), or look for failures across microservices with [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing).{{/is_alert}}",
11
- };
12
- exports.TIMEOUT = {
13
- name: "Timeout on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
14
- threshold: 1,
15
- query: (cloudFormationStackId, criticalThreshold) => {
16
- return `avg(last_15m):sum:aws.lambda.duration.maximum{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,functionname,region}.as_count() / (sum:aws.lambda.timeout{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,functionname,region}.as_count() * 1000) >= ${criticalThreshold}`;
17
- },
18
- message: "At least one invocation in the selected time range timed out. This occurs when your function runs for longer than the configured timeout or the global Lambda timeout. Resolution: [Distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing) can help you pinpoint slow requests to APIs and other microservices. You can also consider increasing the timeout of your function. Note that this could affect your AWS bill.",
19
- };
20
- exports.OUT_OF_MEMORY = {
21
- name: "Out of Memory on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
22
- threshold: 0,
23
- query: (cloudFormationStackId, criticalThreshold) => {
24
- return `avg(last_15m):sum:aws.lambda.enhanced.out_of_memory{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,functionname,region} > ${criticalThreshold}`;
25
- },
26
- message: "At least one invocation in the selected time range ran out of memory. Resolution: Lambda functions that use more than their allotted amount of memory can be killed by the Lambda runtime. To users, this may look like failed requests to your application. [Distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing) can help you pinpoint parts of your application using excessive amounts of memory. Consider increasing the amount of memory your Lambda function is allowed to use.",
27
- };
28
- exports.HIGH_ITERATOR_AGE = {
29
- name: "High Iterator Age on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
30
- threshold: 86400,
31
- query: (cloudFormationStackId, criticalThreshold) => {
32
- return `avg(last_15m):min:aws.lambda.iterator_age.maximum{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,region,functionname} >= ${criticalThreshold}`;
33
- },
34
- message: "The function’s iterator was older than two hours. Iterator age measures the age of the last record for each batch of records processed from a stream. When this value increases, it means your function cannot process data fast enough. {{#is_alert}} Resolution: Enable [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing) to isolate why your function has so much data being streamed to it. You can also consider increasing the shard count and batch size of the stream your function reads from. {{/is_alert}}",
35
- };
36
- exports.HIGH_COLD_START_RATE = {
37
- name: "High Cold Start Rate on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
38
- threshold: 0.01,
39
- query: (cloudFormationStackId, criticalThreshold) => {
40
- return `avg(last_15m):sum:aws.lambda.enhanced.invocations{cold_start:true AND aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,functionname,region}.as_count() / sum:aws.lambda.enhanced.invocations{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,functionname,region}.as_count() >= ${criticalThreshold}`;
41
- },
42
- message: "More than 1% of the function’s invocations were cold starts in the selected time range. Datadog’s [enhanced metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics) and [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing) can help you understand the impact of cold starts on your applications today. {{#is_alert}} Resolution: Cold starts occur when your serverless applications receive sudden increases in traffic, and can occur when the function was previously inactive or when it was receiving a relatively constant number of requests. Users may perceive cold starts as slow response times or lag. To get ahead of cold starts, consider enabling [provisioned concurrency](https://www.datadoghq.com/blog/monitor-aws-lambda-provisioned-concurrency/) on your impacted Lambda functions. Note that this could affect your AWS bill. {{/is_alert}}",
43
- };
44
- exports.HIGH_THROTTLES = {
45
- name: "High Throttles on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
46
- threshold: 0.1,
47
- query: (cloudFormationStackId, criticalThreshold) => {
48
- return `avg(last_15m):sum:aws.lambda.throttles {aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,region,functionname}.as_count() / ( sum:aws.lambda.throttles {aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,region,functionname}.as_count() + sum:aws.lambda.invocations{aws_cloudformation_stack-id:${cloudFormationStackId}} by {aws_account,region,functionname}.as_count() ) >= ${criticalThreshold}`;
49
- },
50
- message: "More than 10% of invocations in the selected time range were throttled. Throttling occurs when your serverless Lambda applications receive high levels of traffic without adequate [concurrency](https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html). {{#is_alert}} Resolution: Check your [Lambda concurrency metrics](https://docs.datadoghq.com/integrations/amazon_lambda/#metrics) and confirm if `aws.lambda.concurrent_executions.maximum` is approaching your AWS account concurrency level. If so, consider configuring reserved concurrency, or request a service quota increase from AWS. Note that this may affect your AWS bill. {{/is_alert}}",
51
- };
52
- exports.INCREASED_COST = {
53
- name: "Increased Cost on {{functionname.name}} in {{region.name}} for {{aws_account.name}}",
54
- threshold: 0.2,
55
- query: (cloudFormationStackId, criticalThreshold) => {
56
- return `pct_change(avg(last_5m),last_5m):avg:aws.lambda.enhanced.estimated_cost{aws_cloudformation_stack-id:${cloudFormationStackId}} > ${criticalThreshold}`;
57
- },
58
- message: "This Lambda function’s estimated cost has increased more than 20%. This could be due to increased traffic to this function, or because it is running longer than expected. [Distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing) can help pinpoint application bottlenecks.",
59
- };
60
- exports.SERVERLESS_MONITORS = {
61
- high_error_rate: exports.HIGH_ERROR_RATE,
62
- timeout: exports.TIMEOUT,
63
- out_of_memory: exports.OUT_OF_MEMORY,
64
- high_iterator_age: exports.HIGH_ITERATOR_AGE,
65
- high_cold_start_rate: exports.HIGH_COLD_START_RATE,
66
- high_throttles: exports.HIGH_THROTTLES,
67
- increased_cost: exports.INCREASED_COST,
68
- };
69
- //# sourceMappingURL=serverless_monitors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverless_monitors.js","sourceRoot":"","sources":["../../src/serverless_monitors.ts"],"names":[],"mappings":";;;AAQa,QAAA,eAAe,GAAsB;IAChD,IAAI,EAAE,sFAAsF;IAC5F,SAAS,EAAE,GAAG;IACd,KAAK,EAAE,CAAC,qBAA6B,EAAE,iBAAyB,EAAE,EAAE;QAClE,OAAO,mEAAmE,qBAAqB,8GAA8G,qBAAqB,wDAAwD,iBAAiB,EAAE,CAAC;IAChT,CAAC;IACD,OAAO,EACL,gaAAga;CACna,CAAC;AAEW,QAAA,OAAO,GAAsB;IACxC,IAAI,EAAE,8EAA8E;IACpF,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC,qBAA6B,EAAE,iBAAyB,EAAE,EAAE;QAClE,OAAO,6EAA6E,qBAAqB,2GAA2G,qBAAqB,gEAAgE,iBAAiB,EAAE,CAAC;IAC/T,CAAC;IACD,OAAO,EACL,obAAob;CACvb,CAAC;AAEW,QAAA,aAAa,GAAsB;IAC9C,IAAI,EAAE,oFAAoF;IAC1F,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC,qBAA6B,EAAE,iBAAyB,EAAE,EAAE;QAClE,OAAO,mFAAmF,qBAAqB,4CAA4C,iBAAiB,EAAE,CAAC;IACjL,CAAC;IACD,OAAO,EACL,mfAAmf;CACtf,CAAC;AAEW,QAAA,iBAAiB,GAAsB;IAClD,IAAI,EAAE,wFAAwF;IAC9F,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,CAAC,qBAA6B,EAAE,iBAAyB,EAAE,EAAE;QAClE,OAAO,iFAAiF,qBAAqB,6CAA6C,iBAAiB,EAAE,CAAC;IAChL,CAAC;IACD,OAAO,EACL,shBAAshB;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