metric-statistics API fails when monasca deployed using devstack and python is implementation lang

Bug #1521484 reported by Rohit Jaiswal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Monasca
Fix Committed
Low
Ryan

Bug Description

Deployed monasca using devstack: https://github.com/openstack/monasca-api/tree/master/devstack
and chose python as impl lang for monasca api and monasca persister,

Using the monasca list statistics API , get an error: {"error":"error parsing query: aggregate functions with GROUP BY time require a WHERE time clause"}

When doing the same using the monasca CLI, monasca -d metric-statistics, get an error -

File "/opt/monasca/local/lib/python2.7/site-packages/monascaclient/v2_0/shell.py", line 380, in do_metric_statistics
column_names = metric[0]['columns']
KeyError: 0

These are the versions of monasca packages:

monasca-agent==1.1.20.dev17
monasca-api==2015.1.1.dev330
monasca-common==0.0.2
monasca-notification==1.2.8.dev10
monasca-statsd==1.0.2
python-monascaclient==1.0.24

With impl lang as java, this error is not seen..

summary: metric-statistics API fails when monasca deployed using devstack and
- python is implementatio lang
+ python is implementation lang
description: updated
description: updated
Revision history for this message
Roland Hochmuth (roland-hochmuth) wrote :

Ryan Brandt will take a look at this and see if we can resolve.

Changed in monasca:
assignee: nobody → Ryan (ryan-brandt)
Revision history for this message
Ryan (ryan-brandt) wrote :

I tried a variety of queries with both the Monasca CLI and direct API calls, but I was unable to reproduce this in my local devstack environment.

Would you please include a specific query that fails?

Changed in monasca:
status: New → Incomplete
Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

monasca -d metric-statistics image count 2015-01-01 gives the keyerror,

The other error message is when we use the monasca client bindings when invoking the list statistics api in the recommended way - https://github.com/openstack/monasca-api/blob/master/docs/monasca-api-spec.md#list-statistics

Revision history for this message
Ryan (ryan-brandt) wrote :

That query works just fine for me. I believe some problems were recently fixed in the statistics portion of the API, do you still see this problem with the latest code?

Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

It failed with monasca-api==2015.1.1.dev330 python version.. when was it fixed?

Revision history for this message
Ryan (ryan-brandt) wrote :

We've put in a lot of fixes in the last few weeks. I think the statistics change was just a few days ago.

My test version was monasca-api (2015.1.1.dev360)

Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

oh, that seems like a more recent version that i tested with, let me test with the newer version..

Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :
Download full text (3.2 KiB)

With these versions in devstack deployment:

monasca-agent==1.1.20.dev17
monasca-api==2015.1.1.dev373
monasca-common==0.0.2
monasca-notification==1.2.8.dev10
monasca-statsd==1.0.2
python-monascaclient==1.0.24,

I cannot reproduce the CLI error when i try something like: monasca metric-statistics image.size max 2015-01-01 --merge_metrics

But when i try to use the client directly to do the same, i get a stack trace:

DEBUG (client) REQ: curl -g -i -X 'GET' 'http://192.168.10.6:8777/v2/meters/image.size/statistics' -H 'User-Agent: ceilometerclient.openstack.common.apiclient' -H 'X-Auth-Token: {SHA1}200bcc0d11614ad4ebed8a6fd22b26549d9004c5'
INFO (connectionpool) Starting new HTTP connection (1): 192.168.10.6
DEBUG (connectionpool) "GET /v2/meters/image.size/statistics HTTP/1.1" 500 298
DEBUG (client) RESP: [500] {'date': 'Mon, 07 Dec 2015 09:26:18 GMT', 'content-length': '298', 'content-type': 'application/json', 'x-openstack-request-id': 'req-5758ca8f-bf2a-4748-b385-f0444109fe4e', 'server': 'Werkzeug/0.11.2 Python/2.7.6'}

DEBUG (client) RESP BODY: {"error_message": {"debuginfo": null, "faultcode": "Server", "faultstring": "{\n \"title\": \"The repository was unable to process your request\",\n \"description\": \"400: {\\\"error\\\":\\\"error parsing query: aggregate functions with GROUP BY time require a WHERE time clause\\\"}\"\n}"}}

DEBUG (client) Request returned failure status: 500
Traceback (most recent call last):
  File "/opt/monasca/bin/ceilometer", line 11, in <module>
    sys.exit(main())
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/shell.py", line 293, in main
    CeilometerShell().main(args)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/shell.py", line 242, in main
    args.func(client, args)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/v2/shell.py", line 101, in do_statistics
    statistics = cc.statistics.list(**api_args)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/v2/statistics.py", line 58, in list
    q, p))
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/common/base.py", line 70, in _list
    resp = self.api.get(url)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/openstack/common/apiclient/client.py", line 355, in get
    return self.client_request("GET", url, **kwargs)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/openstack/common/apiclient/client.py", line 345, in client_request
    self, method, url, **kwargs)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/openstack/common/apiclient/client.py", line 261, in client_request
    method, self.concat_url(endpoint, url), **kwargs)
  File "/opt/monasca/local/lib/python2.7/site-packages/ceilometerclient/openstack/common/apiclient/client.py", line 201, in request
    raise exceptions.from_response(resp, method, url)
ceilometerclient.openstack.common.apiclient.exceptions.InternalServerError: {
    "title": "The repository was unable to process your request",
    "description": "400: {\"error\":\"error parsing query: aggregate functions with GROUP BY time require a WHERE ...

Read more...

Revision history for this message
Rohit Jaiswal (rohit-jaiswal-3) wrote :

So, i can reproduce the issue with monasca CLI, when i use 1970-01-01 as utc_start_time for monasca metric-statistics.

 /opt/stack/ceilometer/ceilometer/storage$ monasca metric-statistics image.size max 1970-01-01 --merge_metrics --limit 2
ERROR (exc:65) exception: {
    "title": "The repository was unable to process your request",
    "description": "400: {\"error\":\"error parsing query: aggregate functions with GROUP BY time require a WHERE time clause\"}"
}
HTTPException code=500 message={
    "title": "The repository was unable to process your request",
    "description": "400: {\"error\":\"error parsing query: aggregate functions with GROUP BY time require a WHERE time clause\"}"
}

When i change the date to anything else, things work fine:

/opt/stack/ceilometer/ceilometer/storage$ monasca metric-statistics image.size max 1970-01-02 --merge_metrics --limit 2
+------------+------------+----------------------+--------------+
| name | dimensions | timestamp | max |
+------------+------------+----------------------+--------------+
| image.size | | 1970-01-02T00:00:00Z | 0.00 |
| | | 1970-01-02T00:05:00Z | 0.00 |
+------------+------------+----------------------+--------------+

The stack trace above is from the direct monasca api usage. It uses 1970-01-01 if no start datetimestamp is specified.

This is from the latest install

Revision history for this message
Ryan (ryan-brandt) wrote :

Thanks for the extra info! I found the problem. The fix can be found here https://review.openstack.org/#/c/255425/

Changed in monasca:
status: Incomplete → In Progress
importance: Undecided → Low
Ryan (ryan-brandt)
Changed in monasca:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.