|
| 1 | +========== |
| 2 | +CloudKitty |
| 3 | +========== |
| 4 | + |
| 5 | +Configuring in kayobe-config |
| 6 | +============================ |
| 7 | + |
| 8 | +By default, CloudKitty uses Gnocchi and Ceilometer as the collector and fetcher |
| 9 | +backends. Unless the system has a specific reason not to, we recommend instead |
| 10 | +using Prometheus as the backend for both. The following instructions explain |
| 11 | +how to do this. Also, see the `Kolla Ansible docs on CloudKitty |
| 12 | +<https://docs.openstack.org/kolla-ansible/latest/reference/rating/cloudkitty-guide.html>`__ |
| 13 | +for more details. |
| 14 | + |
| 15 | +Enable CloudKitty and disable InfluxDB, as we are using OpenSearch as the |
| 16 | +storage backend. Set the following in ``kolla.yml``: |
| 17 | + |
| 18 | +.. code-block:: yaml |
| 19 | +
|
| 20 | + kolla_enable_cloudkitty: true |
| 21 | + # Explicitly disable influxdb as we are using OpenSearch as the CloudKitty backend |
| 22 | + kolla_enable_influxdb: false |
| 23 | +
|
| 24 | +Set Prometheus as the backend for both the collector and fetcher, and |
| 25 | +Elasticsearch as the storage backend. Note that our fork of CloudKitty is |
| 26 | +patched so that the CloudKitty Elasticsearch V2 storage backend will also work |
| 27 | +with an OpenSearch cluster. Proper support for the V2 OpenSearch storage |
| 28 | +backend is still pending in Kolla-Ansible `here |
| 29 | +<https://review.opendev.org/c/openstack/kolla-ansible/+/898555>`__. Set the |
| 30 | +following in ``kolla/globals.yml``: |
| 31 | + |
| 32 | +.. code-block:: yaml |
| 33 | +
|
| 34 | + cloudkitty_collector_backend: prometheus |
| 35 | + cloudkitty_fetcher_backend: prometheus |
| 36 | + cloudkitty_storage_backend: elasticsearch |
| 37 | +
|
| 38 | +If you have TLS enabled, you will also need to set the cafile for Prometheus |
| 39 | +and Elasticsearch. Set the following in ``kolla/globals.yml``. |
| 40 | + |
| 41 | +.. code-block:: |
| 42 | +
|
| 43 | + {% raw %} |
| 44 | + cloudkitty_prometheus_cafile: "{{ openstack_cacert }}" |
| 45 | + cloudkitty_elasticsearch_cafile: "{{ openstack_cacert }}" |
| 46 | + {% endraw %} |
| 47 | +
|
| 48 | +The default collection period is one hour, which is likely too long for most |
| 49 | +systems as CloudKitty charges by the **entire** collection period if any usage |
| 50 | +is seen within this timeframe. This is regardless of actual usage, meaning that |
| 51 | +even one minute will be charged as a full hour's usage. As a result, it is |
| 52 | +recommended to adjust the collection interval, ``period`` (in units of |
| 53 | +seconds), appropriately (e.g. ten minutes). Furthermore, when using Prometheus |
| 54 | +as the collector, you need to change the ``scope_key`` to match the metrics |
| 55 | +provided by the Prometheus OpenStack Exporter. Both of these can be achieved by |
| 56 | +setting the following in ``kolla/config/cloudkitty.conf``: |
| 57 | + |
| 58 | +.. code-block:: console |
| 59 | +
|
| 60 | + [collect] |
| 61 | + scope_key = tenant_id |
| 62 | + period = 600 |
| 63 | +
|
| 64 | +You will need to configure which metrics CloudKitty should track. The following |
| 65 | +example, set in ``kolla/config/cloudkitty/metrics.yml``, will track for VM flavors and |
| 66 | +the total utilised volume. |
| 67 | + |
| 68 | +.. code-block:: yaml |
| 69 | +
|
| 70 | + metrics: |
| 71 | + openstack_nova_server_status: |
| 72 | + alt_name: instance |
| 73 | + groupby: |
| 74 | + - uuid |
| 75 | + - user_id |
| 76 | + - tenant_id |
| 77 | + metadata: |
| 78 | + - flavor_id |
| 79 | + - name |
| 80 | + mutate: MAP |
| 81 | + mutate_map: |
| 82 | + 0.0: 1.0 # ACTIVE |
| 83 | + 11.0: 1.0 # SHUTOFF |
| 84 | + 12.0: 1.0 # SUSPENDED |
| 85 | + 16.0: 1.0 # PAUSED |
| 86 | + unit: instance |
| 87 | + openstack_cinder_limits_volume_used_gb: |
| 88 | + alt_name: storage |
| 89 | + unit: GiB |
| 90 | + groupby: |
| 91 | + - tenant_id |
| 92 | +
|
| 93 | +If your system had Monasca deployed in the past, you likely have some |
| 94 | +relabelled attributes in the Prometheus OpenStack exporter. To account for |
| 95 | +this, you should either remove the custom relabelling (in |
| 96 | +``kolla/config/prometheus.yml``) or change your ``metrics.yml`` to use the |
| 97 | +correct attributes. |
| 98 | + |
| 99 | +Post-configuration with openstack-config |
| 100 | +======================================== |
| 101 | + |
| 102 | +This is an example `openstack-config |
| 103 | +<https://github.com/stackhpc/openstack-config>`__ setup to create mappings for |
| 104 | +the metrics configured above. Note that the costs are scaled for the ten minute |
| 105 | +collection period, e.g. a flavor with 1 VCPU will cost 1 unit per hour. |
| 106 | + |
| 107 | +.. code-block:: yaml |
| 108 | +
|
| 109 | + # Map flavors based on VCPUs |
| 110 | + openstack_ratings_hashmap_field_mappings: |
| 111 | + - service: instance |
| 112 | + name: flavor_id |
| 113 | + mappings: |
| 114 | + - value: '1' # tiny compute flavor (1 vcpu) with an OpenStack flavor ID of 1 |
| 115 | + cost: 0.1666666666666666 |
| 116 | + type: flat |
| 117 | + - value: '2' # small compute flavor (2 vcpus) with an OpenStack flavor ID of 2 |
| 118 | + cost: 0.3333333333333333 |
| 119 | + type: flat |
| 120 | + - value: '3' # medium compute flavor (3 vcpus) with an OpenStack flavor ID of 3 |
| 121 | + cost: 0.5 |
| 122 | + type: flat |
| 123 | + - value: '4' # large compute flavor (4 vcpus) with an OpenStack flavor ID of 4 |
| 124 | + cost: 0.6666666666666666 |
| 125 | + type: flat |
| 126 | + - value: '5' # xlarge compute flavor (8 vcpus) with an OpenStack flavor ID of 5 |
| 127 | + cost: 1.3333333333333333 |
| 128 | + type: flat |
| 129 | + - value: '6' # tiny 2 compute flavor (2 vcpus) with an OpenStack flavor ID of 6 |
| 130 | + cost: 0.3333333333333333 |
| 131 | + type: flat |
| 132 | +
|
| 133 | + # Map volumes based on GB |
| 134 | + openstack_ratings_hashmap_service_mappings: |
| 135 | + - service: storage |
| 136 | + cost: 0.16666666666666666 |
| 137 | + type: flat |
| 138 | +
|
| 139 | +See the `OpenStack CloudKitty Ratings role |
| 140 | +<https://github.com/stackhpc/ansible-collection-openstack/tree/main/roles/os_ratings>`__ |
| 141 | +for more details. |
0 commit comments