Monitoring with Syntropy — Grafana, Prometheus and node-exporter approach

Justas Pacekajus
4 min readJan 24, 2021

--

Nowadays Prometheus takes more ground as a primary monitoring solution for infrastructure and Grafana + Prometheus + node_exporter setups are really common. It is relatively easy to implement when your infrastructure is located in a site or two — some standard fiddling with IPsec and firewalls lets you merge those remote networks. However, when you find yourself working with many remote sites and different network implementations, it becomes a burden to manage efficiently. At this point, it makes sense to start working smarter, not harder. One way to do that is Syntropy Stack. It allows you to establish encrypted and fast tunnels between endpoints and centrally manage those connections with ease. Take this scheme as an example:

This tutorial will provide you with Ansible playbooks, Syntropy network template, and some general instructions on setting up this monitoring and network scheme. We’ll implement it in 3 steps:

  1. Prepare the code and variables
  2. Run ansible-playbook
  3. Setup Syntropy Network

You can also watch video to see how it looks in action:

Prerequisites

To successfully follow this tutorial, please note the requirements:

  1. Register for Syntropy account here: https://platform.syntropystack.com
  2. Have your ansible server setup — you need to have ability to execute ansible playbooks against ansible hosts and ansible target user having required privileges to run tasks on target servers. Please note that playbooks are designed for Debian/Ubuntu based Linux distros.
  3. Wireguard kernel module is required if you are running kernel older than 5.6. More details here.

Step1 — code and variables

Without further hesitation go grab yourself those ansible-playbooks for deploying Nginx, Grafana, Prometheus, node-exporter and Syntropy Agent containers:

https://github.com/jpacekajus/syntropy-grafana-prometheus-node-exporter

a) Clone repository:

git clone https://github.com/jpacekajus/syntropy-grafana-prometheus-node-exporter.git

b) Setup ansible inventory file:

cat /etc/ansible/hosts ##can be any inventory file

[exporter_nodes]
exporter1
exporter2
exporterN

[prometheus_nodes]
prometheus1

[web_nodes]
grafana1

c) Update the variables in main.yml — change:

  • cloud provider — check your ID here
  • Grafana domain name
  • email
  • Grafana admin password
  • Syntropy API key
...
- name: Deploy Grafana
become: true
hosts: web_nodes
vars:
subnet: 172.1.0.0/24
prometheus_ip: 172.2.0.2
cloud_provider: '3'
api_key: MyAPIKey
domain: 'grafana.mydomain.com'
email: 'my@email.com'
...

if node-exporter subnet beggining is changed, then change roles/prometheus/templates/prometheus.j2 template accordingly

Step2 — run the playbooks

That’s really simple:

ansible-playbook main.yml

Step3 — set up your Syntropy network

There are multiple ways to interact with Syntropy stack — using web UI, using dedicated ansible playbooks or using command line interface. You can read about all of them in here. In this tutorial I will be focusing on using CLI approach and define networks in YAML files.

a) Install syntropy CLI tools (please note that Python3.6 or above is required):

apt install python3
apt install python3-pip
pip install git+https://github.com/SyntropyNet/syntropy-cli#egg=syntropycli
pip install git+https://github.com/SyntropyNet/syntropy-nac#egg=syntropynac

b) Prepare your environment variables and get API token:

export SYNTROPY_API_SERVER=https://controller-prod-server.syntropystack.comsyntropyctl login your@account.com
Password: **********

After successful authentication, you will receive your API token. You can store it as your environment variable to make things easier for yourself:

export SYNTROPY_API_TOKEN=QWERTYUIOPASLDFDNGGMWJRDNSKFHSKKSNNS

c) Check your newly created endpoints and get your Agent IDs:

syntropyctl get-endpoints
Syntropy endpoint details

d) Update example network YAML with your endpoint Agent IDs and your Network name:

cat networks/grafana-prom-exporter.ymlconnections:
exporter1:
connect_to:
prometheus1:
id: 625
services: [prometheus1]
type: endpoint
id: 624
services: [node_exporter]
state: present
type: endpoint
grafana1:
connect_to:
prometheus1:
id: 625
services: [prometheus1]
type: endpoint
id: 623
services: [grafana]
state: present
type: endpoint
prometheus1:
connect_to:
exporter2:
id: 676
services: [node_exporter]
type: endpoint
id: 625
services: [prometheus1]
state: present
type: endpoint
name: monitoring
state: present
topology: P2P

e) Now as your network-as-a-code file is ready, import it with syntropynac CLI tool:

syntropynac configure-networks networks/grafana-prom-exporter.ymlConfiguring network monitoring 339
Created 3 connections for network monitoring
Configured 3 connections and 8 subnets for network monitoring
Done

f) In case you make changes to your network, you can quickly generate latest file:

syntropynac export-networks

View from web UI

Now you can check or change your newly created network using web UI:

https://platform.syntropystack.com

That’s it!

Now you know how to automatically create and connect your monitoring stack using Syntropy Stack. Feel free to adapt this tutorial for your own requirements if you need to connect remote services and prefer Network as Code implementation. Try connecting an Elasticsearch cluster or even Kubernetes nodes. Of course, you can create even more sophisticated network topologies if needed (e.g. mesh networks). Let me know in the comments what you build and good luck!

--

--

Justas Pacekajus
Justas Pacekajus

No responses yet