Grafana: How to have the duration for a selected period

橙三吉。 提交于 2019-12-23 16:18:18

问题


I can't find the correct mathematical formula to compute a SLA (availability) with Grafana: I have graph to show the duration of downtime for each days: From this, i would like to compute the SLA (eg: 99,5%).

On the graph for the selected period (Last 7 days) i can to have this data:

  • 71258 is the sum of duration of downtime in second. I have this with summarize(1day, max, false)
  • I need to have the sum of duration of time for the selected period (here 7 days = 604800second). But how ?

If i have this last data, after i will do :

(100% * 604800) / 71258 = X %

100% - X % = My SLA!!

My question is: Which formula use to have the duration for a selected period in Grafana ?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/36398159/grafana-how-to-have-the-duration-for-a-selected-period

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!