Skip to content

OT-OSM/prometheus-exporters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role: Prometheus Exporters

An ansible role which contains multiple exporters of prometheus for scrapping data and for enhancing your monitoring stack. Here are the list of exporters which we are supporting in this role:-

Requirments

For MySQL Exporter, Create a user in mysql with these privileges

CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'password';
GRANT PROCESS, REPLICATION CLIENT,
SELECT ON *.* TO 'exporter'@'localhost' WITH MAX_USER_CONNECTIONS 3;
FLUSH PRIVILEGES;

For MongoDB Exporter, Create a user in mongodb with these privileges

db.createUser( { 
    user: "mongodb_exporter", 
    pwd: "opstree123", roles: 
    [ 
        { role: "clusterMonitor", db: "admin" }, 
        { role: "read", db: "your_database" }
    ] 
  } )

For Nginx Exporter, We have to enable stub_status in nginx configuration. In your Nginx Conf add this line to your location block

location / {
    stub_status on;
}

Role Variables

Mandatory Variables

Needs to be change depending upon environment

Variables Default Values Description
prometheus_mysqld_exporter_env 'user:password@(hostname:port)/' User, password, host and port for mysql-exporter
es_url localhost Server IP of Elasticsearch
mongodb_port 27017 Port on which Mongo_db service is listening
es_port 9200 Port on which elasticsearch is listening
kafka_ip localhost IP of the Kafka Server
kafka_port 9092 Port number on which kafka is running
nginx_ip localhost Server IP of nginx
nginx_port 80 Port number on which nginx is running
solr_ip localhost Server IP of the Solr server
solr_port 8983 Port number on which Solr is listening

Optional Variables

Variables Default Values Description
node_version 0.17.0 Version of Node Exporter
solr_exporter_version 0.3.9 Version of Solr Exporter
apache_exporter 0.5.0 Version of Apache Exporter
es_exporter 1.0.2 Version of Elasticsearch Exporter
mongodb_exporter 1.0.0 Version of MongoDB Exporter
nginx_exporter 0.2.0 Version of Nginx Exporter
kafka_exporter_version 1.2.0 Version of Kafka Exporter
mysql_exporter_version 0.11.0 Version of MySQL Exporter

Dependencies

None :-)

Example Playbook

Here is an example playbook:-

---
- hosts: exporter
  user: ubuntu
  become: yes
  roles:
    - opstree_devops.prometheus-exporters

Usage

For using this role you have to pass one variable to role which is exporter_name

ansible-playbook -i hosts site.yml -e exporter_name="node"

Note: For MongoDB exporter use this configs

For now use latest version to run mongo exporter

ansible-playbook -i hosts site.yml  --extra-vars "@extra_vars.json"

extra_vars.json [ change versions according to you ]

{
	"exporter_name":  "mongodb",
	"mongodb_admin_user": "admin",
        "mongodb_admin_password": "Opstree@123",
        "mongodb_exporter_user_password": "opstree123",
        "mongodb_exporter_dir": "mongodb_exporter-0.32.0.linux-amd64",
	"mongodb_exporter_url": "https://github.com/percona/mongodb_exporter/releases/download/v0.32.0/mongodb_exporter-0.32.0.linux-amd64.tar.gz"

}

Values of exporter_name could be:-

Values Description
node For Node Exporter
mysql For MySQL Exporter
apache For Apache Exporter
mongodb For MongoDB Exporter
nginx For Nginx Exporter
elasticsearch For Elasticsearch Exporter
kafka For Kafka Exporter
solr For Solr Exporter

Authors

Abhishek Dubey

Varghese Kurian