cat-a-logs 2.0.10 → 2.0.12
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.
- package/client/index.js +110 -110
- package/client/index.ts +111 -111
- package/package.json +9 -8
package/client/index.js
CHANGED
@@ -9,6 +9,113 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import { Logger } from "@aws-lambda-powertools/logger";
|
11
11
|
import { Ajv } from "ajv";
|
12
|
+
//Create new instance of Logger to use in function
|
13
|
+
const logger = new Logger({ serviceName: "serverlessAirline" });
|
14
|
+
//Set up Ajv instance for JSON validation
|
15
|
+
const ajv = new Ajv();
|
16
|
+
// from AWS: EMF schema to test/validate against with Ajv
|
17
|
+
const emfSchema = {
|
18
|
+
type: "object",
|
19
|
+
title: "Root Node",
|
20
|
+
required: ["_aws"],
|
21
|
+
properties: {
|
22
|
+
_aws: {
|
23
|
+
$id: "#/properties/_aws",
|
24
|
+
type: "object",
|
25
|
+
title: "Metadata",
|
26
|
+
required: ["Timestamp", "CloudWatchMetrics"],
|
27
|
+
properties: {
|
28
|
+
Timestamp: {
|
29
|
+
$id: "#/properties/_aws/properties/Timestamp",
|
30
|
+
type: "integer",
|
31
|
+
title: "The Timestamp Schema",
|
32
|
+
examples: [1565375354953],
|
33
|
+
},
|
34
|
+
CloudWatchMetrics: {
|
35
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics",
|
36
|
+
type: "array",
|
37
|
+
title: "MetricDirectives",
|
38
|
+
items: {
|
39
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items",
|
40
|
+
type: "object",
|
41
|
+
title: "MetricDirective",
|
42
|
+
required: ["Namespace", "Dimensions", "Metrics"],
|
43
|
+
properties: {
|
44
|
+
Namespace: {
|
45
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Namespace",
|
46
|
+
type: "string",
|
47
|
+
title: "CloudWatch Metrics Namespace",
|
48
|
+
examples: ["MyApp"],
|
49
|
+
pattern: "^(.*)$",
|
50
|
+
minLength: 1,
|
51
|
+
maxLength: 1024,
|
52
|
+
},
|
53
|
+
Dimensions: {
|
54
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions",
|
55
|
+
type: "array",
|
56
|
+
title: "The Dimensions Schema",
|
57
|
+
minItems: 1,
|
58
|
+
items: {
|
59
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items",
|
60
|
+
type: "array",
|
61
|
+
title: "DimensionSet",
|
62
|
+
minItems: 0,
|
63
|
+
maxItems: 30,
|
64
|
+
items: {
|
65
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items/items",
|
66
|
+
type: "string",
|
67
|
+
title: "DimensionReference",
|
68
|
+
examples: ["Operation"],
|
69
|
+
pattern: "^(.*)$",
|
70
|
+
minLength: 1,
|
71
|
+
maxLength: 250,
|
72
|
+
},
|
73
|
+
},
|
74
|
+
},
|
75
|
+
Metrics: {
|
76
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics",
|
77
|
+
type: "array",
|
78
|
+
title: "MetricDefinitions",
|
79
|
+
items: {
|
80
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items",
|
81
|
+
type: "object",
|
82
|
+
title: "MetricDefinition",
|
83
|
+
required: ["Name"],
|
84
|
+
properties: {
|
85
|
+
Name: {
|
86
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Name",
|
87
|
+
type: "string",
|
88
|
+
title: "MetricName",
|
89
|
+
examples: ["ProcessingLatency"],
|
90
|
+
pattern: "^(.*)$",
|
91
|
+
minLength: 1,
|
92
|
+
maxLength: 1024,
|
93
|
+
},
|
94
|
+
Unit: {
|
95
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Unit",
|
96
|
+
type: "string",
|
97
|
+
title: "MetricUnit",
|
98
|
+
examples: ["Milliseconds"],
|
99
|
+
pattern: "^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\\/Second|Kilobytes\\/Second|Megabytes\\/Second|Gigabytes\\/Second|Terabytes\\/Second|Bits\\/Second|Kilobits\\/Second|Megabits\\/Second|Gigabits\\/Second|Terabits\\/Second|Count\\/Second|None)$",
|
100
|
+
},
|
101
|
+
StorageResolution: {
|
102
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/StorageResolution",
|
103
|
+
type: "integer",
|
104
|
+
title: "StorageResolution",
|
105
|
+
examples: [60],
|
106
|
+
},
|
107
|
+
},
|
108
|
+
},
|
109
|
+
},
|
110
|
+
},
|
111
|
+
},
|
112
|
+
},
|
113
|
+
},
|
114
|
+
},
|
115
|
+
},
|
116
|
+
};
|
117
|
+
//usable instance of the validation JSON
|
118
|
+
const validateEmf = ajv.compile(emfSchema);
|
12
119
|
//cache entries are structured thusly: 'Namespace + DimensionsKeys(Alphabetically)': EMFObject
|
13
120
|
const cache = {};
|
14
121
|
//let latency = 300; (Example metric to track)
|
@@ -37,113 +144,6 @@ function catalog(trackedVariable_1, metricName_1) {
|
|
37
144
|
if (Object.keys(CustomerDefinedDimension).length > 30) {
|
38
145
|
throw new Error("EMF has a limit of 30 user defined dimension keys per log");
|
39
146
|
}
|
40
|
-
//Create new instance of Logger to use in function
|
41
|
-
const logger = new Logger({ serviceName: "serverlessAirline" });
|
42
|
-
//Set up Ajv instance for JSON validation
|
43
|
-
const ajv = new Ajv();
|
44
|
-
// from AWS: EMF schema to test/validate against with Ajv
|
45
|
-
const emfSchema = {
|
46
|
-
type: "object",
|
47
|
-
title: "Root Node",
|
48
|
-
required: ["_aws"],
|
49
|
-
properties: {
|
50
|
-
_aws: {
|
51
|
-
$id: "#/properties/_aws",
|
52
|
-
type: "object",
|
53
|
-
title: "Metadata",
|
54
|
-
required: ["Timestamp", "CloudWatchMetrics"],
|
55
|
-
properties: {
|
56
|
-
Timestamp: {
|
57
|
-
$id: "#/properties/_aws/properties/Timestamp",
|
58
|
-
type: "integer",
|
59
|
-
title: "The Timestamp Schema",
|
60
|
-
examples: [1565375354953],
|
61
|
-
},
|
62
|
-
CloudWatchMetrics: {
|
63
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics",
|
64
|
-
type: "array",
|
65
|
-
title: "MetricDirectives",
|
66
|
-
items: {
|
67
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items",
|
68
|
-
type: "object",
|
69
|
-
title: "MetricDirective",
|
70
|
-
required: ["Namespace", "Dimensions", "Metrics"],
|
71
|
-
properties: {
|
72
|
-
Namespace: {
|
73
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Namespace",
|
74
|
-
type: "string",
|
75
|
-
title: "CloudWatch Metrics Namespace",
|
76
|
-
examples: ["MyApp"],
|
77
|
-
pattern: "^(.*)$",
|
78
|
-
minLength: 1,
|
79
|
-
maxLength: 1024,
|
80
|
-
},
|
81
|
-
Dimensions: {
|
82
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions",
|
83
|
-
type: "array",
|
84
|
-
title: "The Dimensions Schema",
|
85
|
-
minItems: 1,
|
86
|
-
items: {
|
87
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items",
|
88
|
-
type: "array",
|
89
|
-
title: "DimensionSet",
|
90
|
-
minItems: 0,
|
91
|
-
maxItems: 30,
|
92
|
-
items: {
|
93
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items/items",
|
94
|
-
type: "string",
|
95
|
-
title: "DimensionReference",
|
96
|
-
examples: ["Operation"],
|
97
|
-
pattern: "^(.*)$",
|
98
|
-
minLength: 1,
|
99
|
-
maxLength: 250,
|
100
|
-
},
|
101
|
-
},
|
102
|
-
},
|
103
|
-
Metrics: {
|
104
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics",
|
105
|
-
type: "array",
|
106
|
-
title: "MetricDefinitions",
|
107
|
-
items: {
|
108
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items",
|
109
|
-
type: "object",
|
110
|
-
title: "MetricDefinition",
|
111
|
-
required: ["Name"],
|
112
|
-
properties: {
|
113
|
-
Name: {
|
114
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Name",
|
115
|
-
type: "string",
|
116
|
-
title: "MetricName",
|
117
|
-
examples: ["ProcessingLatency"],
|
118
|
-
pattern: "^(.*)$",
|
119
|
-
minLength: 1,
|
120
|
-
maxLength: 1024,
|
121
|
-
},
|
122
|
-
Unit: {
|
123
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Unit",
|
124
|
-
type: "string",
|
125
|
-
title: "MetricUnit",
|
126
|
-
examples: ["Milliseconds"],
|
127
|
-
pattern: "^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\\/Second|Kilobytes\\/Second|Megabytes\\/Second|Gigabytes\\/Second|Terabytes\\/Second|Bits\\/Second|Kilobits\\/Second|Megabits\\/Second|Gigabits\\/Second|Terabits\\/Second|Count\\/Second|None)$",
|
128
|
-
},
|
129
|
-
StorageResolution: {
|
130
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/StorageResolution",
|
131
|
-
type: "integer",
|
132
|
-
title: "StorageResolution",
|
133
|
-
examples: [60],
|
134
|
-
},
|
135
|
-
},
|
136
|
-
},
|
137
|
-
},
|
138
|
-
},
|
139
|
-
},
|
140
|
-
},
|
141
|
-
},
|
142
|
-
},
|
143
|
-
},
|
144
|
-
};
|
145
|
-
//usable instance of the validation JSON
|
146
|
-
const validateEmf = ajv.compile(emfSchema);
|
147
147
|
//sort customerDimensions key values in alphabetical order. We will use this to keep the keys in our cache consistant. Since the order of the dimensions do not change where the metrics are stored
|
148
148
|
// const sortedDimensions: { [key: string]: string } = {}; // Doesn't need to be an object. Made it a string
|
149
149
|
let sortedDimensions = '';
|
@@ -173,7 +173,7 @@ function catalog(trackedVariable_1, metricName_1) {
|
|
173
173
|
CloudWatchMetrics: [
|
174
174
|
{
|
175
175
|
Namespace: metricNamespace,
|
176
|
-
Dimensions: sortedCustomerDimensions,
|
176
|
+
Dimensions: [sortedCustomerDimensions],
|
177
177
|
Metrics: [
|
178
178
|
{
|
179
179
|
Name: metricName,
|
@@ -187,12 +187,12 @@ function catalog(trackedVariable_1, metricName_1) {
|
|
187
187
|
[`${metricName}`]: trackedVariable,
|
188
188
|
}, CustomerDefinedDimension);
|
189
189
|
// Log the Unit value before validation
|
190
|
-
console.log("index.ts - Unit value before validation
|
190
|
+
console.log("index.ts - Unit value before validation = ", newEmfLog._aws.CloudWatchMetrics[0].Metrics[0].Unit);
|
191
191
|
// validate the new EMF JSON schema against AWS EMF JSON schema before adding to cache object
|
192
192
|
const isValid = validateEmf(newEmfLog);
|
193
193
|
// if the new EMF object fails validation, throw error and do not cache flawed object
|
194
194
|
if (!isValid) {
|
195
|
-
console.error("An error occurred during EMF validation
|
195
|
+
console.error("An error occurred during EMF validation = ", validateEmf.errors);
|
196
196
|
throw new Error("Supplied/Proposed structured log does not comply with EMF schema");
|
197
197
|
}
|
198
198
|
// If the new EMF object passes validation then add to cache object
|
package/client/index.ts
CHANGED
@@ -1,5 +1,113 @@
|
|
1
1
|
import { Logger } from "@aws-lambda-powertools/logger";
|
2
2
|
import { Ajv } from "ajv";
|
3
|
+
//Create new instance of Logger to use in function
|
4
|
+
const logger = new Logger({ serviceName: "serverlessAirline" });
|
5
|
+
//Set up Ajv instance for JSON validation
|
6
|
+
const ajv = new Ajv();
|
7
|
+
// from AWS: EMF schema to test/validate against with Ajv
|
8
|
+
const emfSchema = {
|
9
|
+
type: "object",
|
10
|
+
title: "Root Node",
|
11
|
+
required: ["_aws"],
|
12
|
+
properties: {
|
13
|
+
_aws: {
|
14
|
+
$id: "#/properties/_aws",
|
15
|
+
type: "object",
|
16
|
+
title: "Metadata",
|
17
|
+
required: ["Timestamp", "CloudWatchMetrics"],
|
18
|
+
properties: {
|
19
|
+
Timestamp: {
|
20
|
+
$id: "#/properties/_aws/properties/Timestamp",
|
21
|
+
type: "integer",
|
22
|
+
title: "The Timestamp Schema",
|
23
|
+
examples: [1565375354953],
|
24
|
+
},
|
25
|
+
CloudWatchMetrics: {
|
26
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics",
|
27
|
+
type: "array",
|
28
|
+
title: "MetricDirectives",
|
29
|
+
items: {
|
30
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items",
|
31
|
+
type: "object",
|
32
|
+
title: "MetricDirective",
|
33
|
+
required: ["Namespace", "Dimensions", "Metrics"],
|
34
|
+
properties: {
|
35
|
+
Namespace: {
|
36
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Namespace",
|
37
|
+
type: "string",
|
38
|
+
title: "CloudWatch Metrics Namespace",
|
39
|
+
examples: ["MyApp"],
|
40
|
+
pattern: "^(.*)$",
|
41
|
+
minLength: 1,
|
42
|
+
maxLength: 1024,
|
43
|
+
},
|
44
|
+
Dimensions: {
|
45
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions",
|
46
|
+
type: "array",
|
47
|
+
title: "The Dimensions Schema",
|
48
|
+
minItems: 1,
|
49
|
+
items: {
|
50
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items",
|
51
|
+
type: "array",
|
52
|
+
title: "DimensionSet",
|
53
|
+
minItems: 0,
|
54
|
+
maxItems: 30,
|
55
|
+
items: {
|
56
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items/items",
|
57
|
+
type: "string",
|
58
|
+
title: "DimensionReference",
|
59
|
+
examples: ["Operation"],
|
60
|
+
pattern: "^(.*)$",
|
61
|
+
minLength: 1,
|
62
|
+
maxLength: 250,
|
63
|
+
},
|
64
|
+
},
|
65
|
+
},
|
66
|
+
Metrics: {
|
67
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics",
|
68
|
+
type: "array",
|
69
|
+
title: "MetricDefinitions",
|
70
|
+
items: {
|
71
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items",
|
72
|
+
type: "object",
|
73
|
+
title: "MetricDefinition",
|
74
|
+
required: ["Name"],
|
75
|
+
properties: {
|
76
|
+
Name: {
|
77
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Name",
|
78
|
+
type: "string",
|
79
|
+
title: "MetricName",
|
80
|
+
examples: ["ProcessingLatency"],
|
81
|
+
pattern: "^(.*)$",
|
82
|
+
minLength: 1,
|
83
|
+
maxLength: 1024,
|
84
|
+
},
|
85
|
+
Unit: {
|
86
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Unit",
|
87
|
+
type: "string",
|
88
|
+
title: "MetricUnit",
|
89
|
+
examples: ["Milliseconds"],
|
90
|
+
pattern:
|
91
|
+
"^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\\/Second|Kilobytes\\/Second|Megabytes\\/Second|Gigabytes\\/Second|Terabytes\\/Second|Bits\\/Second|Kilobits\\/Second|Megabits\\/Second|Gigabits\\/Second|Terabits\\/Second|Count\\/Second|None)$",
|
92
|
+
},
|
93
|
+
StorageResolution: {
|
94
|
+
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/StorageResolution",
|
95
|
+
type: "integer",
|
96
|
+
title: "StorageResolution",
|
97
|
+
examples: [60],
|
98
|
+
},
|
99
|
+
},
|
100
|
+
},
|
101
|
+
},
|
102
|
+
},
|
103
|
+
},
|
104
|
+
},
|
105
|
+
},
|
106
|
+
},
|
107
|
+
},
|
108
|
+
};
|
109
|
+
//usable instance of the validation JSON
|
110
|
+
const validateEmf = ajv.compile(emfSchema);
|
3
111
|
|
4
112
|
//cache entries are structured thusly: 'Namespace + DimensionsKeys(Alphabetically)': EMFObject
|
5
113
|
const cache: { [key: string]: any } = {};
|
@@ -42,114 +150,6 @@ async function catalog(
|
|
42
150
|
"EMF has a limit of 30 user defined dimension keys per log"
|
43
151
|
);
|
44
152
|
}
|
45
|
-
//Create new instance of Logger to use in function
|
46
|
-
const logger = new Logger({ serviceName: "serverlessAirline" });
|
47
|
-
//Set up Ajv instance for JSON validation
|
48
|
-
const ajv = new Ajv();
|
49
|
-
// from AWS: EMF schema to test/validate against with Ajv
|
50
|
-
const emfSchema = {
|
51
|
-
type: "object",
|
52
|
-
title: "Root Node",
|
53
|
-
required: ["_aws"],
|
54
|
-
properties: {
|
55
|
-
_aws: {
|
56
|
-
$id: "#/properties/_aws",
|
57
|
-
type: "object",
|
58
|
-
title: "Metadata",
|
59
|
-
required: ["Timestamp", "CloudWatchMetrics"],
|
60
|
-
properties: {
|
61
|
-
Timestamp: {
|
62
|
-
$id: "#/properties/_aws/properties/Timestamp",
|
63
|
-
type: "integer",
|
64
|
-
title: "The Timestamp Schema",
|
65
|
-
examples: [1565375354953],
|
66
|
-
},
|
67
|
-
CloudWatchMetrics: {
|
68
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics",
|
69
|
-
type: "array",
|
70
|
-
title: "MetricDirectives",
|
71
|
-
items: {
|
72
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items",
|
73
|
-
type: "object",
|
74
|
-
title: "MetricDirective",
|
75
|
-
required: ["Namespace", "Dimensions", "Metrics"],
|
76
|
-
properties: {
|
77
|
-
Namespace: {
|
78
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Namespace",
|
79
|
-
type: "string",
|
80
|
-
title: "CloudWatch Metrics Namespace",
|
81
|
-
examples: ["MyApp"],
|
82
|
-
pattern: "^(.*)$",
|
83
|
-
minLength: 1,
|
84
|
-
maxLength: 1024,
|
85
|
-
},
|
86
|
-
Dimensions: {
|
87
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions",
|
88
|
-
type: "array",
|
89
|
-
title: "The Dimensions Schema",
|
90
|
-
minItems: 1,
|
91
|
-
items: {
|
92
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items",
|
93
|
-
type: "array",
|
94
|
-
title: "DimensionSet",
|
95
|
-
minItems: 0,
|
96
|
-
maxItems: 30,
|
97
|
-
items: {
|
98
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Dimensions/items/items",
|
99
|
-
type: "string",
|
100
|
-
title: "DimensionReference",
|
101
|
-
examples: ["Operation"],
|
102
|
-
pattern: "^(.*)$",
|
103
|
-
minLength: 1,
|
104
|
-
maxLength: 250,
|
105
|
-
},
|
106
|
-
},
|
107
|
-
},
|
108
|
-
Metrics: {
|
109
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics",
|
110
|
-
type: "array",
|
111
|
-
title: "MetricDefinitions",
|
112
|
-
items: {
|
113
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items",
|
114
|
-
type: "object",
|
115
|
-
title: "MetricDefinition",
|
116
|
-
required: ["Name"],
|
117
|
-
properties: {
|
118
|
-
Name: {
|
119
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Name",
|
120
|
-
type: "string",
|
121
|
-
title: "MetricName",
|
122
|
-
examples: ["ProcessingLatency"],
|
123
|
-
pattern: "^(.*)$",
|
124
|
-
minLength: 1,
|
125
|
-
maxLength: 1024,
|
126
|
-
},
|
127
|
-
Unit: {
|
128
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/Unit",
|
129
|
-
type: "string",
|
130
|
-
title: "MetricUnit",
|
131
|
-
examples: ["Milliseconds"],
|
132
|
-
pattern:
|
133
|
-
"^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\\/Second|Kilobytes\\/Second|Megabytes\\/Second|Gigabytes\\/Second|Terabytes\\/Second|Bits\\/Second|Kilobits\\/Second|Megabits\\/Second|Gigabits\\/Second|Terabits\\/Second|Count\\/Second|None)$",
|
134
|
-
},
|
135
|
-
StorageResolution: {
|
136
|
-
$id: "#/properties/_aws/properties/CloudWatchMetrics/items/properties/Metrics/items/properties/StorageResolution",
|
137
|
-
type: "integer",
|
138
|
-
title: "StorageResolution",
|
139
|
-
examples: [60],
|
140
|
-
},
|
141
|
-
},
|
142
|
-
},
|
143
|
-
},
|
144
|
-
},
|
145
|
-
},
|
146
|
-
},
|
147
|
-
},
|
148
|
-
},
|
149
|
-
},
|
150
|
-
};
|
151
|
-
//usable instance of the validation JSON
|
152
|
-
const validateEmf = ajv.compile(emfSchema);
|
153
153
|
//sort customerDimensions key values in alphabetical order. We will use this to keep the keys in our cache consistant. Since the order of the dimensions do not change where the metrics are stored
|
154
154
|
// const sortedDimensions: { [key: string]: string } = {}; // Doesn't need to be an object. Made it a string
|
155
155
|
let sortedDimensions: string = '';
|
@@ -185,7 +185,7 @@ async function catalog(
|
|
185
185
|
CloudWatchMetrics: [
|
186
186
|
{
|
187
187
|
Namespace: metricNamespace,
|
188
|
-
Dimensions: sortedCustomerDimensions,
|
188
|
+
Dimensions: [sortedCustomerDimensions],
|
189
189
|
Metrics: [
|
190
190
|
{
|
191
191
|
Name: metricName,
|
@@ -203,7 +203,7 @@ async function catalog(
|
|
203
203
|
|
204
204
|
// Log the Unit value before validation
|
205
205
|
console.log(
|
206
|
-
"index.ts - Unit value before validation
|
206
|
+
"index.ts - Unit value before validation = ",
|
207
207
|
newEmfLog._aws.CloudWatchMetrics[0].Metrics[0].Unit
|
208
208
|
);
|
209
209
|
|
@@ -212,7 +212,7 @@ async function catalog(
|
|
212
212
|
// if the new EMF object fails validation, throw error and do not cache flawed object
|
213
213
|
if (!isValid) {
|
214
214
|
console.error(
|
215
|
-
"An error occurred during EMF validation
|
215
|
+
"An error occurred during EMF validation = ",
|
216
216
|
validateEmf.errors
|
217
217
|
);
|
218
218
|
throw new Error(
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cat-a-logs",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.12",
|
4
4
|
"description": "Create & send structured logs to AWS Cloudwatch logs",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -17,13 +17,13 @@
|
|
17
17
|
"license": "ISC",
|
18
18
|
"type": "module",
|
19
19
|
"devDependencies": {
|
20
|
-
"ts-jest": "^29.2.5",
|
21
|
-
"ts-loader": "^9.5.1",
|
22
|
-
"typescript": "^5.7.3",
|
23
|
-
"jest": "^29.7.0",
|
24
20
|
"@types/jest": "^29.5.14",
|
25
21
|
"concurrently": "^9.0.1",
|
26
|
-
"cross-env": "^7.0.3"
|
22
|
+
"cross-env": "^7.0.3",
|
23
|
+
"jest": "^29.7.0",
|
24
|
+
"ts-jest": "^29.2.5",
|
25
|
+
"ts-loader": "^9.5.1",
|
26
|
+
"typescript": "^5.7.3"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
29
|
"@aws-lambda-powertools/logger": "^2.11.0",
|
@@ -33,8 +33,9 @@
|
|
33
33
|
"@testing-library/react": "^16.0.1",
|
34
34
|
"@testing-library/user-event": "^14.5.2",
|
35
35
|
"ajv": "^8.17.1",
|
36
|
+
"aws-lambda": "^1.0.7",
|
37
|
+
"dotenv": "^16.4.7",
|
36
38
|
"jest-environment-jsdom": "^29.7.0",
|
37
|
-
"lambda-log": "^3.1.0"
|
38
|
-
"dotenv": "^16.4.7"
|
39
|
+
"lambda-log": "^3.1.0"
|
39
40
|
}
|
40
41
|
}
|