Quickstart for Sensu Go 6¶
Before we can do anything, we need to install Sensu Go Ansible Collection. Luckily, we are just one short command away from that goal:
$ ansible-galaxy collection install sensu.sensu_go
Now we can set up a simple Sensu Go sandbox using the following
playbook
:
---
- name: Install, configure and run Sensu backend
hosts: backends
become: true
tasks:
- name: Install backend
include_role:
name: sensu.sensu_go.backend
vars:
version: 6.0.0
- name: Install, configure and run Sensu agents
hosts: agents
become: true
tasks:
- name: Install agent
include_role:
name: sensu.sensu_go.agent
vars:
version: 6.0.0
agent_config:
name: my-agent
keepalive-interval: 5
keepalive-timeout: 10
- name: Configure your first monitor
hosts: localhost
tasks:
- name: Add subscriptions to agent entity
sensu.sensu_go.entity:
auth: &auth
url: http://{{ groups['backends'][0] }}:8080
name: my-agent
entity_class: agent
deregister: true
subscriptions:
- linux
- name: Create sensu asset
sensu.sensu_go.bonsai_asset:
auth: *auth
name: sensu/monitoring-plugins
version: 2.2.0-1
- name: Create sensu ntp check
sensu.sensu_go.check:
auth: *auth
name: ntp
runtime_assets: sensu/monitoring-plugins
command: check_ntp_time -H time.nist.gov --warn 0.5 --critical 1.0
output_metric_format: nagios_perfdata
publish: true
interval: 30
timeout: 10
subscriptions:
- linux
When we run it, Ansible will install and configure backend and agents on selected hosts, and then configure a ntp check that agents will execute twice a minute. Note that we do not need to inform agents explicitly where the backend is because the agent role can obtain the backend’s address from the inventory.
Now, before we can run this playbook, we need to prepare an inventory file.
The inventory should contain two groups of hosts: backends and agents. A
minimal inventory
with
only two hosts will look somewhat like this:
all:
children:
backends:
hosts:
192.168.50.4:
agents:
hosts:
192.168.50.5:
Replace the IP addresses with your own and make sure you can ssh into those hosts. If you need help with building your inventory file, consult official documentation on inventory.
All that we need to do now is to run the playbook:
$ ansible-playbook -i inventory.yaml playbook-6.yaml
And in a few minutes, things should be ready to go. And if we now visit http://192.168.50.4:3000 (replace that IP address with the address of your backend), we can log in and start exploring.