Skip to content

Commit

Permalink
added geoip tagging for VPC logs via logagent-js
Browse files Browse the repository at this point in the history
added remaining logagent-js files
  • Loading branch information
radu-gheorghe committed Mar 22, 2016
1 parent df846fd commit c6d8c9f
Show file tree
Hide file tree
Showing 1,505 changed files with 229,064 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -52,7 +52,7 @@ Finally, you'd upload the zip to AWS Lambda as the function code:
After the code, leave the handler to the default *index.handler* and select a role that allows this function to execute. You can create a new Basic execution role to do that (from the drop-down) or select a basic execution role that you've already created:
![role](https://raw.githubusercontent.com/sematext/logsene-aws-lambda-cloudwatch/master/img/role.png)

Then, you need to decide on how much memory you allow for the function and how long you allow it to run. This depends on the log throughput (more logs will need more processing resources) and will influence costs (i.e. like keeping the equivalent general-purpose instance up for that time). Normally, runtime is very short (sub-second) so even large resources shouldn't generate significant costs. The default 128MB and 3 second timeout should be enough for most use-cases:
Then, you need to decide on how much memory you allow for the function and how long you allow it to run. This depends on the log throughput (more logs will need more processing resources) and will influence costs (i.e. like keeping the equivalent general-purpose instance up for that time). Normally, runtime is very short so even large resources shouldn't generate significant costs. 256MB and 30 second timeout should be enough for most use-cases:
![memory](https://raw.githubusercontent.com/sematext/logsene-aws-lambda-cloudwatch/master/img/memory.png)

To enable the function to run when new logs come in, you'd need to enable the source with your Flow Log name at the last step.
Expand Down
Binary file modified img/memory.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions index.js
@@ -1,13 +1,13 @@
var logseneToken = 'LOGSENE-APP-TOKEN-GOES-HERE'

var zlib = require('zlib')
var net = require('net')
var client = null
var connected = false
var start = 0
var errorCounter = 0
var Logagent = require('logagent-js')
var lp = new Logagent('./pattern.yml')
var lp = null

function connectLogsene (cbf) {
client = net.connect(12201, 'logsene-receiver-syslog.sematext.com', function () {
connected = true
Expand Down Expand Up @@ -61,11 +61,13 @@ function parseLogs (err, data) {
if(key!=='message')
data[key] = this.event[key]
}.bind(this))
//console.log('Now my data is ' + JSON.stringify(data))
Object.keys(this.result).forEach(function (key) {
if (key !== 'logEvents') {
data['meta_' + key] = this.result[key]
}
}.bind(this))
//console.log('Now my data is ' + JSON.stringify(data))
shipLogs(data, function checkDone () {
//console.log('I\'m at ' + this.index + ' of ' + this.size)
if (this.index === this.size - 1) {
Expand Down Expand Up @@ -104,14 +106,19 @@ function pushLogs (event, context) {
})
console.log(Date.now() - start)
}


function handler (event, context) {
start = Date.now()
if (!connected) {
connectLogsene(function () {
lp = new Logagent('./pattern.yml', {}, function () {
if (!connected) {
connectLogsene(function () {
pushLogs(event, context)
})
} else {
pushLogs(event, context)
})
} else {
pushLogs(event, context)
}
}
})
}
exports.handler = handler

1 change: 1 addition & 0 deletions node_modules/.bin/esparse

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esvalidate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/har-validator

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/json2yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/logagent-setup

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/maxmind-geolite-mirror

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/prettyjson

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-conv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-sign

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-verify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/yaml2json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions node_modules/ansi-regex/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/ansi-regex/license

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions node_modules/ansi-regex/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions node_modules/ansi-regex/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6d8c9f

Please sign in to comment.