Could not retrieve Alarm History from UI

Bug #1653832 reported by Allan G
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Monasca
New
Undecided
James Gu

Bug Description

Tried to retrieve Alarm History from an ALARM via UI in a monasca-api vagrant@devstack env (built on MAC), this works fine from CLI for the same ALARM, see test details below error output.

Error: Could not retrieve alarm history for 806e6a30-b85d-4b5a-8f08-6cfb5f0c40ed

monasca-api.log file:
2017-01-03 22:55:49,613 ERROR [monasca_api.common.repositories.influxdb.metrics_repository][GreenThread-42] invalid operation: time and *influxql.StringLiteral are not compatible
2017-01-03 22:55:49,614 ERROR [monasca_api.v2.reference.resource][GreenThread-42] invalid operation: time and *influxql.StringLiteral are not compatible
2017-01-03 22:55:49,664 ERROR [monasca_api.common.repositories.influxdb.metrics_repository][GreenThread-38] invalid operation: time and *influxql.StringLiteral are not compatible
2017-01-03 22:55:49,665 ERROR [monasca_api.v2.reference.resource][GreenThread-38] invalid operation: time and *influxql.StringLiteral are not compatible

Test Details:
vagrant@devstack:/var/log/monasca/api$ monasca alarm-list
+--------------------------------------+--------------------------------------+-----------------------+---------------+---------------------+----------+-------+-----------------+------+-------------------------+----------------------+----------------------+
| id | alarm_definition_id | alarm_definition_name | metric_name | metric_dimensions | severity | state | lifecycle_state | link | state_updated_timestamp | updated_timestamp | created_timestamp |
+--------------------------------------+--------------------------------------+-----------------------+---------------+---------------------+----------+-------+-----------------+------+-------------------------+----------------------+----------------------+
| 806e6a30-b85d-4b5a-8f08-6cfb5f0c40ed | dfe91126-499e-4036-bc48-d2caa6903f70 | TEST | cpu.idle_perc | hostname: devstack | LOW | ALARM | None | None | 2017-01-03T22:42:54Z | 2017-01-03T22:42:54Z | 2017-01-03T22:42:53Z |
| | | | | service: monitoring | | | | | | | |
+--------------------------------------+--------------------------------------+-----------------------+---------------+---------------------+----------+-------+-----------------+------+-------------------------+----------------------+----------------------+
vagrant@devstack:/var/log/monasca/api$ monasca alarm-history 806e6a30-b85d-4b5a-8f08-6cfb5f0c40ed
+--------------------------------------+-----------+--------------+-----------------------------------------------------------------------------------------------+-------------+---------------+---------------------+--------------------------+
| alarm_id | new_state | old_state | reason | reason_data | metric_name | metric_dimensions | timestamp |
+--------------------------------------+-----------+--------------+-----------------------------------------------------------------------------------------------+-------------+---------------+---------------------+--------------------------+
| 806e6a30-b85d-4b5a-8f08-6cfb5f0c40ed | ALARM | UNDETERMINED | Thresholds were exceeded for the sub-alarms: max(cpu.idle_perc) > 0.0 with the values: [91.2] | {} | cpu.idle_perc | hostname: devstack | 2017-01-03T22:42:53.558Z |
| | | | | | | service: monitoring | |
+--------------------------------------+-----------+--------------+-----------------------------------------------------------------------------------------------+-------------+---------------+---------------------+--------------------------+

Revision history for this message
Allan G (greental) wrote :
Revision history for this message
James Gu (jamesgu) wrote :

there appears to be a sql qiery syntax issue with influxdb in /monasca-api/monasca_api/common/repositories/influxdb/metrics_repository.py:

 def _build_offset_clause(self, offset):

        if offset:
            offset_clause = " and time > '{}'".format(offset)
        else:
            offset_clause = ""

        return offset_clause

Removing the quote around the value of time offset fixed the issue in my devstack.

Will push for a fix if that makes sense. The question that I have -- is there a default offset value of zero? didn't see that in the UI>

Changed in monasca:
assignee: nobody → James Gu (jamesg2016)
Revision history for this message
James Gu (jamesgu) wrote :

the offset value was 0 in the test case. wondering what value is expected for the offet value, absolute epoch time or a timestamp, e.g., '2013-08-12 23:32:01.232' ?

Revision history for this message
James Gu (jamesgu) wrote :

now I am wondering why we are using "time" to get the offset? should we be using the "offset" influxdb key?

Revision history for this message
James Gu (jamesgu) wrote :

looks like most places in the code the offset is the time offset, not the count offset in the influxdb pagination.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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