Skip to content

Commit

Permalink
fixed play
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jan 24, 2024
1 parent 13120e8 commit f22fe58
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 1 deletion.
81 changes: 81 additions & 0 deletions plays/metricbeat/metricbeat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common
# options. The metricbeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/metricbeat/index.html

#========================== Modules configuration ============================

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml

# Set to true to enable config reloading
reload.enabled: false

# Period on which files under path should be checked for changes
#reload.period: 10s

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["https://cloud.denbi.de:443"]
allow_older_versions: true


# Optional protocol and basic auth credentials.
protocol: https
path: /elasticsearch/
headers:
HOST: 'cloud.denbi.de'
username: ${METRICBEAT_USER}
password: ${METRICBEAT_PASSWORD}


#================================= Migration ==================================

# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true

metricbeat.modules:
- module: docker
metricsets:
- "container"
- "cpu"
- "diskio"
- "event"
- "healthcheck"
- "info"
- "memory"
- "network"
hosts: ["unix:///var/run/docker.sock"]
period: 45s
enabled: true
- module: system
metricsets:
- cpu # CPU usage
- load # CPU load averages
- memory # Memory usage
- network # Network IO
- process # Per process metrics
- process_summary # Process summary
- uptime # System Uptime
- socket_summary # Socket summary
- core # Per CPU core usage
- diskio # Disk IO
- filesystem # File system usage for each mountpoint
- fsstat # File system summary metrics
enabled: true
period: 60s
processes: ['.*']

# Configure the metric types that are included by these metricsets.
cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks.
core.metrics: ["percentages"] # The other available option is ticks.
4 changes: 4 additions & 0 deletions plays/metricbeat/restart-on-failure.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Restart=on-failure
RestartSec=20
StartLimitIntervalSec=0
46 changes: 46 additions & 0 deletions plays/metricbeat/setup_metricbeat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- name: Setup metricbeat
hosts: all
become: yes
vars_files:
- setup_metricbeat_variables.yml
- ../general_variables.yml

tasks:

- name: Download and install metricbeat.deb
apt:
deb: "{{ metricbeat.DOWNLOAD_URL }}"
tags: [ 'metricbeat' ]

- name: Copy metricbeat config file
copy:
src: "{{ general.REPO_PATH }}plays/metricbeat/metricbeat.yml"
dest: "{{ metricbeat.CONFIG_FILE_PATH }}/metricbeat.yml"
remote_src: True
tags: [ 'production', 'dev', 'post-release', 'never' ]

- name: Create metricbeat dropin dir
file:
state: directory
path: "{{ metricbeat.OVERRIDE_CONFIG_PATH }}"
recurse: yes
tags: [ 'metricbeat' ]

- name: Copy metricbeat override config file
copy:
src: "{{ general.REPO_PATH }}plays/metricbeat/restart-on-failure.conf"
dest: "{{ metricbeat.OVERRIDE_CONFIG_PATH }}/restart-on-failure.conf"
remote_src: True
tags: [ 'metricbeat' ]

- name: Just force systemd to reread configs (2.4 and above)
ansible.builtin.systemd:
daemon_reload: yes
tags: [ 'metricbeat' ]


- name: Start Metricbeat service
service:
name: metricbeat
state: restarted
tags: [ 'metricbeat' ]
4 changes: 4 additions & 0 deletions plays/metricbeat/setup_metricbeat_variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
metricbeat:
DOWNLOAD_URL: "https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-8.12.0-amd64.deb"
CONFIG_FILE_PATH: /etc/metricbeat
OVERRIDE_CONFIG_PATH: /etc/systemd/system/metricbeat.service.d
2 changes: 1 addition & 1 deletion plays/setup_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

- name: Check if ca pem file exists already
stat:
path: "{{ client.PERSISTENT_PATH }}/ca.pem"
path: "{{ client.PERSISTENT_PATH }}/CA.pem"
register: stat_ca_pem
tags: always

Expand Down

0 comments on commit f22fe58

Please sign in to comment.