serverless-es-proxy-logs
Advanced tools
Comparing version 3.0.7-rc0 to 3.0.7-rc1
@@ -228,17 +228,16 @@ "use strict"; | ||
addLogProcesser() { | ||
const { index, endpoint, tags, securityGroupIds, subnetIds, sqsQueue } = this.custom().esLogs; | ||
const { index, endpoint, tags, securityGroupIds, subnetIds } = this.custom().esLogs; | ||
const tagsStringified = tags ? JSON.stringify(tags) : /* istanbul ignore next */ ''; | ||
const dirPath = path_1.default.join(this.serverless.config.servicePath, this.logProcesserDir); | ||
const filePath = path_1.default.join(dirPath, 'syslog.py'); | ||
const handler = `${this.logProcesserDir}/syslog.handler`; | ||
const filePath = path_1.default.join(dirPath, 'index.js'); | ||
const handler = `${this.logProcesserDir}/index.handler`; | ||
const name = `${this.serverless.service.service}-${this.options.stage}-es-logs-plugin`; | ||
fs_extra_1.default.ensureDirSync(dirPath); | ||
fs_extra_1.default.copySync(path_1.default.resolve(__dirname, '../templates/code/logsToEs.py'), filePath); | ||
fs_extra_1.default.copySync(path_1.default.resolve(__dirname, '../templates/code/logsToEs.js'), filePath); | ||
this.serverless.service.functions[this.logProcesserName] = { | ||
description: 'Serverless ES Logs Plugin', | ||
environment: { | ||
AWS_SQS_DLQ_NAME: sqsQueue, | ||
ELASTICSEARCH_GROUP: index, | ||
ELASTICSEARCH_INDEX: index, | ||
ES_ENDPOINT: endpoint, | ||
ES_INDEX_PREFIX: index, | ||
ES_TAGS: tagsStringified, | ||
}, | ||
@@ -254,3 +253,3 @@ events: [], | ||
}, | ||
runtime: 'python3.7', | ||
runtime: 'nodejs8.10', | ||
timeout: 60, | ||
@@ -257,0 +256,0 @@ tracing: true, |
{ | ||
"name": "serverless-es-proxy-logs", | ||
"version": "3.0.7-rc0", | ||
"version": "3.0.7-rc1", | ||
"license": "MIT", | ||
@@ -71,3 +71,4 @@ "description": "A Serverless plugin to transport logs to ElasticSearch", | ||
"fs-extra": "8.1.0", | ||
"lodash": "4.17.15" | ||
"lodash": "4.17.15", | ||
"socket.io-client": "^2.2.0" | ||
}, | ||
@@ -74,0 +75,0 @@ "devDependencies": { |
// v1.1.2 | ||
var https = require('https'); | ||
var zlib = require('zlib'); | ||
var crypto = require('crypto'); | ||
import io from 'socket.io-client'; | ||
var endpoint = process.env.ES_ENDPOINT; | ||
@@ -40,27 +41,35 @@ var indexPrefix = process.env.ES_INDEX_PREFIX; | ||
//socket data | ||
const socket = io(endpoint); | ||
socket.on('connect', () => { | ||
console.log('Successfully connected to es endpoint'); | ||
console.log('Emitting data'); | ||
socket.emit(elasticsearchBulkPayload); | ||
console.log('sent data'); | ||
}); | ||
// post documents to the Amazon Elasticsearch Service | ||
put(elasticsearchBulkPayload, function(error, success, statusCode, failedItems) { | ||
console.log('Response: ' + JSON.stringify({ | ||
"statusCode": statusCode | ||
})); | ||
if (error) { | ||
console.log('Error: ' + JSON.stringify(error, null, 2)); | ||
if (failedItems && failedItems.length > 0) { | ||
console.log("Failed Items: " + | ||
JSON.stringify(failedItems, null, 2)); | ||
var failedLogs = findFailedLogs(failedItems, elasticsearchBulkArray); | ||
failedLogs.forEach( failedLog => { | ||
console.log("Failed log content: " + JSON.stringify(failedLog, null, 2)); | ||
}); | ||
} | ||
context.fail(JSON.stringify(error)); | ||
} else { | ||
console.log('Success: ' + JSON.stringify(success)); | ||
context.succeed('Success'); | ||
} | ||
}); | ||
// put(elasticsearchBulkPayload, function(error, success, statusCode, failedItems) { | ||
// console.log('Response: ' + JSON.stringify({ | ||
// "statusCode": statusCode | ||
// })); | ||
// | ||
// if (error) { | ||
// console.log('Error: ' + JSON.stringify(error, null, 2)); | ||
// | ||
// if (failedItems && failedItems.length > 0) { | ||
// console.log("Failed Items: " + | ||
// JSON.stringify(failedItems, null, 2)); | ||
// | ||
// var failedLogs = findFailedLogs(failedItems, elasticsearchBulkArray); | ||
// failedLogs.forEach( failedLog => { | ||
// console.log("Failed log content: " + JSON.stringify(failedLog, null, 2)); | ||
// }); | ||
// } | ||
// | ||
// context.fail(JSON.stringify(error)); | ||
// } else { | ||
// console.log('Success: ' + JSON.stringify(success)); | ||
// context.succeed('Success'); | ||
// } | ||
// }); | ||
}); | ||
@@ -67,0 +76,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
748
56629
3
24
+ Addedsocket.io-client@^2.2.0
+ Addedafter@0.8.2(transitive)
+ Addedarraybuffer.slice@0.0.7(transitive)
+ Addedbacko2@1.0.2(transitive)
+ Addedbase64-arraybuffer@0.1.4(transitive)
+ Addedblob@0.0.5(transitive)
+ Addedcomponent-bind@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcomponent-inherit@0.0.3(transitive)
+ Addeddebug@3.1.0(transitive)
+ Addedengine.io-client@3.5.4(transitive)
+ Addedengine.io-parser@2.2.1(transitive)
+ Addedhas-binary2@1.0.3(transitive)
+ Addedhas-cors@1.1.0(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedisarray@2.0.1(transitive)
+ Addedms@2.0.0(transitive)
+ Addedparseqs@0.0.6(transitive)
+ Addedparseuri@0.0.6(transitive)
+ Addedsocket.io-client@2.5.0(transitive)
+ Addedsocket.io-parser@3.3.4(transitive)
+ Addedto-array@0.1.4(transitive)
+ Addedws@7.5.10(transitive)
+ Addedxmlhttprequest-ssl@1.6.3(transitive)
+ Addedyeast@0.1.2(transitive)