Skip to content

Commit

Permalink
config: Removed index settings from config
Browse files Browse the repository at this point in the history
These should be set by the cluster in a template or its root config, and aren't
really anything to do with Lumberjack.

- Updated docs and tests

Signed-off-by: Joe MacMahon <joe.macmahon@cern.ch>
  • Loading branch information
Joe MacMahon committed Dec 5, 2014
1 parent 307eb61 commit 5b46322
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
7 changes: 0 additions & 7 deletions docs/configuration.rst
Expand Up @@ -55,13 +55,6 @@ Lumberjack disables analysis on them. (The reason for this is that while
analysis is a powerful Elasticsearch feature when dealing with natural language
documents, for log data it makes little sense.)

Default index settings
----------------------

This contains settings to be added to new templates regarding the creation of
indices, for example the ``number_of_shards`` and ``number_of_replicas``
options.

The interval
------------

Expand Down
4 changes: 0 additions & 4 deletions lumberjack/config.py
Expand Up @@ -47,10 +47,6 @@
'format': 'dateOptionalTime'
}
},
'default_index_settings': {
'number_of_shards': 6,
'number_of_replicas': 1
},
'index_prefix': 'generic-logging-',
'interval': 30,
'max_queue_length': None
Expand Down
3 changes: 1 addition & 2 deletions lumberjack/schemas.py
Expand Up @@ -75,12 +75,11 @@ def _update_index_templates(self):
mappings = self._build_mappings()
template = {
'template': self.config['index_prefix'] + '*',
'settings': self.config['default_index_settings'],
'mappings': mappings
}
logging.getLogger(__name__).debug('Registering a new template.')
self.elasticsearch.indices.put_template(
name=self.config['index_prefix'] + '*',
name='lumberjack-' + self.config['index_prefix'] + '*',
body=template
)
# Try to update existing things.
Expand Down
19 changes: 8 additions & 11 deletions tests/schema.py
Expand Up @@ -149,11 +149,7 @@ def test_build_mappings_non_default(self):
'index': 'analyzed',
}
}
self.config['default_index_settings'] = {
'number_of_shards': 3,
'number_of_replicas': 2
}


expected_mapping = {
'dynamic': 'strict',
'_source': {'enabled': False},
Expand Down Expand Up @@ -185,11 +181,11 @@ def test_register_schema(self):

if MOCK:
def mock_put_template_f(name, body):
self.assertEqual(name, self.config['index_prefix'] + '*')
self.assertEqual(
name,
'lumberjack-' + self.config['index_prefix'] + '*')
self.assertEqual(body['template'],
self.config['index_prefix'] + '*')
self.assertEqual(body['settings'],
self.config['default_index_settings'])
self.assertEqual(body['mappings'],
self.lj.schema_manager._build_mappings())

Expand All @@ -206,9 +202,10 @@ def mock_put_mapping_f(index, body, doc_type):
# Test it's now in ES, unles we're in mock.
if not MOCK:
res = self.elasticsearch.indices.get_template(
name=self.config['index_prefix'] + '*')
name='lumberjack-' + self.config['index_prefix'] + '*')

expected_schema = self.lj.schema_manager._build_mappings()['type_a']

self.assertEqual(res[self.config['index_prefix'] + '*'] \
['mappings']['type_a'], expected_schema)
self.assertEqual(
res['lumberjack-' + self.config['index_prefix'] +'*']
['mappings']['type_a'], expected_schema)

0 comments on commit 5b46322

Please sign in to comment.