Comment 4 for bug 1801755

Revision history for this message
Chiawei Xie (dommgifer) wrote :

If want to used clusetr_id,
here was my step:

1. Add gnocchi resource-type instance with cluster_id attributes(I used gnocchi API):
https://gnocchi.xyz/rest.html#id21

Body:
[
 {
    "op": "add",
    "path": "/attributes/cluster_id",
    "value": {
     "type": "string",
     "min_length": 0,
     "max_length": 255,
     "required": false
  }
 }
]

2. Modify ceilometer gnocchi_resources.yaml (ceilometer/publisher/data/gnocchi_resources.yaml)
https://github.com/openstack/ceilometer/blob/master/ceilometer/publisher/data/gnocchi_resources.yaml#L111

Under the server_group, add this line:
cluster_id: resource_metadata.user_metadata.cluster_id

3. Restart ceilometer service (Both controller and compute)

4. Modify aodh rest.py(aodh/notifier/rest.py)
https://github.com/openstack/aodh/blob/master/aodh/notifier/rest.py#L79

Under the headers['content-type'] , add this line:
headers['openstack-api-version'] = 'clustering 1.10'

5. Restart aodh service

6. create aodh alarm:

aodh alarm create \
--type gnocchi_aggregation_by_resources_threshold \
--name cpu-high \
--metric cpu_util \
--threshold 70 \
--comparison-operator gt \
--description 'instance running hot' \
 --evaluation-periods 1 \
--aggregation-method mean \
--alarm-action $ALRM_URL01 \
--granularity 60 \
--repeat-actions False \
--query '{"=": {"cluster_id": "$MYCLUSTER_ID""}}' \
--resource-type instance