forked from Ashfaque-9x/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall-Prometheus-Grafana-Monitor-Windows-Server-Using-PrometheusGrafana.txt
93 lines (77 loc) · 4 KB
/
Install-Prometheus-Grafana-Monitor-Windows-Server-Using-PrometheusGrafana.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
===============================================================================================================================================================
A ] Install Prometheus
Prometheus Download Page --- https://prometheus.io/download/
sudo apt-get update
sudo useradd --system --no-create-home --shell /bin/false prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.51.2/prometheus-2.51.2.linux-amd64.tar.gz
tar -xvf prometheus-2.51.2.linux-amd64.tar.gz
cd prometheus-2.51.2.linux-amd64/
sudo mkdir -p /data /etc/prometheus ////Create a data folder at the root directory, with a prometheus folder inside.
sudo mv prometheus promtool /usr/local/bin/
sudo mv consoles/ console_libraries/ /etc/prometheus/
sudo mv prometheus.yml /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /etc/prometheus/ /data/
===============================================================================================================================================================
B ] Configuring Prometheus as a service
cd /etc/systemd/system/
sudo touch prometheus.service
sudo nano prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/data \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.enable-lifecycle
[Install]
WantedBy=multi-user.target
===============================================================================================================================================================
C ]
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
http://192.168.0.148:9090/
===============================================================================================================================================================
D ] Install Grafana
sudo apt-get install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get -y install grafana
===============================================================================================================================================================
E ]
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-server
http://192.168.0.148:3000
===============================================================================================================================================================
F ] Install windows_exporterin Window Server
1 -- Download msi file from https://github.com/prometheus-community/windows_exporter/releases
2 -- Install msi file and check windows_exporter service under services.msc
3 -- Now yur exporter is running and it should start exposing metrics on http://localhost:9182/metrics
===============================================================================================================================================================
G ] Binding Prometheus to the Windows exporter
1 -- Add below 2 lines below - job_name: in prometheus.yml file
scrape_interval: 6s
scrape_timeout: 5s
2 -- Add Windows server under targets in yaml file
- targets: ["localhost:9090", "192.168.0.149:9182"]
3--Check the indentation of the prometheus config file with below command
$ promtool check config /etc/prometheus/prometheus.yml
4 -- Restart service
sudo systemctl restart prometheus
===============================================================================================================================================================
H ] Import Grafana Dashboard
Dashboard ID -- 14694