Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 setup grafana node exporter and prometheus #53

Merged
merged 8 commits into from
Dec 23, 2022
Merged
12 changes: 12 additions & 0 deletions Deployment/Ansible/playbooks/files/node-exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Node exporter service
After=network.target

[Service]
ExecStart=/bin/nodeExporter/node_exporter-1.5.0.linux-amd64/node_exporter
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9101:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9102:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9103:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9104:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9105:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client C1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9106:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9111:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9112:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9113:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9114:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9115:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Setup a local tunnel to client D1
After=network.target

[Service]
ExecStart=/usr/bin/ssh -J [email protected]:22022 -i /home/agpbruger/.ssh/id_ecdsa -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -nNTL 9116:127.0.0.1:9100 [email protected] -p 22022
RestartSec=15
Restart=always
KillMode=mixed

[Install]
WantedBy=multi-user.target
53 changes: 53 additions & 0 deletions Deployment/Ansible/playbooks/setupNodeExporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# Find the system architecture: dpkg --print-architecture -> amd64

# Create a folder for node exporter
# mkdir nodeExporter
# cd nodeExporter

# Get the file from the github release page:
# wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz

# Extract the package Tape ARchive file
# tar -xf node_exporter-1.5.0.linux-amd64.tar.gz

# Create the service file

# Start the service




######

# Installs the node exporter, Adds it to systemctl and starts it.

- hosts: all
gather_facts: false
become: true
tasks:

- name: Create a directory if it does not exist
ansible.builtin.file:
path: /bin/nodeExporter
state: directory
mode: '0755'


- name: Extract node exporter
ansible.builtin.unarchive:
src: https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
dest: /bin/nodeExporter/
remote_src: yes

- name: Copy the service file
ansible.builtin.copy:
src: ./node-exporter.service
dest: /etc/systemd/system/node-exporter.service
mode: '0600'

- name: Make sure that the service is started
ansible.builtin.systemd:
name: node-exporter
state: started

89 changes: 89 additions & 0 deletions Deployment/Ansible/playbooks/setupNodeExporterPortForward.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---

# Copies all the ssh forwarding services to the host

# Starts all the services.

- hosts: server-a
gather_facts: false
become: true
tasks:

- name: Copy the service file
ansible.builtin.copy:
src: ./sshPortForwardServices/
dest: /etc/systemd/system/
mode: '0600'

- name: Copy ssh key to root because reason unknown
# No it makes the ssh session able to connect since it is root that does the ssh.
ansible.builtin.copy:
src: ./.ssh/id_ecdsa
dest: /root/.ssh/id_ecdsa
mode: '0600'
remote_src: true

## C Clients

- name: Make sure that the service c1 is started
ansible.builtin.systemd:
name: ssh_forwardingc1
state: started

- name: Make sure that the service c2 is started
ansible.builtin.systemd:
name: ssh_forwardingc2
state: started

- name: Make sure that the service c3 is started
ansible.builtin.systemd:
name: ssh_forwardingc3
state: started

- name: Make sure that the service c4 is started
ansible.builtin.systemd:
name: ssh_forwardingc4
state: started

- name: Make sure that the service c5 is started
ansible.builtin.systemd:
name: ssh_forwardingc5
state: started

- name: Make sure that the service c6 is started
ansible.builtin.systemd:
name: ssh_forwardingc6
state: started

## D Clients

- name: Make sure that the service d1 is started
ansible.builtin.systemd:
name: ssh_forwardingd1
state: started

- name: Make sure that the service d2 is started
ansible.builtin.systemd:
name: ssh_forwardingd2
state: started

- name: Make sure that the service d3 is started
ansible.builtin.systemd:
name: ssh_forwardingd3
state: started

- name: Make sure that the service d4 is started
ansible.builtin.systemd:
name: ssh_forwardingd4
state: started

- name: Make sure that the service d5 is started
ansible.builtin.systemd:
name: ssh_forwardingd5
state: started

- name: Make sure that the service d6 is started
ansible.builtin.systemd:
name: ssh_forwardingd6
state: started

2 changes: 1 addition & 1 deletion Deployment/HostA-Application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DIR=deployment
USER=agpbruger
PORT=22022

FILES=caddy mongo observer webrtc controller docker-compose.yaml
FILES=caddy mongo observer webrtc controller prometheus grafana docker-compose.yaml

all:
@echo "Options include:"
Expand Down
27 changes: 26 additions & 1 deletion Deployment/HostA-Application/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,29 @@ services:
- ./controller/.env
volumes:
- ~/.ssh/:/root/.ssh/
- ./controller/log/:/app/log/
- ./controller/log/:/app/log/

prometheus:
container_name: prometheus
image: prom/prometheus:v2.41.0
hostname: prometheus
network_mode: host
volumes:
- ./prometheus/config:/etc/prometheus
- /media/storage/prometheus:/prometheus
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yaml
user: "0"

grafana:
container_name: grafana
image: grafana/grafana:9.3.2
hostname: grafana
network_mode: host
env_file:
- ./grafana/.env
volumes:
- ./grafana/internal/:/var/lib/grafana/
- ./grafana/provisioning/:/etc/grafana/provisioning/
- ./grafana/dashboards/:/etc/grafana/dashboards/
user: "0"

4 changes: 4 additions & 0 deletions Deployment/HostA-Application/grafana/.envExample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
GF_AUTH_DISABLE_LOGIN_FORM=true
GF_AUTH_ANONYMOUS_ENABLED=true
GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
GF_SERVER_HTTP_PORT=4000
Loading