mac下最方便的方式,通过brew安装进行安装管理
安装prometheus
安装
brew install prometheus
prometheus配置文件默认安装路径:/usr/local/etc/prometheus.yml
配置
prometheus.yml
基于文件服务发现:
global:
scrape_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "actuator-prometheus"
# 多久采集一次数据
scrape_interval: 5s
# 采集时的超时时间
scrape_timeout: 5s
# 采集路径
metrics_path: '/actuator/prometheus'
file_sd_configs:
- files:
- /Users/wfbi/monitor/targets/actuator-*.yaml
/Users/wfbi/monitor/targets
目录下actuator-film.yaml
:
- targets:
- localhost:8080
labels:
app: film
job: film-actuator
启动
brew services start prometheus
访问
http://localhost:9090
问题
fatal: unable to access ‘https://github.com/Homebrew/homebrew-services/’: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
解决方案:
git config --global --unset http.proxy
git config --global --unset https.proxy
安装grafana
安装
brew install grafana
prometheus配置文件默认安装路径:/usr/local/etc/grafana/grafana.ini
启动
brew services start grafana
访问
http://localhost:3000
默认账号密码:admin/admin
添加prometheus数据源:Configuration -> Add data source -> Prometheus -> Add HTTP:URL -> Save&test
Reference