简体   繁体   English

缩小时Grafana仪表板不显示数据

[英]Grafana Dashboard not showing data when zoomed out

I have a Prometheus server which scrapes our aws billing data as metrics using this exporter . 我有一个Prometheus服务器,它使用此导出器抓取我们的AWS账单数据作为指标。 I scrape the billing metrics every 6h to limit the requests. 我每6小时抓取一次计费指标以限制请求。 Than a Grafana server builds some dashboards using this data. 比Grafana服务器使用此数据构建一些仪表板。

The dashboard shows data as expected when I select Last 24 hours 当我选择“ Last 24 hours时,仪表板将按预期显示数据

带有数据的仪表板

But if I change the range to this Month the Graph plots No data points 但是,如果我将范围更改为this Month则图表将No data points

仪表板出现错误

I have not found any way to get Grafana to show the data when zoomed out. 我还没有找到让Grafana在缩小时显示数据的任何方法。 This is the configuration 这是配置

{
  "aliasColors": {},
  "bars": true,
  "dashLength": 10,
  "dashes": false,
  "fill": 1,
  "gridPos": { "h": 12, "w": 5, "x": 5, "y": 16 },
  "id": 12,
  "legend": {
    "alignAsTable": true,
    "avg": false,
    "current": true,
    "hideEmpty": false,
    "hideZero": false,
    "max": false,
    "min": false,
    "rightSide": false,
    "show": true,
    "total": false,
    "values": true
  },
  "lines": false,
  "linewidth": 1,
  "links": [],
  "nullPointMode": "connected",
  "percentage": false,
  "pointradius": 2,
  "points": false,
  "renderer": "flot",
  "seriesOverrides": [],
  "spaceLength": 10,
  "stack": true,
  "steppedLine": false,
  "targets": [
    {
      "expr": "topk(5 ,aws_billing_estimated_charges_sum{linked_account=\"1234567890\"})",
      "format": "time_series",
      "intervalFactor": 1,
      "legendFormat": "{{service_name}}",
      "refId": "A"
    }
  ],
  "thresholds": [],
  "timeFrom": null,
  "timeRegions": [],
  "timeShift": null,
  "title": "Prod: Top 5 Services ",
  "tooltip": {
    "shared": true,
    "sort": 0,
    "value_type": "individual"
  },
  "type": "graph",
  "xaxis": {
    "buckets": null,
    "mode": "time",
    "name": null,
    "show": true,
    "values": []
  },
  "yaxes": [
    {
      "format": "currencyUSD",
      "label": null,
      "logBase": 1,
      "max": null,
      "min": null,
      "show": true
    },
    {
      "format": "short",
      "label": null,
      "logBase": 1,
      "max": null,
      "min": null,
      "show": false
    }
  ],
  "yaxis": {
    "align": false,
    "alignLevel": null
  }
}

How can I get Grafana to show my chart? 如何让Grafana显示我的图表?

I don't have any metrics with such low resolution, so I can't actually test this. 我没有任何分辨率如此低的指标,因此我无法进行实际测试。 But I suppose the problem is that the resulting step when zooming out is longer than 5 minutes (Prometheus' default "lookback delta", configurable via the --query.lookback-delta command-line flag). 但是我想问题是缩小时的结果步骤超过5分钟(Prometheus的默认“ lookback delta”,可通过--query.lookback-delta命令行标志进行配置)。

What this lookback delta means is that if you query the value of a time series at a point in time (either via an instant query, or via a range query that will retrieve the values of said time series at distinct points in time, separated by a fixed step time) you'll only get back a value if there is a sample less than 5 minutes before. 回溯增量的意思是,如果您在某个时间点查询时间序列的值(通过即时查询或通过范围查询来检索不同时间点的所述时间序列的值,则以固定的步长时间),只有在少于5分钟的时间之前有样本时,您才能取回值。 So with a step much larger than 5 minutes and samples much farther apart than 5 minutes, it's less likely for your query to hit timestamps less than 5 minutes after a sample and more likely to hit timestamps where there is no sample within the preceding 5 minutes. 因此,如果步长大于5分钟,而采样间隔远远大于5分钟,则查询在采样后不到5分钟内达到时间戳的可能性较小,而在前5分钟内没有采样的时间戳发生的可能性更高。

So what you need to do is extend this 5 minute time range. 因此,您需要做的是延长这5分钟的时间范围。 Either via the command line flag above (not recommended, as it may break other assumptions, for time series with more reasonable scrape intervals); 通过上面的命令行标志(不建议使用,因为对于具有更合理的刮擦间隔的时间序列,可能会破坏其他假设); or by using one of the <aggregation>_over_time functions. 或使用<aggregation>_over_time函数之一。 In combination with Grafana's $__interval variable, something like this should work: 结合Grafana的$__interval变量,类似这样的方法应该起作用:

topk(5, max_over_time(aws_billing_estimated_charges_sum{linked_account="1234567890"}[$__interval]))

This would "force" Prometheus to look back $__interval (which is the interval between the samples Grafana queries for) rather than 5 minutes. 这将“迫使”普罗米修斯回溯$__interval (这是Grafana查询的样本之间的间隔),而不是5分钟。 With a time range of one month (and the graph size in your screenshot) I'd guess that would be somewhere around 1 hour, so Grafana would query for a sample every 1 hour, with the maximum value over the previous 1 hour. 在一个月的时间范围内(以及屏幕快照中的图形大小),我猜大概会是1小时左右,因此Grafana会每1小时查询一次样本,而前一个小时的最大值是。

If you want those samples to result in lines as in your first graph and not disjoint points, then you should also set a Min step of 6h in Grafana. 如果要使这些样本产生与第一个图形相同的线条而不是不相交的点,则还应该在Grafana中将最小步长设置为6h Or use a fixed interval of 6h in your query, but then you'd get a step function that only changes every 6h . 或在查询中使用固定的6h间隔,但是您将获得仅每6h改变一次的步进函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM