Skip to content

Latest commit

 

History

History

lab02

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

实验二、Prometheus+Grafana展示实验

实验步骤

1. 先决条件

  • 运行Prometheus HTTP Metrics Simulator
  • 运行Prometheus服务器

2. 安装运行Grafana

下载Grafana 5.3.2 for Windows,并解压到本地目录。

运行:

./bin/grafana-server.exe

访问Granfa UI,使用缺省账号admin/admin登录

http://localhost:3000

添加Proemethes数据源

其它缺省即可

Save & Test确保连接成功

3. 创建一个Dashboard

点击**+图标创建一个Dashbaord,点击保存**图标保存Dashboard,使用缺省Folder,给Dashboard起名为prom-demo

4. 展示请求率

点击Add panel图标,点击Graph图标添加一个Graph,

点击Graph上的Panel Title->Edit进行编辑

修改Title:General -> Title = Request Rate

设置Metrics

sum(rate(http_requests_total{job="http-simulator"}[5m]))

调整Lagend

  • 以表格展示As Table
  • 显示Min/Max/Avg/Current/Total
  • 根据需要调整Axis

注意保存Dahsboard。

5. 展示实时错误率

点击Add panel图标,点击Singlestat图标添加一个Singlestat,

点击Graph上的Panel Title->Edit进行编辑

修改Title:General -> Title = Live Error Rate

设置Metrics

sum(rate(http_requests_total{job="http-simulator", status="500"}[5m])) / sum(rate(http_requests_total{job="http-simulator"}[5m]))

调整显示单位unit:Options->Unit,设置为None->percent(0.0-1.0)

调整显示值(目前为平均)为当前值(now):Options->Value->Stat,设置为Current

添加阀值和颜色:Options->Coloring,选中Value,将Threshold设置为0.01,0.05,表示

  • 绿色:0-1%
  • 橙色:1-5%
  • 红色:>5%

添加测量仪效果:Options->Gauge,选中Show,并将Max设为1

添加错误率演变曲线:选中Spark lines -> Show

注意保存Dahsboard。

6. 展示Top requested端点

点击Add panel图标,点击Table图标添加一个Table,

设置Metrics

sum(rate(http_requests_total{job="http-simulator"}[5m])) by (endpoint)

减少表中数据项,在Metrics下,选中Instant只显示当前值

隐藏Time列,在Column Sytle下,Apply to columns namedTime,将Type->Type设置为Hidden

Value列重命名,添加一个Column StyleApply to columns namedValue,将Column Header设置为Requests/s

点击表中的Requests/s header,让其中数据根据端点活跃度进行排序。

注意调整Widget位置并保存Dahsboard。