prometheus入门

prometheus:开源的系统监控和警报工具包,所采集的监控数据均以指标的形式保存再内置的时间序列数据库当中

监控包括:宿主机或自身系统的cpu,内存使用状况

组成:

  1. server-收集和存储时间序列
  2. Client library:用于client访问server
  3. Exporter-各种专用export,面向硬件,存储,数据库,http等
  4. Alertmanager-处理报警
  5. Pushgateway-对于短暂运行的任务,负责接收和缓存时间序列数据,同时也是一个数据源
  6. Node exporter:安装在监控的服务器上,用于暴露metrics给Prometheus;其中metrics包括cpu的负载,内存的使用情况,网络等

相关

  1. Counter:累加的metric,如请求的个数,结束的任务数等
  2. Gauge:常规的metric,如温度,运行的goroutines的个数
  3. Histogram:柱状图,如请求持续时间,响应大小
  4. Summary:类似于histogram,提供观测值的count和sum功能
  5. Instance:一个单独的scrape目标,一般对应于一个进程
  6. Jobs:一组同类型的instances

安装

  1. wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
  2. tar xvfz prometheus-2.10.0.linux-amd64.tar.gz
  3. 启动:./prometheus --config.file=prometheus.yml
  4. 在监控机器上下载node export: wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
  5. tar -xf node_exporter-0.14.0.linux-amd64.tar.g
  6. cp node_exporter-0.14.0.linux-amd64/node_exporter /usr/local/sbin/
  7. /usr/local/sbin/node_exporter

配置

  1. 通过修改/home/prometheus/prometheus-2.10.0.linux-amd64/prometheus.yml 添加target增加监控机器,在graph—graph/console可查看监控信息   
           - targets: ['ip:9100']
             labels:
              group: 'gitlab'

metrics和lables的命名规则
度量指标:metrics和lables(度量指标名称和标签,每一个时间序列数据都由度量指标名称和标签lables键值对集合唯一确定)
metric
符合有效数字的数据模型
与度量所属相关的应用前缀,通常是应用程序名称本身,eg:
    prometheus_notifications_total
    process_cpu_...
必须有一个单位(使用基本的单位,秒,字节,米等)
lables:区分被测物体的特征
api_http_requests_total - differentiate request types: type="create|update|delete"
api_request_duration_seconds - differentiate request stages: stage="extract|transform|load"

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值