Ceilometer API filters doesn't work with multiple same fields

asked 2016-08-08 06:35:00 -0500

Dmitri gravatar image

Dear all,

I want to receive a list of meters, which is filtered by several resource IDs. I use python ceilometer client for communication with ceilometer API. I followed examples from https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/ceilometer.py#L53-L69 (horizon code) and http://docs.openstack.org/developer/python-ceilometerclient/api.html#v2-client-tips (python ceilometer client documentation) to construct my filters, but they work differently from what I expect:

  1. When I filter a list of meters by one resource ID:

    filters = [
        {  
            'field':'resource_id',
            'value':'3ba0a362-d151-41d5-b97c-59a735a60948',
            'op':'eq'
        }
    ]
    ceilometer_client.meters.list(q=filters)
    

    then following query is constructed to the ceilometer API:

    /v2/meters?q.field=resource_id&q.op=eq&q.type=&q.value=3ba0a362-d151-41d5-b97c-59a735a60948
    

    and I get following response:

    [
        {
            'user_id':'7bf66cc5af8b401f90bf3ec0b3e7e947',
            'name':'volume.size',
            'resource_id':'3ba0a362-d151-41d5-b97c-59a735a60948',
            'source':'openstack',
            'meter_id':'M2JhMGEzNjItZDE1MS00MWQ1LWI5N2MtNTlhNzM1YTYwOTQ4K3ZvbHVtZS5zaXpl',
            'project_id':'437de1d2849e4f62a17edbb642f0726a',
            'type':'gauge',
            'unit':'GB'
        }
    ]
    
  2. When I apply same filter for the resource with ID: 541dfc7a-ffd1-4ece-9ffd-4219c85aac6a, I get similar response. However, when I try to apply filters for both resources, I get response only for the last resource in the filters list:

    filters = [  
        {  
            'field':'resource_id',
            'op':'eq',
            'value':'3ba0a362-d151-41d5-b97c-59a735a60948'
        },
        {  
            'field':'resource_id',
            'op':'eq',
            'value':'541dfc7a-ffd1-4ece-9ffd-4219c85aac6a'
        }
    ]
    ceilometer_client.meters.list(q=filters)
    

    then following query is constructed to the ceilometer API:

    /v2/meters?q.field=resource_id&q.field=resource_id&q.op=eq&q.op=eq&q.type=&q.type=&q.value=3ba0a362-d151-41d5-b97c-59a735a60948&q.value=541dfc7a-ffd1-4ece-9ffd-4219c85aac6a
    

    and I get following response:

    [
        {
            'user_id':'7bf66cc5af8b401f90bf3ec0b3e7e947',
            'name':'volume.size',
            'resource_id':'541dfc7a-ffd1-4ece-9ffd-4219c85aac6a',
            'source':'openstack',
            'meter_id':'NTQxZGZjN2EtZmZkMS00ZWNlLTlmZmQtNDIxOWM4NWFhYzZhK3ZvbHVtZS5zaXpl',
            'project_id':'437de1d2849e4f62a17edbb642f0726a',
            'type':'gauge',
            'unit':'GB'
       }
    ]
    

    I expect to get following response:

    [  
       {  
            'user_id':'7bf66cc5af8b401f90bf3ec0b3e7e947',
            'name':'volume.size',
            'resource_id':'3ba0a362-d151-41d5-b97c-59a735a60948',
            'source':'openstack',
            'meter_id':'M2JhMGEzNjItZDE1MS00MWQ1LWI5N2MtNTlhNzM1YTYwOTQ4K3ZvbHVtZS5zaXpl',
            'project_id':'437de1d2849e4f62a17edbb642f0726a',
            'type':'gauge',
            'unit':'GB'
       },
       {  
            'user_id':'7bf66cc5af8b401f90bf3ec0b3e7e947',
            'name':'volume.size',
            'resource_id':'541dfc7a-ffd1-4ece-9ffd-4219c85aac6a',
            'source':'openstack',
            'meter_id':'NTQxZGZjN2EtZmZkMS00ZWNlLTlmZmQtNDIxOWM4NWFhYzZhK3ZvbHVtZS5zaXpl',
            'project_id':'437de1d2849e4f62a17edbb642f0726a',
            'type':'gauge',
            'unit':'GB'
       }
    ]
    

My ceilometer version is 2.3.0.

My python ceilometer client version is 2.3.0.

This question is similar to the question posted https://ask.openstack.org/en/question/52937/how-to-create-query-filter-for-python-ceilometer-client/ (here).

edit retag flag offensive close merge delete