Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Collecting Linux Server Metrics with Prometheus

Prometheus uses a pull model to periodically scrape metric data from targets. In order to collect data, you will need to set up an entity that is able to provide metric data, and then configure the Prometheus server to scrape it. In this lab, you will walk through the process of configuring Prometheus monitoring for a Linux server.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Jun 12, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Install and Configure Node Exporter on the LimeDrop Web Server

    1. Log in to the LimeDrop web server to perform the following steps.

    2. Create a user and group that will be used to run Node Exporter:

      sudo useradd -M -r -s /bin/false node_exporter
      
    3. Download and extract the Node Exporter binary:

      wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
      
      tar xvfz node_exporter-0.18.1.linux-amd64.tar.gz
      
    4. Copy the Node Exporter binary to the appropriate location and set ownership:

      sudo cp node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/
      
      sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
      
    5. Create a systemd unit file for Node Exporter:

      sudo vi /etc/systemd/system/node_exporter.service
      
    6. Define the Node Exporter service in the unit file:

      [Unit]
      Description=Prometheus Node Exporter
      Wants=network-online.target
      After=network-online.target
      
      [Service]
      User=node_exporter
      Group=node_exporter
      Type=simple
      ExecStart=/usr/local/bin/node_exporter
      
      [Install]
      WantedBy=multi-user.target
      
    7. Start and enable the service:

      sudo systemctl daemon-reload
      
      sudo systemctl start node_exporter
      
      sudo systemctl enable node_exporter
      
    8. Test that your Node Exporter is working by making a request to it from localhost. You should get some metric data on the screen in response to this request:

      curl localhost:9100/metrics
      
  2. Challenge

    Configure Prometheus to Scrape Metrics from the LimeDrop Web Server

    1. Log in to the Prometheus server to perform the following steps.

    2. Edit the Prometheus config file:

      sudo vi /etc/prometheus/prometheus.yml
      
    3. Locate the scrape_configs section and add a new entry under that section:

      ...
      
        - job_name: 'LimeDrop Web Server'
          static_configs:
          - targets: ['10.0.1.102:9100']
      
      ...
      
    4. Restart Prometheus to load the new config:

      sudo systemctl restart prometheus
      
    5. Navigate to the Prometheus expression browser in your web browser using the public IP address of your Prometheus server: <PROMETHEUS_SERVER_PUBLIC_IP>:9090.

    6. Run the following query to verify you are able to get some metric data from the LimeDrop web server:

      node_filesystem_avail_bytes{job="LimeDrop Web Server"}
      

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans