A word from our sponsors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sw:prometheus:intro [2022/01/11 08:17] Frank Fegertsw:prometheus:intro [2022/01/11 11:20] (current) Frank Fegert
Line 27: Line 27:
  
 ====== Files and Directories ====== ====== Files and Directories ======
- 
-FIXME 
  
 ===== General Files and Directories ===== ===== General Files and Directories =====
  
-FIXME+^ File or Directory                                 ^ Description                                                                            ^ 
 +| ''/etc/prometheus/''                                                 | The //Prometheus// configuration directory.                     | 
 +| ''/usr/bin/prometheus''                                           | The //Prometheus// server binary.                                     | 
 +| ''/usr/bin/promtool''                                                | The ''promtool'' CLI binary.                                         | 
 +| ''/usr/lib/systemd/system/prometheus.service''   | The //Prometheus// systemd unit file.                                | 
 +| ''/srv/prometheus/''                                                 | The //Prometheus// server data directory.                         |
  
 ===== Configuration Files ===== ===== Configuration Files =====
  
-FIXME+^ File or Directory                          ^ Description                                                                           ^ 
 +| ''/etc/default/prometheus''                           | The configuration file with environment variables for the //Prometheus// server.                 | 
 +| ''/etc/prometheus/prometheus.yml''            | The //Prometheus// server configuration file.                 |
  
 ====== Getting Help ====== ====== Getting Help ======
  
-FIXME+//Prometheus// Manual pages: 
  
-Manual pages: +<cli> 
 +user@host:~$ man prometheus 
 +</cli> 
 + 
 +''promtool'' Manual pages: 
  
 <cli> <cli>
-user@host:~$ +user@host:~$ man promtool
 </cli> </cli>
  
 ====== Install ====== ====== Install ======
- 
-FIXME 
  
 To install //Prometheus// on Debian:  To install //Prometheus// on Debian: 
Line 57: Line 64:
 root@host:~$ apt-get update root@host:~$ apt-get update
 root@host:~$ apt-get install prometheus root@host:~$ apt-get install prometheus
-</cli> +</cli> 
 + 
 +Create the //Prometheus// ''rsyslog'' configuration files: 
 + 
 +<cli> 
 +root@host:~$ vi /etc/rsyslog.d/prometheus.conf 
 +</cli> 
 + 
 +File contents: 
 + 
 +<file config /etc/rsyslog.d/prometheus.conf> 
 +template(name="PROMETHEUS_TEMPLATE" type="string" string="/var/log/prometheus/%programname%.log"
 +if ($programname startswith 'prometheus') then { 
 +   action( 
 +        type="omfile" 
 +        dynaFile="PROMETHEUS_TEMPLATE" 
 +        fileCreateMode="0640" 
 +        fileOwner="prometheus" 
 +        fileGroup="prometheus" 
 +        dirCreateMode="0750" 
 +        dirOwner="prometheus" 
 +        dirGroup="prometheus" 
 +        ioBufferSize="64k" 
 +    ) 
 +   stop 
 +
 +</file> 
 + 
 +Restart the ''rsyslog'' daemon: 
 + 
 +<cli> 
 +root@host:~$ systemctl restart rsyslog.service 
 +</cli> 
 + 
 +Create the //Prometheus// data directories: 
 + 
 +<cli> 
 +root@host:~$ mkdir -p /srv/prometheus/ 
 +root@host:~$ chown -R prometheus:prometheus /srv/prometheus 
 +</cli> 
 + 
 +If a local IPTables firewall is active on the system running //Prometheus// and the embedded server of //Prometheus// should be used and accessible the TCP port ''9090'' needs to be opened for access to the //Prometheus// WebUI: 
 + 
 +<file config iptables.conf> 
 +# Allow access to Prometheus from local networks 
 +-A INPUT -p tcp -s <YOUR-NETWORK> --dport 9090 -j ACCEPT 
 +</file> 
 + 
 +and reload the IPTables rules: 
 + 
 +<cli> 
 +root@host:~$ iptables-restore < iptables.conf 
 +</cli>
  
 ====== Configuration ====== ====== Configuration ======
  
-FIXME+===== Initial ===== 
 + 
 +Configure the //Prometheus// data directory: 
 + 
 +<cli> 
 +root@host:~$ vi /etc/default/prometheus 
 +</cli> 
 + 
 +File contents: 
 + 
 +<file config /etc/default/prometheus> 
 +[...] 
 +ARGS="--storage.tsdb.path='/srv/prometheus/metrics2/'" 
 +[...] 
 +</file> 
 + 
 +===== Adding Prometheus to Grafana ===== 
 + 
 +See [[sw:grafana:intro#adding_prometheus_to_grafana|Adding Prometheus to Grafana]] 
 + 
 +===== Scraping metrics with Prometheus ===== 
 + 
 +Configure //Prometheus// to //scrape// metrics from various sources: 
 + 
 +==== Loki ==== 
 + 
 +<cli> 
 +root@host:~$ vi /etc/prometheus/prometheus.yml 
 +</cli> 
 + 
 +File contents: 
 + 
 +<file config /etc/prometheus/prometheus.yml> 
 +[...] 
 +scrape_configs: 
 +  [...] 
 +  - job_name: loki 
 +    static_configs: 
 +      - targets: ['localhost:3100'
 +  [...] 
 +[...] 
 +</file> 
 + 
 + 
 +==== Promtail ==== 
 + 
 +<cli> 
 +root@host:~$ vi /etc/prometheus/prometheus.yml 
 +</cli> 
 + 
 +File contents: 
 + 
 +<file config /etc/prometheus/prometheus.yml> 
 +[...] 
 +scrape_configs: 
 +  [...] 
 +  - job_name: promtail 
 +    static_configs: 
 +      - targets: ['localhost:9080'
 +  [...] 
 +[...] 
 +</file>
  
 ====== Usage ====== ====== Usage ======