OpenStack Gnocchi - 等同于 ceilometer /v2/meter/[meter]/statistics

OpenStack Gnocchi - Equivalent of ceilometer /v2/meter/[meter]/statistics

我正在寻找 Gnocchi 的云高仪网络 api 的 /meter/[meterName]/statistics 端点的精确等效项,但我正在努力寻找等效项,看起来没有办法检索相同的信息。

ceilometer 端点提到 When a simple statistics request is invoked (using GET /v2/meters/<meter_name>/statistics), it will return the standard set of Statistics: avg, sum, min, max, and count. 并提供了一个富有表现力的 API 允许应用进一步的过滤和高级搜索选项,如下所示:

GET /v2/meters/instance/statistics
q: [{"field": "user_id",
    "op": "eq",
    "value": "user-2"},
    {"field": "source",
     "op": "eq",
     "value": "source-1"}]
groupby: ["project_id", "resource_id"]

这将产生如下输出:

[{"count": 4, "duration_start": "2013-09-18T19:08:33", "min": 1.0,
  "max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
  "sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1137.0,
  "period_start": "2013-09-18T19:08:33", "avg": 1.0,
  "groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
              "resource_id": "551f495f-7f49-4624-a34c-c422f2c5f90b"},
  "unit": "image"},
 {"count": 4, "duration_start": "2013-09-18T19:08:36", "min": 1.0,
  "max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
  "sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1134.0,
  "period_start": "2013-09-18T19:08:36", "avg": 1.0,
  "groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
              "resource_id": "7c1157ed-cf30-48af-a868-6c7c3ad7b531"},
  "unit": "image"},
 {"count": 4, "duration_start": "2013-09-18T19:08:34", "min": 1.0,
  "max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
  "sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1136.0,
  "period_start": "2013-09-18T19:08:34", "avg": 1.0,
  "groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
              "resource_id": "eaed9cf4-fc99-4115-93ae-4a5c37a1a7d7"},
  "unit": "image"}]

(可以找到相关文档 here)。

在 Gnocchi 中(可以找到关于网络 api 的文档 here) I didn't find any way to produce the same info, the closest I could match was using the dynamic aggregates api, although there does not seem any way to filter on the metadata: https://gnocchi.osci.io/rest.html#groupby

POST /v1/aggregates?start=2014-10-06T14:34&groupby=host&groupby=flavor_id HTTP/1.1
Content-Type: application/json
Content-Length: 149

{
  "operations": "(* (aggregate mean (metric cpu.util mean)) 4)",
  "resource_type": "instance",
  "search": "server_group='my_autoscaling_group'"
}

这将产生如下内容:

HTTP/1.1 200 OK
Content-Length: 550
Content-Type: application/json

[
  {
    "group": {
      "flavor_id": "2",
      "host": "compute1"
    },
    "measures": {
      "measures": {
        "aggregated": [
          [
            "2014-10-06T14:00:00+00:00",
            3600.0,
            43.333333333333336
          ],
          [
            "2014-10-06T14:34:00+00:00",
            60.0,
            58.0
          ],
          [
            "2014-10-06T14:34:12+00:00",
            1.0,
            80.0
          ],
          [
            "2014-10-06T14:34:20+00:00",
            1.0,
            36.0
          ]
        ]
      }
    }
  },
  {
    "group": {
      "flavor_id": "2",
      "host": "compute2"
    },
    "measures": {
      "measures": {
        "aggregated": [
          [
            "2014-10-06T14:00:00+00:00",
            3600.0,
            58.4
          ],
          [
            "2014-10-06T14:30:00+00:00",
            1800.0,
            58.4
          ],
          [
            "2014-10-06T14:34:12+00:00",
            1.0,
            18.0
          ],
          [
            "2014-10-06T14:34:20+00:00",
            1.0,
            56.8
          ]
        ]
      }
    }
  }
]

但是,除了不允许过滤元数据外,端点仍会生成度量(聚合度量)而不是聚合数据。

尽管 OpenStack 文档中提到 Gnocchi 是 Ceilometer 的更新替代品,但似乎没有任何方法可以生成相同的数据。

有没有人设法找到替换云高仪端点的方法?

我通过官方 Gnocchi 存储库 github 得到了答案。

看起来你不能直接得到相同的输出,虽然有两种可能的策略可以接近它:

  1. 定义与所需聚合匹配的归档策略。
  2. 对每个统计信息执行 http 请求,稍后手动汇总数据。

可以直接找到更多相关信息here