Merge lp:~cprov/charms/trusty/logstash/heap_size into lp:~canonical-is-sa/charms/trusty/logstash/logstash2

Proposed by Celso Providelo
Status: Merged
Merged at revision: 62
Proposed branch: lp:~cprov/charms/trusty/logstash/heap_size
Merge into: lp:~canonical-is-sa/charms/trusty/logstash/logstash2
Diff against target: 98 lines (+29/-2)
5 files modified
config.yaml (+5/-0)
files/limits.conf (+3/-0)
files/upstart/logstash-indexer.conf (+2/-1)
hooks/config-changed (+5/-1)
hooks/install (+14/-0)
To merge this branch: bzr merge lp:~cprov/charms/trusty/logstash/heap_size
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Guillermo Gonzalez Pending
Review via email: mp+311671@code.launchpad.net

This proposal supersedes a proposal from 2016-11-23.

Commit message

Allowing changing the logstash maximum heap size as a configuration.

Description of the change

Allowing changing the logstash maximum heap size as a configuration.

Defaults to 1000m instead of the application 500m default value and allow adjustments.

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote : Posted in a previous version of this proposal

Celso,

If this is to apply it to the OLS ELK, it's using a a different charm:

lp:~canonical-is-sa/charms/trusty/logstash/logstash2;revno=61,overwrite=true

the spec in use (for both staging and production) is: is/mojo-is-logging-kibana/ @ lp:canonical-mojo-specs.

review: Needs Information
Revision history for this message
Michael Nelson (michael.nelson) wrote : Posted in a previous version of this proposal
review: Approve
61. By Celso Providelo

Special (no-) limits configuration for logstash, so it can eat as much memory it is configured too.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

+1 from me (see note above about using memlock)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2016-01-22 21:34:37 +0000
3+++ config.yaml 2016-11-23 22:47:42 +0000
4@@ -40,6 +40,11 @@
5 match => { ... }
6 }
7 More info at https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#_custom_patterns
8+ heap_size:
9+ default: "1000m"
10+ type: string
11+ description: |
12+ Maximum Java heap size for the logstash process.
13 nagios_context:
14 default: "juju"
15 type: string
16
17=== added file 'files/limits.conf'
18--- files/limits.conf 1970-01-01 00:00:00 +0000
19+++ files/limits.conf 2016-11-23 22:47:42 +0000
20@@ -0,0 +1,3 @@
21+# Ensure Logstash user can run with max open files and unlimited memlock.
22+{{ USER }} - nofile 65535
23+{{ USER }} - memlock unlimited
24
25=== modified file 'files/upstart/logstash-indexer.conf'
26--- files/upstart/logstash-indexer.conf 2014-09-23 12:11:08 +0000
27+++ files/upstart/logstash-indexer.conf 2016-11-23 22:47:42 +0000
28@@ -11,6 +11,7 @@
29 respawn
30 respawn limit 5 30
31 env HOME={{BASEPATH}}
32+env LS_HEAP_SIZE={{HEAP_SIZE}}
33 chdir {{BASEPATH}}
34 setuid logstash
35 setgid adm
36@@ -18,4 +19,4 @@
37
38 script
39 {{BASEPATH}}/bin/logstash agent -f {{BASEPATH}}/conf.d/
40-end script
41\ No newline at end of file
42+end script
43
44=== modified file 'hooks/config-changed'
45--- hooks/config-changed 2016-01-22 21:34:37 +0000
46+++ hooks/config-changed 2016-11-23 22:47:42 +0000
47@@ -113,7 +113,11 @@
48 def place_upstart_template():
49 out = os.path.join(os.path.sep, 'etc', 'init', '{}.conf'.format(SERVICE))
50 templ = os.path.join('files', 'upstart')
51- opts = {'BASEPATH': BASEPATH}
52+ config_data = hookenv.config()
53+ opts = {
54+ 'BASEPATH': BASEPATH,
55+ 'HEAP_SIZE': config_data['heap_size'],
56+ }
57
58 with open(out, 'w') as p:
59 p.write(render('{}.conf'.format(SERVICE), opts, template_dir=templ))
60
61=== modified file 'hooks/install'
62--- hooks/install 2015-04-17 08:26:14 +0000
63+++ hooks/install 2016-11-23 22:47:42 +0000
64@@ -11,6 +11,7 @@
65
66 sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
67
68+from charmhelpers.contrib.templating.jinja import render
69 from charmhelpers.core.hookenv import (
70 config,
71 log,
72@@ -52,6 +53,9 @@
73 create_skeleton()
74 create_user()
75
76+ # Update logstash user limits, so it can have it all.
77+ update_limits()
78+
79 # finalize the installation and make sure logstash owns everything
80 subprocess.call(['chown', '-R', 'logstash', BASEPATH])
81
82@@ -111,6 +115,16 @@
83 except KeyError:
84 subprocess.call(['useradd', 'logstash'])
85
86+
87+def update_limits():
88+ out = '/etc/security/limits.d/{}.conf'.format(SERVICE)
89+ opts = {
90+ 'USER': 'logstash'
91+ }
92+ with open(out, 'w') as fd:
93+ fd.write(render('limits.conf', opts, template_dir='files'))
94+
95+
96 if __name__ == "__main__":
97 # execute a hook based on the name the program is called by
98 hooks.execute(sys.argv)

Subscribers

People subscribed via source and target branches