Prometheus入门和granfana

Prometheus简介:
Prometheus是一个开源的系统监控和报警的工具包,最初由SoundCloud发布。
特点:
1.多维数据模型(有metric名称和键值对确定的时间序列)
2.灵活的查询语言
3.不依赖分布式存储
4.通过pull方式采集时间序列,通过http协议传输
5.支持通过中介网关的push时间序列的方式
6.监控数据通过服务或者静态配置来发现
7.支持图表和dashboard等多种方式
组件:
Prometheus 主程序,主要是负责存储、抓取、聚合、查询方面。
Alertmanager 程序,主要是负责实现报警功能。
Pushgateway 程序,主要是实现接收由Client push过来的指标数据,在指定的时间间隔,由主程序来抓取。
*_exporter 这类是不同系统已经实现了的集成。
时间序列化数据库,我的理解就是将数据打上标签,以时间维度存储。后面有机会在深入研究。
组成图为:

解压 tar zxvf prometheus-*.tar.gz
将prometheus移动到/server目录下
mv prometheus-2.8.1.linux-amd64 /server/
进入prometheus,执行cd prometheus

对prometheus中的配置进行处理:
global: # 全局设置,可以被覆盖
scrape_interval: 15s # 默认值为 15s,用于设置每次数据收集的间隔
external_labels: # 所有时间序列和警告与外部通信时用的外部标签
monitor: ‘codelab-monitor’
rule_files: # 警告规则设置文件

  • ‘/etc/prometheus/alert.rules’

用于配置 scrape 的 endpoint 配置需要 scrape 的 targets 以及相应的参数

scrape_configs:

The job name is added as a label job=<job_name> to any timeseries scraped from this config.

  • job_name: ‘prometheus-server’ # 一定要全局唯一, 采集 Prometheus 自身的 metrics

    覆盖全局的 scrape_interval

    scrape_interval: 5s
    static_configs: # 静态目标的配置
    • targets: [‘172.17.0.2:9090’]
  • job_name: ‘node’ # 一定要全局唯一, 采集本机的 metrics,需要在本机安装 node_exporter
    scrape_interval: 10s
    static_configs:
    • targets: [‘ip:9100’] # 本机 node_exporter 的 endpoint

启动:
./prometheus --config.file=prometheus.yml & (&代表后台启动)

监控服务器: node_export安装
为了更好的演示 Prometheus 从配置,到监控,到报警的功能,本实例将引入本机 ubuntu server 的监控。由于 Prometheus 主要用于监控 web 服务,如果需要监控 ubuntu server,则需要在本机上安装 node exporter。 Node exporter 主要用于暴露 metrics 给 Prometheus,其中 metrics 包括:cpu 的负载,内存的使用情况,网络等。

将node-export放入目录 /server/node-export下。

nohup ./node_exporter & 后台启动

grafana安装
wget https://dl.grafana.com/oss/release/grafana-6.1.6-1.x86_64.rpm
sudo yum localinstall grafana-6.1.6-1.x86_64.rpm
启动服务service grafana-server start (密码: hgzx@2019)

导入模版 ,模版中有仪表盘需要下载仪表盘支持:
测试环境可以联网: git clone https://github.com/grafana/piechart-panel.git
重新启动grafana: sudo service grafana-server restart

若不能联网: 将下载后的文件 解压放入/var/lib/grafana/plugins后再重启

Prometheus监控redis

在地址https://github.com/oliver006/redis_exporter/releases中进行后:
将redis_export放入目录 /server/redis_export下。

有密码的redis:
./redis_exporter -redis.addr 192.168.10.78:6379 -redis.password wangyu & (启动可以时集群,也可以是单机。)
下面的启动 默认监听本机的6379端口的redis:
nohup ./redis_export& 后台启动 (9121对外端口)

公司redis安装在服务器:http://ip:6379(密码:hgzx@2019,单机版)
集群在: ip:7001、ip:7002、ip:7003、ip:7001、ip:7002、ip:7003

Prometheus监控elasticsearch

地址: https://github.com/justwatchcom/elasticsearch_exporter/releases
将elasticsearch_export放入目录 /server/elasticsearch_export下。
./elasticsearch_exporter --es.uri http://ip:9200 &

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值