{"id":1992,"date":"2019-01-09T22:59:37","date_gmt":"2019-01-09T19:59:37","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1992"},"modified":"2019-05-29T21:44:59","modified_gmt":"2019-05-29T18:44:59","slug":"install-and-configure-prometheus-on-fedora-29-fedora-28","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-prometheus-on-fedora-29-fedora-28\/","title":{"rendered":"Install and Configure Prometheus on Fedora 29\/Fedora 28"},"content":{"rendered":"
In this guide, we are going to learn how to install and configure Prometheus on Fedora 29\/Fedora 28. As you already know,\u00a0Prometheus is a time series collection and processing server with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.<\/span><\/p>\n Step through this guide in order to install and configure Prometheus on Fedora 29\/Fedora 28.<\/p>\n Install Prometheus on Ubuntu 18.04 by checking the link below;<\/p>\n Install Prometheus on Ubuntu 18.04<\/a><\/p>\n To create To verify this, you can try to print prometheus user and group information using the Since we are installing Prometheus from source, you need to create the respective configuration directories.<\/p>\n In order to install the latest version of Prometheus, navigate to the Download’s Page<\/a> and grab Prometheus binary for your platform. You can simply run the command below to download version 2.6.0 for Linux systems.<\/p>\n Once the download is done, extract the archive.<\/p>\n Copy the two Prometheus binary files,\u00a0 Copy the The sample Prometheus configuration file,\u00a0 Before we proceed, it is good to note that the default port that Prometheus server listens on, Next, open it for modification and adjust it such that it looks like;<\/p>\n If you don’t want to stop the Cockpit service, then you can configure Prometheus server to listen on a different port, say TCP port 8080. Hence adjust your configuration such that it looks like;<\/p>\n Note the targets line above. Prometheus server is set to listen TCP port 8080.<\/p>\n Allow Prometheus through firewall.<\/p>\n If it is set to listen on a different port, say 8080;<\/p>\n Reload firewalld<\/p>\n Run the command below to set the ownership (owner and group) of Prometheus configuration files and directories to prometheus.<\/p>\n To start Prometheus with our basic configuration file,run:<\/p>\nInstall and Configure Prometheus on Fedora\u00a0 29\/Fedora 28<\/h2>\n
Create Prometheus System User and Group<\/h3>\n
prometheus<\/code> system user and group, run the command below;<\/p>\n
useradd -M -r -s \/bin\/false prometheus<\/code><\/pre>\n
id<\/code> command;<\/p>\n
getent passwd prometheus\nprometheus:x:986:985::\/home\/prometheus:\/bin\/false<\/code><\/pre>\n
Create Configuration Directories<\/h3>\n
mkdir \/etc\/prometheus\nmkdir \/var\/lib\/prometheus<\/code><\/pre>\n
Download Prometheus Binary<\/h3>\n
wget https:\/\/github.com\/prometheus\/prometheus\/releases\/download\/v2.6.0\/prometheus-2.6.0.linux-amd64.tar.gz<\/code><\/pre>\n
tar -xzf prometheus-2.6.0.linux-amd64.tar.gz<\/code><\/pre>\n
prometheus<\/code>and
promtool<\/code>, under the extracted Prometheus archive directory to the
\/usr\/local\/bin<\/code> directory.<\/p>\n
cp prometheus-2.6.0.linux-amd64\/prometheus \/usr\/local\/bin\/\ncp prometheus-2.6.0.linux-amd64\/promtool \/usr\/local\/bin\/<\/code><\/pre>\n
consoles\/<\/code> and
console_libraries\/<\/code> directories to
\/etc\/prometheus<\/code> directory created above.<\/p>\n
cp -r prometheus-2.6.0.linux-amd64\/console \/etc\/prometheus\/\ncp -r prometheus-2.6.0.linux-amd64\/console_libraries\/ \/etc\/prometheus\/<\/code><\/pre>\n
Configure Prometheus on Fedara 29\/28<\/h3>\n
prometheus.yml<\/code>, is located under the extracted archive directory. Since we are doing a basic setup, we will copy the configuration file and modify it as follows such that it can scrape the local system only (Prometheus server).<\/p>\n
cp prometheus-2.6.0.linux-amd64\/prometheus.yml \/etc\/prometheus\/<\/code><\/pre>\n
TCP port 9090<\/code>, is the same port the Fedora Cockpit socket listening on. As a result, if you are not using the Cockpit Web service Manager, disable and stop both the service and socket to free port 9090.<\/p>\n
systemctl mask cockpit cockpit.socket\nsystemctl stop cockpit cockpit.socket<\/code><\/pre>\n
vim \/etc\/prometheus\/prometheus.yml<\/code><\/pre>\n
# my global config\nglobal:\n scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n # scrape_timeout is set to the global default (10s).\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.\n - job_name: 'prometheus'\n\n # metrics_path defaults to '\/metrics'\n # scheme defaults to 'http'.\n\n static_configs:\n - targets: ['localhost:9090']<\/code><\/pre>\n
# my global config\nglobal:\n scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n # scrape_timeout is set to the global default (10s).\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.\n - job_name: 'prometheus'\n\n # metrics_path defaults to '\/metrics'\n # scheme defaults to 'http'.\n\n static_configs:\n - targets: ['localhost:8080']<\/strong><\/code><\/pre>\n
firewall-cmd --add-port=9090\/tcp --permanent<\/code><\/pre>\n
firewall-cmd --add-port=8080\/tcp --permanent<\/code><\/pre>\n
firewall-cmd --reload<\/code><\/pre>\n
Set Proper Ownership on Configuration Files and Directories<\/h3>\n
chown -R prometheus:prometheus \/etc\/prometheus\nchown -R prometheus:prometheus \/var\/lib\/prometheus\nchown prometheus.prometheus \/usr\/local\/bin\/prometheus\nchown prometheus.prometheus \/usr\/local\/bin\/promtool<\/code><\/pre>\n
Starting Prometheus<\/h3>\n
prometheus --config.file=\/etc\/prometheus\/<\/span>prometheus.yml<\/code><\/pre>\n