Prometheus系列第一篇一监控+面板+告警三剑客部署

文章目录

  • prometheus 部署
  • grafana部署
  • AlertManager部署
  • 总结

prometheus 部署

  • docker部署

本地新建/etc/prometheus/prometheus.yml文件

# 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:
      - 127.0.0.1:9093 # 配置altermanager告警

# 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=` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

docker执行以下命令

docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
  • 非docker部署
export VERSION=2.4.3
curl -LO  https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.darwin-amd64.tar.gz
tar -xzf prometheus-${VERSION}.darwin-amd64.tar.gz
cd prometheus-${VERSION}.darwin-amd64
./prometheus

grafana部署

  • docker部署
docker run -d -p 3000:3000 --name grafana  grafana/grafana
  • 访问http://127.0.0.1:3000为grafana配置prometheus作为数据源
    Prometheus系列第一篇一监控+面板+告警三剑客部署_第1张图片
    Prometheus系列第一篇一监控+面板+告警三剑客部署_第2张图片

AlertManager部署

  • docker部署
docker run --name alertmanager -p 9093:9093 prom/alertmanager:v0.23.0
  • 非docker部署
export VERSION=0.15.2
curl -LO https://github.com/prometheus/alertmanager/releases/download/v$VERSION/alertmanager-$VERSION.darwin-amd64.tar.gz
tar xvf alertmanager-$VERSION.darwin-amd64.tar.gz
./alertmanager

总结

  • Prometheus可以看做对metrics的采集与存储的数据源,其内部包含一个tsdb[timestamp series database]
  • Prometheus可以作为grafana的数据源
  • grafana可以配置altermanager
  • prometheus本身可以集成altermanager
    • 企业最佳实践: prometheus负责采集数据,grafana负责配置诸如prometheus等数据源进行面板展示,grafana集成altermanager进行告警
      ,
      Prometheus系列第一篇一监控+面板+告警三剑客部署_第3张图片

你可能感兴趣的:(prometheus,架构,监控)