Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Control the number of shards and replicas

with environment variables:
ES_LOG4JS_SHARDS_NUMBER: 4 by default
ES_LOG4JS_REPLICAS_NUMBER: 1 by default
  • Loading branch information...
commit c0b0b70f854ed66efd59b2ac5a5ca0e53735e1db 1 parent 52ec8a5
@hmalphettes authored
Showing with 7 additions and 3 deletions.
  1. +6 −2 lib/log4js-elasticsearch-layouts.js
  2. +1 −1  package.json
View
8 lib/log4js-elasticsearch-layouts.js
@@ -167,7 +167,9 @@ layouts.esTemplateMakers = {};
// http://untergeek.com/2012/09/20/using-templates-to-improve-elasticsearch-caching-with-logstash/
layouts.esTemplateMakers.logstash = function(templateName, templateConfig) {
var nbOfShards = __getOpt(['settings', 'number_of_shards'], templateConfig,
- parseInt(process.env.ES_DEFAULT_SHARDS_NUMBER, 10) || 4);
+ parseInt(process.env.ES_LOG4JS_SHARDS_NUMBER, 10) || 4);
+ var nbOfReplicas = __getOpt(['settings', 'number_of_replicas'], templateConfig,
+ parseInt(process.env.ES_LOG4JS_REPLICAS_NUMBER, 10) || 1);
var totalShardsPerNode = __getOpt(['settings', 'index.routing.allocation.total_shards_per_node'], templateConfig, 2);
var cacheFieldType = __getOpt(['settings', 'index.cache.field.type'], templateConfig, "soft");
var refreshInterval = __getOpt(['settings', 'index.refresh_interval'], templateConfig, "5s");
@@ -177,6 +179,7 @@ layouts.esTemplateMakers.logstash = function(templateName, templateConfig) {
"template" : templateName || "logstash-*",
"settings" : {
"number_of_shards" : nbOfShards,
+ "number_of_replicas" : nbOfReplicas,
"index.cache.field.type" : cacheFieldType,
"index.refresh_interval" : refreshInterval,
"index.store.compress.stored" : true,
@@ -205,7 +208,8 @@ layouts.esTemplateMakers.simpleJson = function(templateName, templateConfig) {
return {
"template" : templateName || "log4js*",
"settings" : {
- "number_of_shards" : parseInt(process.env.ES_DEFAULT_SHARDS_NUMBER, 10) || 4,
+ "number_of_shards" : parseInt(process.env.ES_LOG4JS_SHARDS_NUMBER, 10) || 4,
+ "number_of_replicas" : parseInt(process.env.ES_LOG4JS_REPLICAS_NUMBER, 10) || 1,
"index.cache.field.type" : "soft",
"index.refresh_interval" : "5s",
"index.store.compress.stored" : true,
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "log4js-elasticsearch",
- "version": "0.0.2",
+ "version": "0.0.4",
"description": "log4js appender for node that targets elasticsearch.\nCompatible with logstash's elasticsearch_http output; Viewable with Kibana.",
"main": "lib/log4js-elasticsearch.js",
"scripts": {
Please sign in to comment.
Something went wrong with that request. Please try again.