Skip to content

Commit 5b466df

Browse files
committed
[AZINTS] add package.json and host.json
1 parent 33f286b commit 5b466df

6 files changed

Lines changed: 96 additions & 25 deletions

File tree

azure/activity_logs_monitoring/function.json

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "2.0",
3+
"extensionBundle": {
4+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5+
"version": "[4.*, 5.0.0)"
6+
}
7+
}

azure/activity_logs_monitoring/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const { app, InvocationContext } = require('@azure/functions');
77

8-
const VERSION = '1.2.1';
8+
const VERSION = '2.0.0';
99

1010
const STRING = 'string'; // example: 'some message'
1111
const STRING_ARRAY = 'string-array'; // example: ['one message', 'two message', ...]
@@ -181,7 +181,7 @@ class HTTPClient {
181181
try {
182182
return await this.send(batch);
183183
} catch (e) {
184-
this.context.log.error(e);
184+
this.context.error(e);
185185
}
186186
})
187187
);
@@ -204,7 +204,7 @@ class HTTPClient {
204204
if (retries === 0) {
205205
throw new Error(errMsg);
206206
}
207-
this.context.log.warn(
207+
this.context.warn(
208208
`Unable to send request, with error: ${errMsg}. Retrying ${retries} more times`
209209
);
210210
retries--;
@@ -259,7 +259,7 @@ class Scrubber {
259259
)
260260
);
261261
} catch {
262-
context.log.error(
262+
context.error(
263263
`Regexp for rule ${name} pattern ${settings['pattern']} is malformed, skipping. Please update the pattern for this rule to be applied.`
264264
);
265265
}
@@ -414,10 +414,10 @@ class EventhubLogHandler {
414414
this.handleJSONArrayLogs(logs, JSON_STRING_ARRAY);
415415
break;
416416
case INVALID:
417-
this.context.log.error('Log format is invalid: ', logs);
417+
this.context.error('Log format is invalid: ', logs);
418418
break;
419419
default:
420-
this.context.log.error('Log format is invalid: ', logs);
420+
this.context.error('Log format is invalid: ', logs);
421421
break;
422422
}
423423
return this.records;
@@ -429,7 +429,7 @@ class EventhubLogHandler {
429429
try {
430430
message = JSON.parse(message);
431431
} catch {
432-
this.context.log.warn(
432+
this.context.warn(
433433
'log is malformed json, sending as string'
434434
);
435435
this.formatLog(STRING_TYPE, message);
@@ -441,7 +441,7 @@ class EventhubLogHandler {
441441
try {
442442
message = JSON.parse(message.toString());
443443
} catch {
444-
this.context.log.warn(
444+
this.context.warn(
445445
'log is malformed json, sending as string'
446446
);
447447
this.formatLog(STRING_TYPE, message.toString());
@@ -656,7 +656,7 @@ app.eventHub('datadog-function', {
656656
cardinality: 'many',
657657
handler: async (eventHubMessages, context) => {
658658
if (!DD_API_KEY || DD_API_KEY === '<DATADOG_API_KEY>') {
659-
context.log.error(
659+
context.error(
660660
'You must configure your API key before starting this function (see ## Parameters section)'
661661
);
662662
return;
@@ -666,13 +666,13 @@ app.eventHub('datadog-function', {
666666
let handler = new EventhubLogHandler(context);
667667
parsedLogs = handler.handleLogs(eventHubMessages);
668668
} catch (err) {
669-
context.log.error('Error raised when parsing logs: ', err);
669+
context.error('Error raised when parsing logs: ', err);
670670
throw err;
671671
}
672672
let results = await new HTTPClient(context).sendAll(parsedLogs);
673673

674674
if (results.every(v => v === true) !== true) {
675-
context.log.error(
675+
context.error(
676676
'Some messages were unable to be sent. See other logs for details.'
677677
);
678678
}

azure/activity_logs_monitoring/package-lock.json

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "datadog-eventhub-forwarder",
3+
"version": "2.0.0",
4+
"main": "index.js",
5+
"author": "Datadog",
6+
"license": "Apache-2.0",
7+
"dependencies": {
8+
"@azure/functions": "^4.7.0"
9+
}
10+
}

azure/deploy-to-azure/function_template.json

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)