prometheus 安装和简单使用

一 : 安装

环境准备:1 go1.12及以上

                  2 git

mkdir -p $GOPATH/src/github.com/prometheus
cd $GOPATH/src/github.com/prometheus
git clone https://github.com/prometheus/prometheus.git
cd prometheus
make build (此步可能持续较长时间,耐心等待)

准备配置文件

vi prometheus.yml

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']

启动
./prometheus --config.file=prometheus.yml

访问 127.0.0.1:9090/graph

prometheus 安装和简单使用_第1张图片

安装成功

二 使用

127.0.0.1:9090/metrics 查看指标列表

任选一个指标填入文本框

点击 Execute 按钮prometheus 安装和简单使用_第2张图片

或者使用Api

前缀(访问地址)

http://127.0.0.1:9090/api/v1/query?query=

后缀(指标)

prometheus_sd_kubernetes_events_total

拼接

http://127.0.0.1:9090/api/v1/query?query=prometheus_sd_kubernetes_events_total

发送get请求

得到类似结果

prometheus 安装和简单使用_第3张图片

 

 

你可能感兴趣的:(go)