了解来自 Graphite 渲染界面的响应

Understanding the response from Graphite render interface

当从 Graphites /render API 获得 JSON 响应时,它看起来如下。

{
"target": "summarize(sol.count.meter.count, "1day", "sum")",
"datapoints": [
  [
  null,
  1481846400
],,
  [
  null,
  1481932800
],,
  [
  null,
  1482019200
],,
  [
  null,
  1482105600
],,
  [
  null,
  1482192000
],,
  [
  null,
  1482278400
],,
  [
  1006491,
  1482364800
],,
  [
  1577,
  1482451200
],
],
}

我对预期响应的直觉是,我会得到一个包含数据点的列表,其中每天都有 0 或 1 个度量。然而这不是我得到的。

我不明白的是为什么我们需要一个嵌套列表来表示数据点? Graphite 响应中内部列表的内容是什么?

石墨的json输出格式可以定义为度量系列数组,每个度量系列是一个对象该系列的id/name调用了目标数据点数组,最后每个数据点都是一个对应值的数组和时间戳.

[
  {
     "datapoints": [
       [value1, timestamp1],
       [value2, timestamp2],
       // ...
     ],
     "target": "some.metric.count"
  },  {
     "datapoints": [
       [value9, timestamp99],
       [value8, timestamp88],
       // ...
     ],
     "target": "some.metric2.count"
  },
  // ...
]

此结构是设计理念及其实现的结果:

  • 数据点必须包含值和时间戳(时间帧在渲染器上对齐并且可以调整)并且数组是最轻的结构
  • 数据点必须是一个数组以保持顺序,因为对象是一个类似散列的结构。请注意,每个系列可以有非常不同的时间戳,但具有特定的顺序和相同的长度(如果没有找到值则为空)

My intuition about the expected response is that I would get a list with datapoints, where each day has 0 or 1 measure. However this is not what I get.

summarize减少(使用sum/avg/max/min)每个指定时间桶的数据点,如果桶中的所有值都是空值,则最终值等于null。您可以使用 transfomrNulls 将空值替换为所需的值。