Bug 988362

Summary: [RFE] POST API for metering samples
Product: Red Hat OpenStack Reporter: Eoghan Glynn <eglynn>
Component: openstack-ceilometerAssignee: Eoghan Glynn <eglynn>
Status: CLOSED ERRATA QA Contact: Kevin Whitney <kwhitney>
Severity: high Docs Contact:
Priority: low    
Version: 4.0CC: ajeain, breeler, eglynn, hateya, jruzicka, mlopes, pbrady, sgordon, srevivo, yeylon
Target Milestone: Upstream M1Keywords: FutureFeature, OtherQA
Target Release: 4.0   
Hardware: Unspecified   
OS: Unspecified   
URL: https://blueprints.launchpad.net/ceilometer/+spec/meter-post-api
Whiteboard:
Fixed In Version: openstack-ceilometer-2013.2-0.2.b1.el6ost Doc Type: Enhancement
Doc Text:
A public RESTful API to accept incoming sample datapoints has been added to OpenStack Metering. This was required because it is often more convenient for user-level agents to emit statistics to Ceilometer via a public API, than to gain access to the AMQP bus. Now, samples may be POSTed to the "/v2/meters/<meter_name>" endpoint.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-20 00:15:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 973191, 975499, 1055813    

Description Eoghan Glynn 2013-07-25 12:02:47 UTC
Allow metering samples to be submitted directly to the ceilometer-api via a RESTful interface (as opposed to everything being collected over AMQP).  

Upstream blueprint: https://blueprints.launchpad.net/ceilometer/+spec/meter-post-api

Comment 3 Ami Jeain 2013-11-21 13:14:29 UTC
Heat and Ceilometer tests will be performed mainly by Dev

Comment 5 Eoghan Glynn 2013-12-09 15:47:42 UTC
How To Test
===========

0. Install packstack allinone in the usual way.


1. Submit a sequence of samples for a fabricated meter:

  for i in $(seq 5)
  do
    ceilometer sample-create -r foobar -m instance_likes \
      --meter-type delta --meter-unit thumbs_up --sample-volume $i \
      --resource-metadata '{"image_id": "cirros", "vcpus": "1", "display_name": "test_server", "ram": "512"}' \
      --timestamp $(date -u +"%Y-%m-%dT%H:%M:%SZ")
    sleep 1
  done


2. Ensure that the samples are all reported correctly:

   ceilometer sample-list -m instance_likes

   The correct number of samples should be reported, with the volumes in descending order.


3. Ensure that samples are aggregated as expected:

   ceilometer statistics ceilometer sample-list -m instance_likes

   Check that the aggregates reported are sane:

     count: 5
     min:   1
     max:   5
     sum:   sigma n (n <= 5)
     avg:   3


4. Ensure that the project and user IDs for the submitted samples can only be set to another indentity by admin:

  export OS_USERNAME=demo
  export OS_TENANT_NAME=demo
  export OS_PASSWORD=<DEMO_PASSWORD>

  ceilometer --debug sample-create -r foobar -m instance_likes \
    --meter-type delta --meter-unit thumbs_up --sample-volume 6 \
    --resource-metadata '{"image_id": "cirros", "vcpus": "1", "display_name": "test_server", "ram": "512"}' \
    --timestamp $(date -u +"%Y-%m-%dT%H:%M:%SZ") \
    --project-id foo --user-id bar

  Should fail with:
 
  ...
  {"error_message": {"debuginfo": null, "faultcode": "Client", "faultstring": "Invalid input for field/attribute project_id. Value: 'project_id'. can not post samples to other projects"}}

  WARNING (http:172) Request returned failure status.
  HTTPBadRequest (HTTP 400)

Comment 9 errata-xmlrpc 2013-12-20 00:15:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2013-1859.html