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

169 views Asked by At

I'm looking for the exact equivalent of the /meter/[meterName]/statistics endpoint of the ceilometer web api for Gnocchi, but I'm struggling finding the equivalent, it looks like there is no way to retrieve the same informations.

The ceilometer endpoint mentions that 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. and provides an expressive API allowing to apply further filtering and advanced search options, like this:

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"]

which will produce an output like this:

[{"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"}]

(documentation about that can be found here).

In Gnocchi, instead (documentation about web apis can be found 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'"
}

which will produce something like this:

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
          ]
        ]
      }
    }
  }
]

However, apart from not allowing to filter for metadata, the endpoint still produces measures (aggregated measures) instead of aggregated data.

There does not seem to be any way to produce the same data, although Gnocchi is mentioned as the updated substitute of Ceilometer in the OpenStack documentation.

Did anyone manage to find a way to replace the ceilometer endpoint?

1

There are 1 answers

0
briosheje On BEST ANSWER

I've got an answer through github through the official Gnocchi repository.

It looks like you cannot directly get the same output, although there are two possible strategies to get close to it:

  1. Define an archive policy that matches the desired aggregation.
  2. Perform the http requests for each stat and aggregate data manually later.

More about that can be directly found here