软件选择
1、Grafana大屏展示
2、prometheus数据库
3、node_exporter采集
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
安装好后
brew update brew install grafana
运行Grafana
brew services start grafana
停止Grafana
brew services stop grafana
升级Grafana
brew update brew reinstall grafana
查看版本
grafana-server -v
Version 7.0.0 (commit: unknown-dev, branch: master) grafana-server -v Version 7.2.0 (commit: unknown-dev, branch: master)
登陆Grafana
默认用户名密码admin
http://localhost:3000/login
brew install prometheus
运行prometheus
brew services start prometheus
停止prometheus
brew services stop prometheus
带参数启动:参数意义可以热加载
prometheus --config.file=/usr/local/etc/prometheus.yml --web.enable-lifecycle 2>&1 &
页面访问
http://localhost:9090/graph
查看prometheus版本
prometheus --version
显示如下
prometheus, version 2.21.0 (branch: non-git, revision: non-git)
配置文件位置
/usr/local/etc/prometheus.yml
cat prometheus.yml
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
origin_prometheus: 'whx'
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
更改相关配置就是在prometheus.yml文件里,实际我的开发配置如下
cat prometheus.yml
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
origin_prometheus: 'whx'
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node"
static_configs:
- targets: ["127.0.0.1:9100"]
- job_name: 'cm_monitor'
file_sd_configs:
- files: ['/usr/local/etc/moniter_config/*.yml']
refresh_interval: 5s
第一个job为prometheus,第二个为我安装的本机采集工具node_exporter,第三个为我自己写的Hadoop一些指标采集job,这里涉及了刮擦文件可以在prometheus.yml同级目录创建一个文件夹来防止要采集的机器端口,并且还可以创建rules文件夹。
bob@bob etc % ls -l
total 16
drwxr-xr-x 4 bob admin 128 12 15 11:21 bash_completion.d
drwxr-xr-x 6 bob admin 192 12 15 14:23 data
drwxr-xr-x 4 bob admin 128 12 15 11:20 grafana
drwxr-xr-x 3 bob admin 96 12 16 10:37 moniter_config
-rw-r--r-- 1 bob admin 0 12 15 14:38 node_exporter.args
-rw-r--r-- 1 bob admin 126 12 15 14:18 prometheus.args
-rw-r--r-- 1 bob admin 424 12 16 10:35 prometheus.yml
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。