Skip to content

Commit

Permalink
Added logzio scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-szabo authored and cwgoes committed May 25, 2018
1 parent 02bf73b commit 3b9dadd
Show file tree
Hide file tree
Showing 6 changed files with 420 additions and 0 deletions.
14 changes: 14 additions & 0 deletions networks/remote/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,17 @@ Delete servers

make remotenet-stop

Logging
-------

You can ship logs to Logz.io, an Elastic stack (Elastic search, Logstash and Kibana) service provider. You can set up your nodes to log there automatically. Create an account and get your API key from the notes on `this page <https://app.logz.io/#/dashboard/data-sources/Filebeat>`__, then:

::

yum install systemd-devel || echo "This will only work on RHEL-based systems."
apt-get install libsystemd-dev || echo "This will only work on Debian-based systems."

go get github.com/mheese/journalbeat
ansible-playbook -i inventory/digital_ocean.py -l remotenet logzio.yml -e LOGZIO_TOKEN=ABCDEFGHIJKLMNOPQRSTUVWXYZ012345


14 changes: 14 additions & 0 deletions networks/remote/ansible/logzio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

#Note: You need to add LOGZIO_TOKEN variable with your API key. Like this: ansible-playbook -e LOGZIO_TOKEN=ABCXYZ123456

- hosts: all
user: root
any_errors_fatal: true
gather_facts: no
vars:
- service: gaiad
- JOURNALBEAT_BINARY: "{{lookup('env', 'GOPATH')}}/bin/journalbeat"
roles:
- logzio

15 changes: 15 additions & 0 deletions networks/remote/ansible/roles/logzio/files/journalbeat.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=journalbeat
#propagates activation, deactivation and activation fails.
Requires=network-online.target
After=network-online.target

[Service]
Restart=on-failure
ExecStart=/usr/bin/journalbeat -c /etc/journalbeat/journalbeat.yml -path.home /usr/share/journalbeat -path.config /etc/journalbeat -path.data /var/lib/journalbeat -path.logs /var/log/journalbeat
Restart=always

[Install]
WantedBy=multi-user.target


8 changes: 8 additions & 0 deletions networks/remote/ansible/roles/logzio/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

- name: reload daemon
command: "systemctl daemon-reload"

- name: restart journalbeat
service: name=journalbeat state=restarted

27 changes: 27 additions & 0 deletions networks/remote/ansible/roles/logzio/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: Copy journalbeat binary
copy: src="{{JOURNALBEAT_BINARY}}" dest=/usr/bin/journalbeat mode=0755
notify: restart journalbeat

- name: Create folders
file: "path={{item}} state=directory recurse=yes"
with_items:
- /etc/journalbeat
- /etc/pki/tls/certs
- /usr/share/journalbeat
- /var/log/journalbeat

- name: Copy journalbeat config
template: src=journalbeat.yml.j2 dest=/etc/journalbeat/journalbeat.yml mode=0600
notify: restart journalbeat

- name: Get server certificate for Logz.io
get_url: "url=https://raw.githubusercontent.com/logzio/public-certificates/master/COMODORSADomainValidationSecureServerCA.crt force=yes dest=/etc/pki/tls/certs/COMODORSADomainValidationSecureServerCA.crt"

- name: Copy journalbeat service config
copy: src=journalbeat.service dest=/etc/systemd/system/journalbeat.service
notify:
- reload daemon
- restart journalbeat

Loading

0 comments on commit 3b9dadd

Please sign in to comment.