Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sdmoko/22445c4c3e92d93d606df573eb5dc6ab to your computer and use it in GitHub Desktop.
Save sdmoko/22445c4c3e92d93d606df573eb5dc6ab to your computer and use it in GitHub Desktop.
Step by step to Monitoring OpenStack Instances with Service Discovery Prometheus and Grafana

Create Instances for Prometheus Server and Grafana

Download Prometheus Server

cd /tmp
wget -c

Extract Prometheus Server

tar zxvf prometheus-2.13.1.linux-amd64.tar.gz

Move to some directory

mv prometheus-2.13.1.linux-amd64 /opt/prometheus-server
cd /opt/prometheus-server

Edit configuration file

vim config.yml
# my global config
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
# Alertmanager configuration
  - static_configs:
    - targets:
      # - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
  # - "first_rules.yml"
  # - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    - targets: ['localhost:9090']
  - job_name: 'openstack-sd'
      - identity_endpoint: https://keystone-url:5000/v3
        username: username
        project_id: projectid
        password: password
        role: instance 
        region: region-name
        domain_name: domain-name
        port: 9100

Configure Systemd Service for Prometheus Service

vim /etc/systemd/system/prometheus-server.service

Description=Prometheus Server
ExecStart=/opt/prometheus-server/prometheus --config.file=/opt/prometheus-server/config.yml --web.external-url=http://ip-server:9090/

Running Service

systemctl daemon-reload
systemctl enable prometheus-server.service
systemctl start prometheus-server.service

Verification Service

systemctl status prometheus-server.service
ss -tulpn |grep 9090

Install Grafana

cd /tmp
wget -c
dpkg -i grafana_6.4.3_amd64.deb

Running Service

systemctl daemon-reload
systemctl start grafana-server
systemctl enable grafana-server


systemctl status grafana-server
ss -tulpn | grep 3000

Configura Datasource and Dashboard on Grafana

  • Login to Grafana
  • Add data source
  • Choose Prometheus
Name: Prometheus
Http settings
URL: http://localhost:9090
  • Save and Test
  • Add Dashboard

Create new instance with node exporter

Install node-exporter on ubuntu instances

cd /tmp/
wget -c
tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz 
mv node_exporter-0.18.1.linux-amd64 /opt/node_exporter

Create systemd service and running node-exporter

cat << EOF >/etc/systemd/system/node_exporter.service
Description=Node Exporter
systemctl daemon-reload
systemctl enable node_exporter.service
systemctl start node_exporter.service
systemctl status node_exporter.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment