Metricbeat working.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
roles:
|
||||
- { role: apache2config }
|
||||
- { role: tomcat8 }
|
||||
- { role: metricbeat }
|
||||
|
||||
|
||||
vars:
|
||||
tmpl:
|
||||
@@ -33,6 +35,10 @@
|
||||
# - webmin.rudolf.com.ua
|
||||
# - bitsync.rudolf.com.ua
|
||||
# - wa.rudolf.com.ua
|
||||
metricbeat_es_user: "metricbeat"
|
||||
metricbeat_es_password: "metricbeat"
|
||||
metricbeat_kibana_index: "metricbeat"
|
||||
elasticsearch_host: "192.168.17.2:9200"
|
||||
|
||||
- hosts: serva4og
|
||||
become: yes
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
---
|
||||
|
||||
metricbeat_user: root
|
||||
metricbeat_group: root
|
||||
|
||||
metricbeat_create_user: true
|
||||
|
||||
# Start metricbeat at boot time
|
||||
#
|
||||
metricbeat_start_at_boot: True
|
||||
|
||||
metricbeat_bin_dir: /usr/share/metricbeat
|
||||
|
||||
metricbeat_config_dir: /etc/metricbeat
|
||||
metricbeat_config_filename: metricbeat.yml
|
||||
metricbeat_config_file: "{{ metricbeat_config_dir }}/{{ metricbeat_config_filename }}"
|
||||
|
||||
# Metricbeat configuration
|
||||
# The configuratlion is built based on a single variable, in YAML format, metricbeat_config.
|
||||
# Just for fun and example, it has been splitted into multiple vars:
|
||||
#
|
||||
# - metricbeat_config_prospectors
|
||||
# - metricbeat_config_output
|
||||
# - metricbeat_config_shipper
|
||||
# - metricbeat_config_logging
|
||||
#
|
||||
|
||||
metricbeat_config_modules: |
|
||||
metricbeat.modules:
|
||||
- module: system
|
||||
metricsets:
|
||||
- cpu
|
||||
#- load
|
||||
#- core
|
||||
- diskio
|
||||
- filesystem
|
||||
#- fsstat
|
||||
- memory
|
||||
- network
|
||||
- process
|
||||
enabled: true
|
||||
period: 10s
|
||||
processes: ['.*']
|
||||
|
||||
- module: mysql
|
||||
metricsets: ["status"]
|
||||
hosts: ["tcp(127.0.0.1:3306)/"]
|
||||
username: elastic
|
||||
password: 2588013SS
|
||||
|
||||
metricbeat_config_processors: |
|
||||
processors:
|
||||
|
||||
metricbeat_config_output: |
|
||||
output.elasticsearch:
|
||||
hosts: [ "{{ elasticsearch_host | default('localhost:9200') }}" ]
|
||||
username: "{{ metricbeat_es_user }}"
|
||||
index: "{{ metricbeat_kibana_index }}"
|
||||
password: "{{ metricbeat_es_password }}"
|
||||
|
||||
metricbeat_config_logging: |
|
||||
logging:
|
||||
level: info
|
||||
to_files: true
|
||||
files:
|
||||
path: /var/log/metricbeat
|
||||
name: metricbeat.log
|
||||
rotateeverybytes: 10485760 # = 10MB
|
||||
keepfiles: 7
|
||||
|
||||
|
||||
metricbeat_config: |
|
||||
{{metricbeat_config_modules}}
|
||||
|
||||
{{metricbeat_config_processors}}
|
||||
|
||||
{{metricbeat_config_output}}
|
||||
|
||||
{{metricbeat_config_logging}}
|
||||
|
||||
# List of template files to copy
|
||||
metricbeat_templates:
|
||||
- metricbeat.template.json
|
||||
- metricbeat.template-es2x.json
|
||||
- metricbeat.template-es6x.json
|
||||
|
||||
metricbeat_install_default_kibana_dashboards: False
|
||||
metricbeat_es_user: "metricbeat"
|
||||
metricbeat_es_password: "secret"
|
||||
metricbeat_kibana_index: ".kibana"
|
||||
metricbeat_es_url: "{{ elasticsearch_proto | default('http') }}://{{ elasticsearch_host | default('localhost:9200') }}"
|
||||
|
||||
# vi:ts=2:sw=2:et:ft=yaml
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- name: metricbeat start
|
||||
service: name=metricbeat state=started
|
||||
become: yes
|
||||
|
||||
- name: metricbeat stop
|
||||
service: name=metricbeat state=stopped
|
||||
become: yes
|
||||
|
||||
- name: metricbeat restart
|
||||
service: name=metricbeat state=restarted
|
||||
become: yes
|
||||
|
||||
- name: systemctl reload
|
||||
shell: systemctl daemon-reload
|
||||
become: yes
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Sirk Johannsen
|
||||
description: Ansible role for MetricBeat
|
||||
license: Apache
|
||||
min_ansible_version: 2.1
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- name: Amazon Linux
|
||||
|
||||
categories:
|
||||
- ELK
|
||||
- beats
|
||||
- monitoring
|
||||
- system
|
||||
|
||||
dependencies: []
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
- name: Create config directory
|
||||
file:
|
||||
path="{{metricbeat_config_dir}}"
|
||||
state=directory
|
||||
owner="{{metricbeat_user}}"
|
||||
group="{{metricbeat_group}}"
|
||||
|
||||
|
||||
- name: Metricbeat configuration file
|
||||
template:
|
||||
src=etc/metricbeat/metricbeat.yml.j2
|
||||
dest="{{metricbeat_config_file}}"
|
||||
owner="{{metricbeat_user}}"
|
||||
group="{{metricbeat_group}}"
|
||||
mode=0640
|
||||
notify: metricbeat restart
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
|
||||
- name: Metricbeat default dashboards for Kibana
|
||||
shell:
|
||||
/usr/share/metricbeat/kibana/import_dashboards.sh
|
||||
-u {{ metricbeat_es_user }}:{{ metricbeat_es_password }}
|
||||
-i {{ metricbeat_kibana_index }}
|
||||
-l {{ metricbeat_es_url }}
|
||||
> dashboard_load.log
|
||||
args:
|
||||
chdir: /usr/share/metricbeat/kibana
|
||||
creates: dashboard_load.log
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
- name: Create bin directory
|
||||
file:
|
||||
path="{{ metricbeat_bin_dir }}"
|
||||
state=directory
|
||||
owner="{{metricbeat_user}}"
|
||||
group="{{metricbeat_group}}"
|
||||
|
||||
|
||||
- name: Metricbeat binary file
|
||||
copy:
|
||||
src: "files/metricbeat.{{ ansible_architecture }}"
|
||||
dest: "{{ metricbeat_bin_dir }}/metricbeat"
|
||||
owner: "{{ metricbeat_user }}"
|
||||
group: "{{ metricbeat_group }}"
|
||||
mode: 0740
|
||||
notify: metricbeat restart
|
||||
tags: [ 'metricbeat', 'metricbeat.install' ]
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
|
||||
- include: install.yml
|
||||
become: true
|
||||
tags: [ 'metricbeat', 'metricbeat.install' ]
|
||||
|
||||
- include: config.yml
|
||||
become: true
|
||||
tags: [ 'metricbeat', 'metricbeat.config' ]
|
||||
|
||||
- include: template.yml
|
||||
become: true
|
||||
tags: [ 'metricbeat', 'metricbeat.template' ]
|
||||
|
||||
- include: dashboards.yml
|
||||
tags: [ 'metricbeat', 'metricbeat.dashboards' ]
|
||||
when: metricbeat_install_default_kibana_dashboards
|
||||
|
||||
- name: Install metricbeat as a systemd service
|
||||
template:
|
||||
src: metricbeat.service.j2
|
||||
dest: /etc/systemd/system/metricbeat.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 400
|
||||
notify: systemctl reload
|
||||
|
||||
- service:
|
||||
name: metricbeat
|
||||
enabled: yes
|
||||
state: started
|
||||
when: metricbeat_start_at_boot
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
- name: Metricbeat template file(s)
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ metricbeat_config_file | dirname }}/{{ item | basename }}"
|
||||
owner: "{{ metricbeat_user }}"
|
||||
group: "{{ metricbeat_group }}"
|
||||
mode: 0640
|
||||
with_items: "{{ metricbeat_templates }}"
|
||||
notify: metricbeat restart
|
||||
@@ -0,0 +1,4 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{{metricbeat_config}}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Metricbeat Service
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ metricbeat_user }}
|
||||
PIDFile=/var/run/metricbeat.pid
|
||||
ExecStart={{ metricbeat_bin_dir }}/metricbeat -c {{ metricbeat_config_file }} -path.home {{ metricbeat_bin_dir }} -path.config {{ metricbeat_config_dir }} -path.data /var/lib/metricbeat -path.logs /var/log/metricbeat
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user