# Navigate to a temporary directory
cd /tmp # Download the latest Prometheus release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz prometheus-*.linux-amd64.tar.gz
# Navigate to a temporary directory
cd /tmp # Download the latest Prometheus release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz prometheus-*.linux-amd64.tar.gz
# Navigate to a temporary directory
cd /tmp # Download the latest Prometheus release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz prometheus-*.linux-amd64.tar.gz
# Move the binaries to a system-wide location
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus /usr/local/bin/
-weight: 600;">sudo mv prometheus-*.linux-amd64/promtool /usr/local/bin/ # Create a Prometheus user and group
-weight: 600;">sudo groupadd --system prometheus
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false prometheus # Create directories for Prometheus data and configuration
-weight: 600;">sudo mkdir /etc/prometheus
-weight: 600;">sudo mkdir /var/lib/prometheus # Move configuration files
-weight: 600;">sudo mv prometheus-*.linux-amd64/consoles /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/console_libraries /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus.yml /etc/prometheus/
-weight: 600;">sudo mv prometheus-*.linux-amd64/notifier.yml /etc/prometheus/ # If you have notifier config # Set ownership for Prometheus directories
-weight: 600;">sudo chown -R prometheus:prometheus /etc/prometheus
-weight: 600;">sudo chown -R prometheus:prometheus /var/lib/prometheus
# Move the binaries to a system-wide location
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus /usr/local/bin/
-weight: 600;">sudo mv prometheus-*.linux-amd64/promtool /usr/local/bin/ # Create a Prometheus user and group
-weight: 600;">sudo groupadd --system prometheus
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false prometheus # Create directories for Prometheus data and configuration
-weight: 600;">sudo mkdir /etc/prometheus
-weight: 600;">sudo mkdir /var/lib/prometheus # Move configuration files
-weight: 600;">sudo mv prometheus-*.linux-amd64/consoles /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/console_libraries /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus.yml /etc/prometheus/
-weight: 600;">sudo mv prometheus-*.linux-amd64/notifier.yml /etc/prometheus/ # If you have notifier config # Set ownership for Prometheus directories
-weight: 600;">sudo chown -R prometheus:prometheus /etc/prometheus
-weight: 600;">sudo chown -R prometheus:prometheus /var/lib/prometheus
# Move the binaries to a system-wide location
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus /usr/local/bin/
-weight: 600;">sudo mv prometheus-*.linux-amd64/promtool /usr/local/bin/ # Create a Prometheus user and group
-weight: 600;">sudo groupadd --system prometheus
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false prometheus # Create directories for Prometheus data and configuration
-weight: 600;">sudo mkdir /etc/prometheus
-weight: 600;">sudo mkdir /var/lib/prometheus # Move configuration files
-weight: 600;">sudo mv prometheus-*.linux-amd64/consoles /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/console_libraries /etc/prometheus
-weight: 600;">sudo mv prometheus-*.linux-amd64/prometheus.yml /etc/prometheus/
-weight: 600;">sudo mv prometheus-*.linux-amd64/notifier.yml /etc/prometheus/ # If you have notifier config # Set ownership for Prometheus directories
-weight: 600;">sudo chown -R prometheus:prometheus /etc/prometheus
-weight: 600;">sudo chown -R prometheus:prometheus /var/lib/prometheus
# Global configuration
global: scrape_interval: 15s # How often to scrape targets by default # Alerting rules
# alerting:
# alertmanagers:
# - static_configs:
# - targets: ['localhost:9093'] # Replace with your Alertmanager address if you have one # Load rules once and all a rule files
rule_files: # - "first_rules.yml" # - "second_rules.yml" # Scrape configurations
scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']
# Global configuration
global: scrape_interval: 15s # How often to scrape targets by default # Alerting rules
# alerting:
# alertmanagers:
# - static_configs:
# - targets: ['localhost:9093'] # Replace with your Alertmanager address if you have one # Load rules once and all a rule files
rule_files: # - "first_rules.yml" # - "second_rules.yml" # Scrape configurations
scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']
# Global configuration
global: scrape_interval: 15s # How often to scrape targets by default # Alerting rules
# alerting:
# alertmanagers:
# - static_configs:
# - targets: ['localhost:9093'] # Replace with your Alertmanager address if you have one # Load rules once and all a rule files
rule_files: # - "first_rules.yml" # - "second_rules.yml" # Scrape configurations
scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']
# Navigate to a temporary directory
cd /tmp # Download the latest Node Exporter release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz node_exporter-*.linux-amd64.tar.gz # Move the binary
-weight: 600;">sudo mv node_exporter-*.linux-amd64/node_exporter /usr/local/bin/ # Create a user for Node Exporter
-weight: 600;">sudo groupadd --system node_exporter
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false node_exporter # Clean up
rm -rf node_exporter-*.linux-amd64.tar.gz node_exporter-*.linux-amd64
# Navigate to a temporary directory
cd /tmp # Download the latest Node Exporter release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz node_exporter-*.linux-amd64.tar.gz # Move the binary
-weight: 600;">sudo mv node_exporter-*.linux-amd64/node_exporter /usr/local/bin/ # Create a user for Node Exporter
-weight: 600;">sudo groupadd --system node_exporter
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false node_exporter # Clean up
rm -rf node_exporter-*.linux-amd64.tar.gz node_exporter-*.linux-amd64
# Navigate to a temporary directory
cd /tmp # Download the latest Node Exporter release (replace with the actual latest version)
-weight: 500;">wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz # Extract the downloaded archive
tar xvfz node_exporter-*.linux-amd64.tar.gz # Move the binary
-weight: 600;">sudo mv node_exporter-*.linux-amd64/node_exporter /usr/local/bin/ # Create a user for Node Exporter
-weight: 600;">sudo groupadd --system node_exporter
-weight: 600;">sudo useradd --system --no-create-home --shell /bin/false node_exporter # Clean up
rm -rf node_exporter-*.linux-amd64.tar.gz node_exporter-*.linux-amd64
# Global configuration
global: scrape_interval: 15s scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # Scrape Node Exporter for OS and hardware metrics - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] # Node Exporter's default port
# Global configuration
global: scrape_interval: 15s scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # Scrape Node Exporter for OS and hardware metrics - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] # Node Exporter's default port
# Global configuration
global: scrape_interval: 15s scrape_configs: # Scrape Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # Scrape Node Exporter for OS and hardware metrics - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] # Node Exporter's default port
-weight: 600;">sudo nano /etc/systemd/system/prometheus.-weight: 500;">service
-weight: 600;">sudo nano /etc/systemd/system/prometheus.-weight: 500;">service
-weight: 600;">sudo nano /etc/systemd/system/prometheus.-weight: 500;">service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target [Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \ --config.file /etc/prometheus/prometheus.yml \ --storage.tsdb.path /var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install]
WantedBy=multi-user.target
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target [Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \ --config.file /etc/prometheus/prometheus.yml \ --storage.tsdb.path /var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install]
WantedBy=multi-user.target
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target [Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \ --config.file /etc/prometheus/prometheus.yml \ --storage.tsdb.path /var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install]
WantedBy=multi-user.target
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status prometheus # Check if it's running
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status prometheus # Check if it's running
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start prometheus
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status prometheus # Check if it's running
# Install dependencies
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install -y -weight: 500;">apt-transport-https software-properties-common -weight: 500;">wget # Import GPG key
-weight: 500;">wget -q -O - https://-weight: 500;">apt.grafana.com/gpg.key | -weight: 600;">sudo -weight: 500;">apt-key add - # Add Grafana repository
echo "deb https://-weight: 500;">apt.grafana.com stable main" | -weight: 600;">sudo tee /etc/-weight: 500;">apt/sources.list.d/grafana.list # Install Grafana
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install grafana
# Install dependencies
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install -y -weight: 500;">apt-transport-https software-properties-common -weight: 500;">wget # Import GPG key
-weight: 500;">wget -q -O - https://-weight: 500;">apt.grafana.com/gpg.key | -weight: 600;">sudo -weight: 500;">apt-key add - # Add Grafana repository
echo "deb https://-weight: 500;">apt.grafana.com stable main" | -weight: 600;">sudo tee /etc/-weight: 500;">apt/sources.list.d/grafana.list # Install Grafana
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install grafana
# Install dependencies
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install -y -weight: 500;">apt-transport-https software-properties-common -weight: 500;">wget # Import GPG key
-weight: 500;">wget -q -O - https://-weight: 500;">apt.grafana.com/gpg.key | -weight: 600;">sudo -weight: 500;">apt-key add - # Add Grafana repository
echo "deb https://-weight: 500;">apt.grafana.com stable main" | -weight: 600;">sudo tee /etc/-weight: 500;">apt/sources.list.d/grafana.list # Install Grafana
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt-get -weight: 500;">install grafana
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status grafana-server # Check if it's running
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status grafana-server # Check if it's running
-weight: 600;">sudo -weight: 500;">systemctl daemon-reload
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start grafana-server
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status grafana-server # Check if it's running - Log in to your Grafana instance.
- Click on the gear icon (Configuration) on the left sidebar, then select Data sources.
- Click Add data source.
- Search for and select Prometheus.
- In the URL field, enter http://localhost:9090 (assuming Prometheus is running on the same VPS as Grafana).
- Leave other settings as default for now and click Save & test. You should see a "Data source is working" message. - In Grafana, click the plus icon (Create) on the left sidebar, then select Import.
- In the Import via grafana.com field, enter 1860 (the ID for the Node Exporter Full dashboard) and click Load.
- On the next screen, select your Prometheus data source from the dropdown.
- Click Import. - CPU Usage: High CPU can indicate an overloaded server or inefficient code. Watch for sustained high usage.
- Memory Usage: Running out of RAM leads to swapping (using disk as RAM), which drastically slows down your server. Monitor both used and free memory.
- Disk I/O: Slow disk read/write operations can bottleneck your applications, especially databases.
- Network Traffic: Spikes in incoming or outgoing traffic can signal a DDoS attack or a sudden surge in legitimate user activity.
- Disk Space: Running out of disk space will cause applications to fail. Monitor available disk space.
- Process Counts: An unexpectedly high number of processes can indicate a runaway application or a fork bomb. - Alerting: Prometheus can be configured with alerting rules that trigger notifications when certain conditions are met (e.g., CPU usage over 90% for 5 minutes). This usually involves setting up an Alertmanager.
- Application-Specific Metrics: You can instrument your applications to expose custom metrics to Prometheus, giving you visibility into application-level performance (e.g., request latency, error rates).
- High Availability: For critical systems, you might consider running Prometheus and Grafana in a highly available setup, perhaps using multiple VPS instances. For reliable VPS hosting, providers like PowerVPS and Immers Cloud offer various plans to suit different needs.
- Resource Management: Understanding your server's resource usage helps you choose the right VPS plan. A resource like Server Rental Guide can be helpful when comparing hosting options.