Skip to content

Commit

Permalink
Add the ability to set the JVM heap size
Browse files Browse the repository at this point in the history
This change makes it possible for users to set the `elastic_heap_size_default`
value. Before this change, the option was unreachable due to a series of facts
ganerated template values. The options `elastic_heap_size` or `logstash_heap_size`
have also been exposed giving deployers the ability to define service specific
heap sizes as needed.

Change-Id: Ida3a57fdcff388f8e4bb3f325b787205a6183970
Signed-off-by: Kevin Carter <kevin@cloudnull.com>
  • Loading branch information
cloudnull committed Jan 30, 2019
1 parent 78221b1 commit 6017fc0
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 8 deletions.
5 changes: 5 additions & 0 deletions elk_metrics_6x/roles/elastic_dependencies/defaults/main.yml
Expand Up @@ -42,3 +42,8 @@ elastic_lxc_template_config:
2:
aa_profile: lxc.aa_profile
mount: lxc.mount.entry

# Set the elastic search heap size. If this option is undefined the value will
# be derived automatically using 1/4 of the available RAM for logstash and 1/2
# of the available RAM for elasticsearch. The value is expected to be in MiB.
# elastic_heap_size_default: 10240 # type `int`
3 changes: 1 addition & 2 deletions elk_metrics_6x/roles/elastic_dependencies/tasks/main.yml
Expand Up @@ -49,9 +49,8 @@
tags:
- always

- name: Set elastic heap defaults
- name: Set elastic log rotate path
set_fact:
elastic_heap_size_default: "{{ _elastic_heap_size_default }}"
elastic_log_rotate_path: "/var/log/{{ service_name }}"

- name: Configure systcl vm.max_map_count=524288 on elastic hosts
Expand Down
5 changes: 5 additions & 0 deletions elk_metrics_6x/roles/elastic_logstash/defaults/main.yml
Expand Up @@ -86,3 +86,8 @@ logstash_arcsight_event_brokers: []
## detect the media type where the queue will exist. If the media type is
## "rotational" in memory queues will be used.
# logstash_queue_type:

# Set the logstash search heap size. If this option is undefined the value will
# be derived automatically using 1/4 of the available RAM for logstash and 1/2
# of the available RAM for elasticsearch. The value is expected to be in MiB.
# logstash_heap_size: 10240 # type `int`
6 changes: 6 additions & 0 deletions elk_metrics_6x/roles/elastic_logstash/tasks/main.yml
Expand Up @@ -71,6 +71,12 @@
- key: LS_OPEN_FILES
value: 32768

- name: Set service specific haap size
set_fact:
_service_heap_size: "{{ logstash_heap_size }}"
when:
- logstash_heap_size is defined

- name: Drop jvm conf file(s)
template:
src: "{{ item.src }}"
Expand Down
5 changes: 5 additions & 0 deletions elk_metrics_6x/roles/elasticsearch/defaults/main.yml
Expand Up @@ -28,3 +28,8 @@ elastic_plugins:
- ingest-attachment
- ingest-geoip
- ingest-user-agent

# Set the logstash search heap size. If this option is undefined the value will
# be derived automatically using 1/4 of the available RAM for logstash and 1/2
# of the available RAM for elasticsearch. The value is expected to be in MiB.
# elastic_heap_size: 10240 # type `int`
6 changes: 6 additions & 0 deletions elk_metrics_6x/roles/elasticsearch/tasks/main.yml
Expand Up @@ -81,6 +81,12 @@
- key: MAX_MAP_COUNT
value: 524288

- name: Set service specific haap size
set_fact:
_service_heap_size: "{{ elastic_heap_size }}"
when:
- elastic_heap_size is defined

- name: Drop jvm conf file(s)
template:
src: "{{ item.src }}"
Expand Down
3 changes: 1 addition & 2 deletions elk_metrics_6x/roles/elasticsearch/vars/vars_default.yml
Expand Up @@ -13,5 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Set elasticsearch facts
elastic_heap_size: "{{ elastic_heap_size_default }}"
place_holder: true
1 change: 0 additions & 1 deletion elk_metrics_6x/roles/elasticsearch/vars/vars_kibana.yml
Expand Up @@ -18,7 +18,6 @@ elasticsearch_node_master: false
elasticsearch_node_data: false
elasticsearch_node_ingest: false
elastic_coordination_node: true
elastic_heap_size: "{{ (elastic_heap_size_default | int) // 3 }}"

# This variable is redefined because kibana runs elasticsearch but only in a
# load balancer capacity.
Expand Down
10 changes: 7 additions & 3 deletions elk_metrics_6x/templates/jvm.options.j2
@@ -1,8 +1,12 @@
## JVM configuration
{% if (not (elasticsearch_node_master | default(master_node)) | bool) and (not (elasticsearch_node_data | default(data_node)) | bool) %}
{% set heap_size = (elastic_heap_size_default | int) // 2 %}
{% if _service_heap_size is defined %}
{% set heap_size = _service_heap_size %}
{% else %}
{% set heap_size = (elastic_heap_size_default | int) %}
{% if (not (elasticsearch_node_master | default(master_node)) | bool) and (not (elasticsearch_node_data | default(data_node)) | bool) %}
{% set heap_size = elastic_heap_size_default | default((_elastic_heap_size_default | int) // 2) %}
{% else %}
{% set heap_size = elastic_heap_size_default | default(_elastic_heap_size_default | int) %}
{% endif %}
{% endif %}
# Xms represents the initial size of total heap space
-Xms{{ heap_size }}m
Expand Down

0 comments on commit 6017fc0

Please sign in to comment.