prometheus安装
下载地址https://prometheus.io/
tar -zxvf prometheus-2.0.0.linux-amd64.tar.gz
cd prometheus-2.0.0.linux-amd64.tar.gz
./prometheus
配置项
-
全局配置
- global:
- scrape_interval: 15s # 默认 15秒到目标处抓取数据
-
这个标签是在本机上每一条时间序列上都会默认产生的,主要可以用于 联合查询、远程存储、Alertmanger时使用。
- external_labels:
- monitor: ‘codelab-monitor’
-
这里就表示抓取对象的配置
-
设置抓取自身数据
- scrape_configs:
-
job name 这个配置是表示在这个配置内的时间序例,每一条都会自动添加上这个{job_name:“prometheus”}的标签。
-
- job_name: ‘prometheus’
-
重写了全局抓取间隔时间,由15秒重写成5秒。
- scrape_interval: 5s
- static_configs:
-
- targets: [‘localhost:9090’]
简单配置
prometheus.yml
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_timeout is set to the global default (10s).
alerting:
alertmanagers:
rule_files:
- “first_rules.yml”
- “second_rules.yml”
scrape_configs:
The job name is added as a label job=<job_name>
to any timeseries scraped from this config.
-
job_name: ‘prometheus’
metrics_path defaults to ‘/metrics’
scheme defaults to ‘http’.
static_configs:
- targets: [‘localhost:9090’]
labels:
instance: prometheus
- targets: [‘localhost:9090’]
#监控canal
- job_name: ‘canal’
metrics_path defaults to ‘/metrics’
scheme defaults to ‘http’.
static_configs:- targets: [‘c9:11112’,‘c6:11112’]
labels:
instance: canal
- targets: [‘c9:11112’,‘c6:11112’]
#监控doris
- job_name: ‘PALO_CLUSTER’ # 每一个 Doris 集群,我们称为一个 job。这里可以给 job 取一个名字,作为 Doris 集群在监控系统中的名字。
#metrics_path: ‘/metrics’ # 这里指定获取监控项的 restful api。配合下面的 targets 中的 host:port,Prometheus 最终会通过 host:port/metrics_path 来采集监控项。
static_configs: # 这里开始分别配置 FE 和 BE 的目标地址。所有的 FE 和 BE 都分别写入各自的 group 中。-
targets: [‘c9:8030’,‘c6:8030’,‘c3:8030’]
labels:
group: fe # 这里配置了 fe 的 group,该 group 中包含了 3 个 Frontends -
targets: [‘c9:8040’,‘c6:8040’,‘c3:8040’]
labels:
group: be # 这里配置了 be 的 group,该 group 中包含了 3 个 Backends
-
#监控pulsar
- job_name: ‘pulsar-project’
Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
#监控broker- targets: [‘c2:8080’,‘c3:8080’,‘c4:8080’,‘c5:8080’,‘c6:8080’]
labels:
group: ‘pulsar-broker-state’
#监控bookie - targets: [‘c2:8000’,‘c3:8000’,‘c4:8000’,‘c5:8000’,‘c6:8000’]
labels:
group: ‘pulsar-bookie-state’
- targets: [‘c2:8080’,‘c3:8080’,‘c4:8080’,‘c5:8080’,‘c6:8080’]
启动命令
./prometheus --config.file “/mnt/prometheus-2.7.0.linux-amd64/prometheus.yml” --web.enable-lifecycle --storage.tsdb.retention=10d
默认访问端口
9090
例 http://c9:9090
grafana安装
安装
wget https://dl.grafana.com/oss/release/grafana-5.4.3.linux-amd64.tar.gz
tar zxfv 安装包
启动
./bin/grafana-server web
默认访问端口 3000
例 http://c9:3000