{"id":1986,"date":"2019-01-09T19:36:42","date_gmt":"2019-01-09T16:36:42","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1986"},"modified":"2019-09-17T19:59:09","modified_gmt":"2019-09-17T16:59:09","slug":"install-and-configure-prometheus-on-debian-9","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-prometheus-on-debian-9\/","title":{"rendered":"Install and Configure Prometheus on Debian 9"},"content":{"rendered":"
In this guide, we are going to learn how to install and configure Prometheus on Debian 9. Prometheus is a time series collection and processing\u00a0monitoring platform with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.<\/span><\/p>\n Want to install Prometheus on Ubuntu 18.04? See 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 Assign the ownership of the above directories, user and group, to prometheus.<\/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 Assign the owner and the group of the above directories to prometheus.<\/p>\n Copy the Similarly, set the ownership to prometheus user.<\/p>\n Now that we have all the required configuration files in place, proceed to configure Prometheus. The sample Prometheus configuration file is located under the extracted 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.<\/p>\n Next, open it for modification and adjust it such that it looks like;<\/p>\n Set the ownership of the configuration file to prometheus user.<\/p>\n The basic configuration of Prometheus is now done. To start Prometheus with our basic configuration file,run:<\/p>\n You should able to access the Prometheus status page at To be able to run Prometheus as a service, you need to create a systemd service file,\u00a0 Reload systemd daemon configuration.<\/p>\n Start and Enable Prometheus service to run at boot time.<\/p>\n Check the status<\/p>\n Great, Prometheus is now running as a service.<\/p>\n Upto there, we have learnt a basic of how to install and configure Prometheus on Debian 9. In our next tutorials, we will cover how monitor other target systems so that you can have a real taste of what Prometheus has to offer. Stay connected.<\/p>\n Feel free to explore more about Prometheus here<\/a>.<\/p>\n Check our other guides by following the links below;<\/p>\n Install Graylog 3.0 on CentOS 7<\/a><\/p>\n Monitor Squid Access Logs with Graylog Server<\/a><\/p>\n Monitor Squid logs with Grafana and Graylog<\/a><\/p>\nInstall and Configure Prometheus on Debian 9<\/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
id prometheus\nuid=999(prometheus) gid=999(prometheus) groups=999(prometheus)<\/code><\/pre>\n
Create Configuration Directories<\/h3>\n
mkdir \/etc\/prometheus\nmkdir \/var\/lib\/prometheus<\/code><\/pre>\n
chown prometheus:prometheus \/etc\/prometheus\nchown prometheus:prometheus \/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 and\u00a0promtool<\/code>, under the extracted Prometheus 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
chown prometheus:prometheus \/usr\/local\/bin\/prometheus\nchown prometheus:prometheus \/usr\/local\/bin\/promtool<\/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\/consoles \/etc\/prometheus\/\ncp -r prometheus-2.6.0.linux-amd64\/console_libraries\/ \/etc\/prometheus\/<\/code><\/pre>\n
chown -R prometheus:prometheus \/etc\/prometheus\/consoles\nchown -R prometheus:prometheus \/etc\/prometheus\/console_libraries<\/code><\/pre>\n
Configure Prometheus<\/h3>\n
cp prometheus-2.6.0.linux-amd64\/prometheus.yml \/etc\/prometheus\/<\/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
chown prometheus:prometheus \/etc\/prometheus\/prometheus.yml<\/code><\/pre>\n
Starting Prometheus<\/h3>\n
prometheus --config.file=\/etc\/prometheus\/<\/span>prometheus.yml<\/code><\/pre>\n
http:\/\/localhost:9090<\/code> if you are accessing the server locally or
http:\/\/<server-IP>:9090<\/code> if you are accessing remotely.<\/p>\n
<\/a><\/p>\n
Create Prometheus Systemd Service file<\/h3>\n
\/etc\/systemd\/system\/prometheus.service<\/code>, configured as follows;<\/p>\n
vim \/etc\/systemd\/system\/prometheus.service<\/code><\/pre>\n
[Unit]\nDescription=Prometheus Time Series Collection and Processing Server\nWants=network-online.target\nAfter=network-online.target\n\n[Service]\nUser=prometheus\nGroup=prometheus\nType=simple\nExecStart=\/usr\/local\/bin\/prometheus \\\n --config.file \/etc\/prometheus\/prometheus.yml \\\n --storage.tsdb.path \/var\/lib\/prometheus\/ \\\n --web.console.templates=\/etc\/prometheus\/consoles \\\n --web.console.libraries=\/etc\/prometheus\/console_libraries\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n
systemctl daemon-reload<\/code><\/pre>\n
systemctl start prometheus\nsystemctl enable prometheus<\/code><\/pre>\n
systemctl status prometheus\n\u25cf<\/span> prometheus.service - Prometheus Time Series Collection and Processing Server\n Loaded: loaded (\/etc\/systemd\/system\/prometheus.service; enabled; vendor preset: enabled)\n Active: active (running)<\/span> since Wed 2019-01-09 11:22:52 EST; 1min 1s ago\n Main PID: 1649 (prometheus)\n CGroup: \/system.slice\/prometheus.service\n \u2514\u25001649 \/usr\/local\/bin\/prometheus --config.file \/etc\/prometheus\/prometheus.yml --storage.tsdb.path \/var\/lib\/prometheus\/ --web.console.templates=\/etc\/<\/code><\/pre>\n