前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >prometheus入门(一)

prometheus入门(一)

作者头像
alexhuiwang
发布2020-09-23 11:38:42
9330
发布2020-09-23 11:38:42
举报
文章被收录于专栏:运维博客运维博客

prometheus入门(一)

大纲

  • 基础架构介绍
  • 官方站点以及后期用到的软件包介绍
  • prometheus以及各类exporter的使用
  • 告警配置
  • 高可用架构
  • docker&k8s监控

基础架构介绍

官方站点: https://prometheus.io 官方架构图:

prometheus入门(一)
prometheus入门(一)

大体组成部分以及流程介绍

  • 数据采集: 主要是由各类的exporter采集上报,如图中的1所表示的地方
  • 数据处理: server端,图中2所在的位置,主要的功能是定期抓取上面数据采集的数据,然后将数据落盘和根据告警条件向alertmanager发送告警提示;还有就是根据webUI或者grafana去展示
  • 告警处理: alertmanager根据server定义的阈值和告警去通过不同的媒介(email,pagerduty)向定义的告警接收方发送告警
  • 数据展示: 自身存在prometheusUI这个web界面,利用promSQL去查询和展示数据,也有对应的API,通过grafana或者其他二次开发产品将prometheus数据加以展示

官方站点以及后期用到的软件包介绍

prometheus以及各类exporter的使用

  • 注意事项:
    • 操作系统为centos7+
    • 数据存储可以使用本地或者influxdb
    • 数据默认的保存时间是15天
    • 可以根据不同的业务场景采用不同的expoter或者其组合
  • 大体部署如下:
prometheus入门(一)
prometheus入门(一)

prometheus的安装

代码语言:javascript
复制
> wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz
> tar xf prometheus-2.18.1.linux-amd64.tar.gz
> mv prometheus-2.18.1.linux-amd64/* /usr/local/bin/
------------写入启动文件
> cat /etc/systemd/system/prometheus.service 
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System

[Service]
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --web.listen-address=:9090

[Install]
WantedBy=multi-user.target
-------准备配置文件
> cat /etc/prometheus/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.
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
prometheus配置文件简介
  • 配置问价是yaml格式的
  • 字段介绍:
    • global: 全局配置,配置抓取的间隔和评估时间
    • remoteDB: 远端数据库存储配置,主要使用influxdb
    • alertManager: 配置alertmanager告警发送
    • rules: 告警阈值的定义
    • scrape_configs: 定义锁抓取的exporter地址,后期加入exporter主要在这操作即可
服务配置检测与启动
代码语言:javascript
复制
> promtool  check config /etc/prometheus/prometheus.yml # 检测配置文件正确性
> systemctl enable prometheus && systemctl start prometheus  #服务启动与开机自启动
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-05-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • prometheus入门(一)
    • 大纲
      • 基础架构介绍
        • 大体组成部分以及流程介绍
      • 官方站点以及后期用到的软件包介绍
        • prometheus以及各类exporter的使用
          • prometheus的安装
      相关产品与服务
      Prometheus 监控服务
      Prometheus 监控服务(TencentCloud Managed Service for Prometheus,TMP)是基于开源 Prometheus 构建的高可用、全托管的服务,与腾讯云容器服务(TKE)高度集成,兼容开源生态丰富多样的应用组件,结合腾讯云可观测平台-告警管理和 Prometheus Alertmanager 能力,为您提供免搭建的高效运维能力,减少开发及运维成本。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档