export version
export platform
# Download the Node Exporter binary (adjust the version as necessary)
wget https://github.com/prometheus/node_exporter/releases/download/v${version}/node_exporter-${version}.${platform}-arm64.tar.gz
# Extract the binary
tar -xzf node_exporter-${version}.${platform}-arm64.tar.gz
# Move the binary to a suitable location (e.g., /usr/local/bin)
sudo mv node_exporter-${version}.${platform}-arm64/node_exporter /usr/local/bin/
# Optionally, create a system service file (e.g., for systemd)
sudo nano /etc/systemd/system/node_exporter.service
cat <<EOF > ${PWD}/node_exporter/node_exporter.service
[Unit]
Description=Prometheus Node Exporter
After=network.target
[Service]
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=default.target
EOF
sudo cp -rf ${PWD}/node_exporter/node_exporter.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable node_exporter
echo "node exporter enable"
sudo systemctl start node_exporter
echo "node_exporter has started."
sudo systemctl status node_exporter
sudo systemctl restart node_exporter
export version
curl -LO https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-${version}.linux-amd64.tar.gz
tar -xzf prometheus-${version}.linux-amd64.tar.gz
mkdir -p ${PWD}/prometheus
cp -r prometheus-${version}.linux-amd64/prometheus ${PWD}/prometheus
cp -r prometheus-${version}.linux-amd64/promtool ${PWD}/prometheus
cat <<EOF > ${PWD}/prometheus/prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'node_'
metrics_path: /metrics
static_configs:
- targets:
- 10.90.2.1:9116
EOF
cat <<EOF > ${PWD}/prometheus/prometheus.service
[Unit]
Description=Prometheus Agent Mode
After=network-online.target
[Service]
User=${USER}
WorkingDirectory=${PWD}
ExecStart=${PWD}/prometheus/prometheus --config.file=${PWD}/prometheus/prometheus.yml --enable-feature=agent
[Install]
WantedBy=multi-user.target
EOF
sudo cp -rf ${PWD}/prometheus/prometheus.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable prometheus
echo "prometheus enable"
sudo systemctl start prometheus
echo "prometheus has started."
sudo systemctl status prometheus
sudo systemctl restart prometheus
open http://localhost:9090
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_9.4.7_amd64.deb
sudo dpkg -i grafana-enterprise_9.4.7_amd64.deb
sudo apt-get install grafana
systemctl enable --now grafana-server
systemctl restart grafana-server
open http://localhost:3000
curl -LO https://github.com/prometheus/alertmanager/releases/download/v0.27.0/alertmanager-0.27.0.linux-amd64.tar.gz
# Extract the binary
tar -xzf alertmanager-${version}.${platform}-amd64.tar.gz
# Move the binary to a suitable location (e.g., /usr/local/bin)
sudo mv alertmanager-${version}.${platform}-amd64/alertmanager /usr/local/bin/
# Move the binary to a suitable location (e.g., /etc)
cp alertmanager-<version>.${platform}-amd64/alertmanager.yml /etc/alertmanager/
alertmanager --config.file=/etc/alertmanager/alertmanager.yml
Edit the alertmanager.yml
file to define your alerting configurations, notification integrations, and routing rules.
nano /etc/alertmanager/alertmanager.yml
cat <<EOF > ${PWD}/alertmanager/alertmanager.service
[Unit]
Description=Alertmanager
Wants=network-online.target
After=network-online.target
[Service]
User=alertmanager
Group=alertmanager
Type=simple
ExecStart=/usr/local/bin/alertmanager --config.file=/etc/alertmanager/alertmanager.yml
[Install]
WantedBy=multi-user.target
EOF
sudo cp -rf ${PWD}/alertmanager/alertmanager.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start alertmanager
echo "alertmanager has started."
sudo systemctl enable alertmanager
echo "alertmanager enable"
sudo systemctl status alertmanager
sudo systemctl restart alertmanager
open http://localhost:9093