Graphite的Dashboard绘制的注意事项和最佳实践

Graphite绘制注意事项为:

  1. 命名规范
    • 业务接口采用:API-业务组-模块-EXT方式,例如API-Status-Feed
    • 相关依赖采用:-HTTP,-RPC的方式,例如Feed依赖的RPC服务API-Status-Feed-RPC
    • 后端服务:RPC-服务名,例如 RPC-Object
  2. Dashboard整体设置
    • 时间设置:Relative Time Range 设置为24hours;
    • 刷新设置:打开 Auto-Refresh,设置刷新间隔为 20s;
    • 图块大小设置:Rreset为 Custom,Width为400,Height为300;
    • 每个Dashboard总图表数不超过12个(大屏显示器可以全部展示);
  3. Graph通用设置
    • Title设置:设置 Render Options -> Graph Title,如“Entity MeanTime”;
    • Colors设置:设置 Render Options -> Display -> Color -> Line Colors,设置为 #0033ff,#00ff66,#ff3300,#ffff33,#00ffff,#ff00ff ,替代默认色彩集;
    • 透明度设置:设置 Render Options -> Display -> Color -> Filled Area Alpha Value,设置为 0.8 ;
    • 设置条目别名:设置 Apply Function -> Special -> Set Legend Name,设置别名,以便于阅读,如 alias(stats.timers.openapi.profile.core.tc.API._statuses_repost.avg_time.mean,"TC Status Repost AvgTime");
    • 消除频繁变化的尖刺图:设置 Render Options -> X-Axis -> Point-width Consolidation Threshold,一般设置为 3 即可; 
    • 消除极值点:对于异常大的数据,可以通过设置 Apply Funtion -> Filter -> Data Filters -> Remove Above Value ,removeAboveValue函数将不正常的数据不在图表中展示;
    • Area Mode规范:
      • 对于Time Area(请求量按照性能区间分块)采用堆积图  Stacked 模式;
      • 对于平均处理时间,一般采取 First Only 模式,并将平均数值较小的放在图标的前面。也可以采取 None 模式;
      • 对于QPS,采取 First Only 模式,并将平均数值较小的放在图标的前面;
  4. 业务规范
    • API类Dashboard一般要包括 主要接口的 QPS、AvgTime,依赖的主要Mysql、MC、MCQ、Redis、Hbase、Http的QPS、AvgTime;
    • 对于重要接口区分机房;
    • 每个Graph中的数据线不超过6条;
    • 重要业务增加红色基准线 alias(lineWidth(color(dashed(scale(asPercent(stats.timers.openapi.profile.core.tc.API._statuses_friends_timeline.avg_time.mean,stats.timers.openapi.profile.core.tc.API._statuses_friends_timeline.avg_time.mean),0.5)),"#ff0000"),1),"Base Line")
    • Time Area时间区间参照 http://wiki.intra.weibo.com/Openapi/profile 中类型,如 QPS <100ms 等;
  5. 常用函数
    • 求和:Apply Function -> Combine -> Sum
    • 乘积:Apply Function -> Transform -> Scale
    • 偏移时间: Apply Function -> Transform -> timeShift
    • 百分比展示:Apply Function -> Calculate -> As Percent
    • 虚线:Apply Function -> Special -> Dashed Line


如何画基准线

思路:通过asPercent函数将同一个数据项的值转换为100,然后通过 scale 函数调整到需要的阀值,通过dashed函数变换为虚线,color函数转换颜色,lineWidth调整线的宽度

代码:alias(lineWidth(color(dashed(scale(asPercent(stats.timers.openapi.profile.openapi.tc.API._users_domain_show.avg_time.mean,stats.timers.openapi.profile.openapi.tc.API._users_domain_show.avg_time.mean),0.5)),"#ff0000"),2),"Base Line")

Clipboard Image.png


增加昨日数据对比

思路:使用 timeShift 函数对数据做偏移,然后通过dashed 删除绘制成虚线

代码:alias(dashed(removeAbovePercentile(timeShift(multiplySeries(stats.timers.openapi.profile.mobile.NET.yidong_complete.avg_time.mean,stats.openapi.profile.mobile.NET.yidong_response.total_count),"1d"),98)),"YiDong Total Time 1day Ago")

Clipboard Image.png


如何按照百分比显示

思路:使用 asPercent 函数将同一个系列的数据转换为百分比展示数据

代码:asPercent(stats.openapi.profile.core.yf.API.feed_structure_after_whole.interval*)

Clipboard Image.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值