Created
January 22, 2016 06:15
-
-
Save hideokamoto/a78255164a210ec2e51e to your computer and use it in GitHub Desktop.
CloudWatch Logs からElasticsearch Serviceに送るログのインデックス名を変える ref: http://qiita.com/motchi0214/items/5671c6f1a10655236b34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
payload.logEvents.forEach(function(logEvent) { | |
var timestamp = new Date(1 * logEvent.timestamp); | |
// index name format: cwl-YYYY.MM.DD | |
var indexName = [ | |
'cwl-' + timestamp.getUTCFullYear(), // year | |
('0' + (timestamp.getUTCMonth() + 1)).slice(-2), // month | |
('0' + timestamp.getUTCDate()).slice(-2) // day | |
].join('.'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var source = buildSource(logEvent.message, logEvent.extractedFields); | |
source['@id'] = logEvent.id; | |
source['@timestamp'] = new Date(1 * logEvent.timestamp).toISOString(); | |
source['@message'] = logEvent.message; | |
source['@owner'] = payload.owner; | |
source['@log_group'] = payload.logGroup; | |
source['@log_stream'] = payload.logStream;``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment