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 10:43] Frank Fegertsw:prometheus:intro [2022/01/11 11:20] (current) Frank Fegert
Line 64: 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>
 +
 +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> </cli>
  
Line 87: Line 119:
  
 ====== Configuration ====== ====== Configuration ======
 +
 +===== Initial =====
  
 Configure the //Prometheus// data directory: Configure the //Prometheus// data directory:
  
 <cli> <cli>
-root@host:~$ vi //etc/prometheus/prometheus.yml+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> </cli>
  
Line 98: Line 174:
 <file config /etc/prometheus/prometheus.yml> <file config /etc/prometheus/prometheus.yml>
 [...] [...]
-storage+scrape_configs
-  tsdb+  [...] 
-    path/srv/prometheus/metrics2/+  - job_namepromtail 
 +    static_configs: 
 +      - targets: ['localhost:9080'
 +  [...]
 [...] [...]
 </file> </file>