docker-compose

  • docker-compose.yaml
version: '3.2'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
    - 9090:9090
    command:
    - --config.file=/etc/prometheus/prometheus.yml
    volumes:
    - ./prom/prometheus.yml:/etc/prometheus/prometheus.yml:ro
  grafana:
    image: grafana/grafana-enterprise
    ports:
    - 3000:3000
  gometric:
    image: oneslide/go-metrics
    ports:
    - 8080:8080
  • ./prom/prometheus.yml
scrape_configs:
- job_name: prom
  scrape_interval: 5s
  static_configs:
  - targets:
    - localhost:9090
- job_name: gometric
  scrape_interval: 5s
  static_configs:
  - targets:
    - gometric:8080

gometric是使用Prometheus Go client library写的web应用

  • 启动
docker-compose up -d 

百分位点

  • histogram

histogram可以使用histogram_quantile(φ scalar, b instant-vector) 计算任意百分位点。
参考histogram_quantile()

计算过去10m内,90%的RPC请求在多少秒内完成

histogram_quantile(0.9, rate(rpc_durations_histogram_seconds_bucket[10m]))
  • summary

summary只能指定预先设定好的百分位点。访问gometric的/metrics接口,可以看到:

# HELP rpc_durations_seconds RPC latency distributions.
# TYPE rpc_durations_seconds summary
rpc_durations_seconds{service="exponential",quantile="0.5"} 7.621662406368606e-07
rpc_durations_seconds{service="exponential",quantile="0.9"} 2.411794063405817e-06
rpc_durations_seconds{service="exponential",quantile="0.99"} 4.95442152061398e-06
rpc_durations_seconds_sum{service="exponential"} 0.0018711212215494185
rpc_durations_seconds_count{service="exponential"} 1884

summary的百分位点是在客户端计算实现的,在上面情况下,只能指定50% 90% 99%三个百分位点。

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐