DevOps Tools/Prometheus
From r00tedvw.com wiki
(Difference between revisions)
| Line 23: | Line 23: | ||
<nowiki>~$ sudo vim /etc/prometheus/prometheus.yml</nowiki> | <nowiki>~$ sudo vim /etc/prometheus/prometheus.yml</nowiki> | ||
<div class="mw-collapsible mw-collapsed"> | <div class="mw-collapsible mw-collapsed"> | ||
| − | + | prometheus config | |
| − | <div class="mw-collapsible-content"> | + | <div class="mw-collapsible-content"> |
| + | <nowiki># my global config | ||
| + | global: | ||
| + | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. | ||
| + | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. | ||
| + | # scrape_timeout is set to the global default (10s). | ||
| + | |||
| + | # Alertmanager configuration | ||
| + | alerting: | ||
| + | alertmanagers: | ||
| + | - static_configs: | ||
| + | - targets: | ||
| + | # - alertmanager:9093 | ||
| + | |||
| + | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. | ||
| + | rule_files: | ||
| + | # - "first_rules.yml" | ||
| + | # - "second_rules.yml" | ||
| + | |||
| + | # A scrape configuration containing exactly one endpoint to scrape: | ||
| + | # Here it's Prometheus itself. | ||
| + | scrape_configs: | ||
| + | # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. | ||
| + | - job_name: 'prometheus' | ||
| + | |||
| + | # metrics_path defaults to '/metrics' | ||
| + | # scheme defaults to 'http'. | ||
| + | |||
| + | static_configs: | ||
| + | - targets: ['localhost:9090']</nowiki> | ||
| + | </div> | ||
</div> | </div> | ||
Revision as of 14:21, 26 August 2022
Overview | Prometheus
Contents |
CentOS 7 Installation
Create dependencies
~$ sudo yum install -y wget
~$ sudo groupadd --system prometheus
~$ sudo useradd -s /sbin/nologin --system -g prometheus prometheus
~$ sudo mkdir /var/lib/prometheus
~$ for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done
~$ mkdir -p /tmp/prometheus && cd /tmp/prometheus
Download and setup
~$ curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi - ~$ tar xvf prometheus*.tar.gz ~$ cd prometheus*/ ~$ sudo mv prometheus promtool /usr/local/bin/ ~$ sudo mv prometheus.yml /etc/prometheus/prometheus.yml ~$ sudo mv consoles/ console_libraries/ /etc/prometheus/ ~$ cd ~/ ~$ rm -rf /tmp/prometheus
Create config
~$ sudo vim /etc/prometheus/prometheus.yml
prometheus config
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']