get statistics do not work with postgresql database

Bug #1256318 reported by Vadim Rovachev
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
High
gordon chung
Icehouse
Fix Released
High
Dirk Mueller

Bug Description

Steps to reproduce:
1. Install devstack with postgresql database
2. Configure ceilometer to using postgresql
3. Get meter list(200 OK)
4. Get statistics for any meters(By example: vcpus).
   Expected result: 200 OK
   Actual result:
Status: 500
Body:
{"error_message": {"debuginfo": null, "faultcode": "Server", "faultstring": "(ProgrammingError) column \"meter.counter_unit\" must appear in the GROUP BY clause or be used in an aggregate function\nLINE 1: SELECT meter.counter_unit AS unit, min(meter.timestamp) AS t...\n ^\n 'SELECT meter.counter_unit AS unit, min(meter.timestamp) AS tsmin, max(meter.timestamp) AS tsmax, avg(meter.counter_volume) AS avg, sum(meter.counter_volume) AS sum, min(meter.counter_volume) AS min, max(meter.counter_volume) AS max, count(meter.counter_volume) AS count \\nFROM meter \\nWHERE meter.counter_name = %(counter_name_1)s' {'counter_name_1': 'vcpus'}"}}

=====================================================
Stacktrace(in ceilometer-api log):
=====================================================
2013-11-28 12:42:22.639 23577 ERROR wsme.api [-] Server-side error: "(ProgrammingError) column "meter.counter_unit" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT meter.counter_unit AS unit, min(meter.timestamp) AS t...
               ^
 'SELECT meter.counter_unit AS unit, min(meter.timestamp) AS tsmin, max(meter.timestamp) AS tsmax, avg(meter.counter_volume) AS avg, sum(meter.counter_volume) AS sum, min(meter.counter_volume) AS min, max(meter.counter_volume) AS max, count(meter.counter_volume) AS count \nFROM meter \nWHERE meter.counter_name = %(counter_name_1)s' {'counter_name_1': 'vcpus'}". Detail:
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/wsmeext/pecan.py", line 77, in callfunction
    result = f(self, *args, **kwargs)

  File "/opt/stack/new/ceilometer/ceilometer/api/controllers/v2.py", line 816, in statistics
    for c in computed]

  File "/opt/stack/new/ceilometer/ceilometer/storage/impl_sqlalchemy.py", line 611, in get_meter_statistics
    for res in self._make_stats_query(sample_filter, groupby):

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2227, in __iter__
    return self._execute_and_instances(context)

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2242, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute
    params)

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
    compiled_sql, distilled_params

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
    context)

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
    context)

  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 331, in do_execute
    cursor.execute(statement, parameters)

ProgrammingError: (ProgrammingError) column "meter.counter_unit" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT meter.counter_unit AS unit, min(meter.timestamp) AS t...
               ^
 'SELECT meter.counter_unit AS unit, min(meter.timestamp) AS tsmin, max(meter.timestamp) AS tsmax, avg(meter.counter_volume) AS avg, sum(meter.counter_volume) AS sum, min(meter.counter_volume) AS min, max(meter.counter_volume) AS max, count(meter.counter_volume) AS count \nFROM meter \nWHERE meter.counter_name = %(counter_name_1)s' {'counter_name_1': 'vcpus'}

localhost - - [28/Nov/2013 12:42:22] "GET /v2/meters/vcpus/statistics HTTP/1.1" 500 136

Ilya Tyaptin (ityaptin)
Changed in ceilometer:
assignee: nobody → Ilya Tyaptin (ityaptin)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/59204

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/59214

Changed in ceilometer:
assignee: Ilya Tyaptin (ityaptin) → Alexei Kornienko (alexei-kornienko)
Eoghan Glynn (eglynn)
tags: added: havana-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/86399

Changed in ceilometer:
assignee: Alexei Kornienko (alexei-kornienko) → gordon chung (chungg)
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/86399
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=551bbbb0dff43d22d7cca7826af1b3ef5868168b
Submitter: Jenkins
Branch: master

commit 551bbbb0dff43d22d7cca7826af1b3ef5868168b
Author: Gordon Chung <email address hidden>
Date: Wed Apr 9 13:01:50 2014 -0400

    fix statistics query in postgres

    when aggregate functions present, postgres requires all
    non-aggregate columns selected to be included in group by clause
    to ensure a single value is selected.

    Change-Id: Iccbcd8046cca872e8eba472f48fa392114f34426
    Closes-Bug: #1256318

Changed in ceilometer:
status: In Progress → Fix Committed
Eoghan Glynn (eglynn)
Changed in ceilometer:
importance: Undecided → High
milestone: none → juno-1
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/114275

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (stable/icehouse)

Reviewed: https://review.openstack.org/114275
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=0ba75c8711341ddd4beac19b287c3c1f6ac0f3e0
Submitter: Jenkins
Branch: stable/icehouse

commit 0ba75c8711341ddd4beac19b287c3c1f6ac0f3e0
Author: Gordon Chung <email address hidden>
Date: Wed Apr 9 13:01:50 2014 -0400

    fix statistics query in postgres

    when aggregate functions present, postgres requires all
    non-aggregate columns selected to be included in group by clause
    to ensure a single value is selected.

    Change-Id: Iccbcd8046cca872e8eba472f48fa392114f34426
    Closes-Bug: #1256318
    (cherry picked from commit 551bbbb0dff43d22d7cca7826af1b3ef5868168b)

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: juno-1 → 2014.2
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.