prometheus编译安装

prometheus是搜集应用程序所使用的CPU 内存 以及磁盘使用大小的神器,
它可以根据用户所配置的性能阀值给出相应的处理,比如 邮件告警等,在这里就不啰嗦了,由于本人也是刚刚学习 所以能说的也就这么多.

一.代码编译:
1.克隆代码

git clone https://github.com/prometheus/prometheus.git 

2.代码编译,很简单,因为官方提供了Makefile ,直接在prometheus文件下执行

make build

执行之后的结果:

[root@reg prometheus]# ls -l
total 76700
-rw-r--r--  1 root root    52270 Dec 16 11:33 CHANGELOG.md
-rw-r--r--  1 root root     2415 Dec 16 11:33 circle.yml
drwxr-xr-x  4 root root     4096 Dec 16 11:33 cmd
-rw-r--r--  1 root root      155 Dec 16 11:33 code-of-conduct.md
drwxr-xr-x  3 root root     4096 Dec 16 11:33 config
drwxr-xr-x  2 root root     4096 Dec 16 11:33 console_libraries
drwxr-xr-x  2 root root     4096 Dec 16 11:33 consoles
-rw-r--r--  1 root root     3022 Dec 16 11:33 CONTRIBUTING.md
drwxr-xr-x  3 root root     4096 Jan  1 11:06 data
drwxr-xr-x 13 root root     4096 Dec 16 11:33 discovery
-rw-r--r--  1 root root     1056 Dec 16 11:33 Dockerfile
drwxr-xr-x  5 root root     4096 Dec 16 11:33 docs
drwxr-xr-x  5 root root     4096 Dec 16 11:33 documentation
-rw-r--r--  1 root root    11357 Dec 16 11:33 LICENSE
-rw-r--r--  1 root root      440 Dec 16 11:33 MAINTAINERS.md
-rw-r--r--  1 root root     3373 Dec 16 11:33 Makefile
-rw-r--r--  1 root root     2769 Dec 16 11:33 NOTICE
drwxr-xr-x  2 root root     4096 Dec 16 11:33 notifier
drwxr-xr-x  9 root root     4096 Dec 16 11:33 pkg
-rwxr-xr-x  1 root root 65406721 Dec 16 11:56 prometheus
-rw-r--r--  1 root root      216 Jan  1 11:05 prometheus.yml
drwxr-xr-x  2 root root     4096 Dec 16 11:33 prompb
drwxr-xr-x  4 root root     4096 Dec 16 11:33 promql
-rwxr-xr-x  1 root root 12932451 Dec 16 11:57 promtool
-rw-r--r--  1 root root     4482 Dec 16 11:33 README.md
drwxr-xr-x  2 root root     4096 Dec 16 11:33 relabel
drwxr-xr-x  3 root root     4096 Dec 16 11:33 retrieval
drwxr-xr-x  2 root root     4096 Dec 16 11:33 rules
drwxr-xr-x  2 root root     4096 Dec 16 11:33 scripts
drwxr-xr-x  4 root root     4096 Dec 16 11:33 storage
drwxr-xr-x  2 root root     4096 Dec 16 11:33 template
drwxr-xr-x  9 root root     4096 Dec 16 11:33 util
drwxr-xr-x  7 root root     4096 Dec 16 11:33 vendor
-rw-r--r--  1 root root        6 Dec 16 11:33 VERSION
drwxr-xr-x  4 root root     4096 Dec 16 11:33 web

就可以了,当然,golang的环境问题,是必须的,另外,编译之后您也可以进行镜像打包

make docker

就可以了
结果:

[root@reg prometheus]# docker images | grep prometheus
prometheus                                          master               d4bd4a6d5364        2 weeks ago         80.9 MB
quay.io/prometheus/busybox                          latest               747e1d7f6665        3 months ago        2.57 MB

quay.io/prometheus/busybox 这个镜像是基础镜像

二 安装
创建prometheus.yml文件
内容

[root@reg prometheus]# cat prometheus.yml 
global:
  scrape_interval:     15s
  evaluation_interval: 15s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['10.39.0.102:9090']

这个是官方的简单的例子
执行:

[root@reg prometheus]# ./prometheus --config.file=prometheus.yml 
level=info ts=2018-01-01T03:06:43.633722756Z caller=main.go:220 msg="Starting Prometheus" version="(version=2.0.0, branch=master, revision=9083d41d3a788f750d520a3975dced39644471a9)"
level=info ts=2018-01-01T03:06:43.633823681Z caller=main.go:221 build_context="(go=go1.9.2, user=root@reg.ennew.com, date=20171216-03:56:18)"
level=info ts=2018-01-01T03:06:43.633847699Z caller=main.go:222 host_details="(Linux 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 reg.ennew.com (none))"
level=info ts=2018-01-01T03:06:43.633865608Z caller=main.go:223 fd_limits="(soft=1024, hard=4096)"
level=info ts=2018-01-01T03:06:43.63726474Z caller=web.go:383 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-01-01T03:06:43.637175893Z caller=targetmanager.go:71 component="target manager" msg="Starting target manager..."
level=info ts=2018-01-01T03:06:43.637261778Z caller=main.go:400 msg="Starting TSDB ..."
level=info ts=2018-01-01T03:06:43.648872734Z caller=main.go:410 msg="TSDB started"
level=info ts=2018-01-01T03:06:43.648933774Z caller=main.go:492 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2018-01-01T03:06:43.649697319Z caller=main.go:387 msg="Server is ready to receive requests."

在浏览器打开:http://10.39.0.102:9090/metrics
会看到

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 5.419e-05
go_gc_duration_seconds{quantile="0.25"} 7.8513e-05
go_gc_duration_seconds{quantile="0.5"} 0.000132775
go_gc_duration_seconds{quantile="0.75"} 0.000183778
go_gc_duration_seconds{quantile="1"} 0.004308542
go_gc_duration_seconds_sum 0.005393469
go_gc_duration_seconds_count 10
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 81
....

在浏览器打开:http://10.39.0.102:9090/
就会看到页面了

prometheus

现在您就可以使用操作界面了

关于如何使用 请参考官方文档

简单举个例子

在页面输入:

http_requests_total

结果

prometheus

还有编译prometheus 的node-exporter 也是这么比较容易的,在这里就费笔墨了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值