• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Prometheus 安装部署

互联网 diligentman 4周前 (01-31) 14次浏览
一、Prometheus下载安装

1、prometheus 启动命令

/home/service/prometheus/prometheus --config.file=/home/service/prometheus/prometheus.yml --storage.tsdb.path=/home/service/prometheus/prometheus-data --storage.tsdb.retention.time=7d

2、prometheus.yml 配置文件

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).
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
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: ['172.17.0.12:9090']
  - job_name: 'node'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['172.17.0.12:9100']

**3、在本机可以启动一个node exporter,用于下文测试,通过http://127.0.0.1:9100/metrics 验证node exporter是否启动成功
**

二、PromQL 基本语法

1、Prometheus 默认启动端口是9090,通过浏览器即可访问prometheus的graph页面;
2、计算每台主机在五分钟内的cpu平均使用率

(1-(avg(irate(node_cpu_seconds_total{cpu='0',mode='idle'}[5m])))) * 100

Prometheus 安装部署


程序员灯塔
转载请注明原文链接:Prometheus 安装部署
喜欢 (0)