Grafana:如何确定选定时间段的持续时间

时间:2016-04-04 08:49:48

标签: graphite grafana

我找不到使用Grafana计算SLA(可用性)的正确数学公式: 我有图表显示每天停机的持续时间: Graph here 由此,我想计算SLA(例如:99.5%)。

在所选期间(过去7天)的图表上,我可以获得此数据:

  • 71258是第二个停机时间的总和。我总结了(1day,max,false)
  • 我需要获得所选时间段的持续时间总和(此处为7天= 604800秒)。但是怎么样?

如果我有这最后的数据,我会这样做:

  

(100%* 604800)/ 71258 = X%

     

100% - X%=我的SLA !!

我的问题是:在Grafana中使用哪个公式来确定选定时间段的持续时间?

1 个答案:

答案 0 :(得分:0)

One of the database you can run behind Grafana, is Axibase Time Series Database (ATSD). It provides built-in aggregation functions that can perform SLA-type calculations, for example, to compute % of the period when the value exceeded the threshold.

  • THRESHOLD_COUNT - number of violations in the period
  • THRESHOLD_DURATION - cumulative duration of the violations
  • THRESHOLD_PERCENT - duration divided by period

In your example, that would be THRESHOLD_PERCENT.

Here's a sample SLA report for Amazon Web Services instance: https://apps.axibase.com/chartlab/0aa34311/6/. THRESHOLD_PERCENT is visualized on the top chart.

AWS SLA report

The API request looks as follows:

{
    "queries": [{
        "startDate": "2016-02-22T00:00:00Z",
        "endDate": "2016-02-23T00:00:00Z",
        "timeFormat": "iso",
        "entity": "nurswgvml007",
        "metric": "app.response_time",
        "aggregate": {
            "types": [
                "THRESHOLD_COUNT",
                "THRESHOLD_DURATION",
                "THRESHOLD_PERCENT"
            ],
            "period": {
                "count": 1,
                "unit": "HOUR"
            },
            "threshold": {
                "max": 200
            }
        }
    }]
}

ATSD driver: https://github.com/grafana/grafana-plugins/tree/master/datasources/atsd

Disclosure: I work for Axibase.