<div dir="ltr">Hello CloudKitters!<br><br>It was a great opportunity to be able to present this talk for you all guys. It was a pleasure to see that so many people are interested in CloudKitty, Ceilometer, and Gnocchi. I really hope that we can all collaborate together to keep improving CloudKitty, and other related systems.<br><br>Attached is the presentation we used during the presentation, so you all can consult this material. Also, as always, if you need some guidance, let us know.<br><br>Furthermore, as I mentioned in the presentation, I will provide a step-by-step process on how to create a new metric using Ceilometer Dynamic pollster that can collect/generate/derive (however you want to call it) IOPs information for volumes. The new metric name is going to be called "dynamic_pollster.volume.services.volume.iops". Also, the idea is that we collect some attributes, and we use the attribute called "bootable", which indicates if the volume is bootable or not. Then, if the volume is bootable, we will charge for its IOPS; otherwise, we do not charge it. As I mentioned, this is just a very simple use case. It is not targeting anyone's need in production, but it can be used to get you going quite easily with the pipeline.<br><br>Requirements:<br><ul><li>Ceilometer up and running. Version 15.0.0 (or higher is recommended);</li><li>Gnocchi up and running.  Version 4.3.0 (or higher). If you want to run this in production, this patch might be very important (<a href="https://github.com/gnocchixyz/gnocchi/pull/1059">https://github.com/gnocchixyz/gnocchi/pull/1059</a>); it has not been merged yet;</li><li>CloudKitty up and running. Version 10.0.0 (or higher).</li></ul><br>With all systems up and running, you will need to do the following:<br><ul><li>Ceilometer</li></ul><ul><ul><li>Add the new metric collection in the "polling.yaml" file. You can add it in any of the sections you already have there. Or, you can create its own, as follows:</li></ul></ul><div style="margin-left:120px">```<br>    - name: volume_iops_metric<br>      interval: 600<br>      meters:<br>        - dynamic_pollster.volume.services.volume.iops<br>```</div><ul><ul><li>After declaring the metrics there, you can create the pollster in the 
"pollster.d" folder in Ceilometer. The name of the file can be anything,
 as long as it ends with ".yaml"; for instance, 
"pollsters.d/volume-iops.yaml". Then, you will need to add the following
 content. Remember to replace the contents of "<>" with the values
 of your environment.  <br><br>```<br>- name: "dynamic_pollster.volume.services.volume.iops"<br>  response_entries_key: "volumes"<br> 
 next_sample_url_attribute: "volumes_links | filter(lambda v: 
v.get('rel') == 'next', value) | list(value) | value[0] | 
value.get('href')"<br>  sample_type: "gauge"<br>  unit: "GB"<br>  value_attribute: "volume_type"<br>  endpoint_type: "volume"<br>  url_path: "/v3/<SERVICE_UUID_FOR_CEILOMETER_USER>/volumes/detail?all_tenants=true&limit=10"<br>  headers:<br>    "Openstack-API-Version": "latest"<br>  project_id_attribute: "os-vol-tenant-attr:tenant_id"<br>  metadata_fields:<br>    - "status"<br>    - "name"<br>    - "volume_type"<br>    - "availability_zone"<br>    - "user_id"<br>    - "bootable | str(value)"<br>    - "attachments | value or [ { 'server_id': '' } ] | value[0] | value['server_id']"<br>  metadata_mapping:<br>    "availability_zone": "dynamic_availability_zone"<br>    "name": "dynamic_display_name"<br>    "volume_type": "dynamic_volume_type"<br>    "attachments | value or [{ 'server_id': '' }] | value[0] | value['server_id']": "dynamic_instance_id"<br>    "bootable | str(value)": "bootable"<br>  value_mapping:<br>    "<VOLUME_TYPE_UUID_OR_VOLUME_TYPE_NAME>": "<THE IOPS THAT THIS VOLUME TYPE REPRESENTS>"<br><br>``` <br><br><br></li><li>After creating that, you will need to customize the file "gnocchi_resources.yaml", which is the file that maps metrics to resources, and attributes that are pushed to the backend. You can also create your own "gnocchi_resources.yaml" file, and then use it in the pipeline configuration in the "pipeline.yaml" file, in the configuration of "publishers". Then, you would have something like "gnocchi://?resources_definition_file=%2Fetc%2Fceilometer%2Fcustom_gnocchi_resources.yaml", assuming the file is called "custom_gnocchi_resources.yaml". In this file, you will need to add the new metric and attribute to be pushed to the metrics backend. The following is an example of "volume" resource declaration in the "gnocchi_resource.yaml" file with the new metric and attribute that we want to capture.<br><br> ```<br>  - resource_type: volume<br>    metrics:<br><MANY OTHER METRICS HERE><br>      dynamic_pollster.volume.services.volume.iops:<br>    attributes:<br>      display_name: resource_metadata.(dynamic_display_name|notification_display_name)<br>      bootable: resource_metadata.bootable<br><MANY OTHER ENTRIES HERE><br>   <br>``` <br><br></li><li>After the above configuration, you will need to create the new attribute in the Gnocchi resource type. To achieve that, you can issue the following command.<br> ```<br>gnocchi resource-type update -a bootable:string:false volume<br>```</li><li>Then, you will need to restart the Ceilometer.</li><li>Now, you can issue "gnocchi resource show <VOLUME ID>", and you should see the new metric in the resource, and the new attribute as well.<br><br></li></ul></ul>With Ceilometer and Gnocchi configured for the new metric, we can move on to CloudKitty.<br><div><ul><li>The new metric needs to be declared in the "metrics.yml" file. The content should be something similar to the following (adapt as you need).<br> <br>```<br>  dynamic_pollster.volume.services.volume.iops:<br>    unit: IOPS<br>    alt_name: disk-volume-iops-usage-hours<br>    groupby:<br>      - id<br>      - user_id<br>      - project_id<br>      - volume_type<br>      - display_name<br>      - revision_start<br>      - instance_id<br>      - availability_zone<br>      - bootable<br>    metadata: []<br>    extra_args:<br>      aggregation_method: max<br>      resource_type: volume<br>      use_all_resource_revisions: false<br>```</li><li>Restart CloudKitty processor<br></li><li>With the new metric introduced in CloudKitty processor, you will need to create the rating configuration. In our case, we wanted to rate the volumes marked as bootable for IOPs. The volumes that are not bootable would not be rated. The following are the steps one needs to execute to create the hashmap rating rules.</li><ul><li>Create the service<br> ```<br>openstack rating hashmap service create disk-volume-iops-usage-hours<br>```</li><li>Then, create the field<br> ```<br>openstack rating hashmap field create <SERVICE_ID> <FIELD NAME WE WANT TO RATE, IN OUR CASE, IT IS bootable><br>```</li><li>After that, we can create the rating rule<br> ```<br>openstack rating hashmap mapping  create --field <FIELD UUID THAT WE CREATE> --value 'true' 1 --type flat<br>``` </li><li>Having done that, you should be able to rate all volumes by IOPS if they have the flag "bootable" set to true. Otherwise, they will not be rated.<br></li></ul></ul><br>That is all that one needs to execute to replicate the example I showed during the presentation. If you guys have any doubts or difficulties when using CloudKitty, do not hesitate to ping me.</div><div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Rafael Weingärtner</div></div></div></div>