Autoscaling with Aodh: create alarm missing paramenter: resource_id,...

Bug #1801755 reported by Vu Nguyen Duy (CBR09) on 2018-11-05
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

Hi all,
I've tried created aodh alarm to trigger senlin receiver "webhook", I followed official docs
But when I created aodh alarm it throw error:
aodh --debug alarm create --name cpu_hi --type gnocchi_resources_threshold --description 'instance running hot' --metric cpu_util --threshold 20.0 --comparison-operator gt --aggregation-method mean --granularity 300 --evaluation-periods 1 --alarm-action $ALRM_URL01 --repeat-actions False --query metadata.user_metadata.cluster_id=$MYCLUSTER_ID
usage: aodh alarm create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
                         [--max-width <integer>] [--fit-width] [--print-empty]
                         [--noindent] [--prefix PREFIX] --name <NAME> -t
                         <TYPE> [--project-id <PROJECT_ID>]
                         [--user-id <USER_ID>] [--description <DESCRIPTION>]
                         [--state <STATE>] [--severity <SEVERITY>]
                         [--enabled {True|False}]
                         [--alarm-action <Webhook URL>]
                         [--ok-action <Webhook URL>]
                         [--insufficient-data-action <Webhook URL>]
                         [--time-constraint <Time Constraint>]
                         [--repeat-actions {True|False}] [--query <QUERY>]
                         [--comparison-operator <OPERATOR>]
                         [--evaluation-periods <EVAL_PERIODS>]
                         [--threshold <THRESHOLD>] [--event-type <EVENT_TYPE>]
                         [--granularity <GRANULARITY>]
                         [--aggregation-method <AGGR_METHOD>]
                         [--metric <METRIC>] [--resource-type <RESOURCE_TYPE>]
                         [--resource-id <RESOURCE_ID>]
                         [--composite-rule <COMPOSITE_RULE>]
aodh alarm create: error: gnocchi_resources_threshold requires --metric, --threshold, --resource-id, --resource-type and --aggregation-method

It's seem missing resource_type and resource_id?, I can make it work if I specify a resource_type and a resource_id of a instance in cluster, but I want it work on all instances of my cluster, so how can I do that?, what do "--query metadata.user_metadata.cluster_id=$MYCLUSTER_ID" mean?, how can I fix that?


description: updated
description: updated

@Duc Truong: is there any information about that?

Chiawei Xie (dommgifer) wrote :

I've tried to use this command:

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 '{"=": {"metadata.user_metadata.cluster_id": "$MYCLUSTER_ID""}}'
--resource-type instance

But got error message:
Resource type instance has no metadata.user_metadata.cluster_id attribute (HTTP 400)

So, aodh created alarm type with gnocchi_aggregation_by_resources_threshold or gnocchi_resources_threshold
was not work.

Pavel (spa-87) wrote :

Hello, I didn't test the `cluster_id` metadata yet, but `server_group` works fine for me with rocky release.

In order to enable this field, you have to add metadata at a cluster profile:
  metering.server_group: $YOURCLUSTER_ID

Now you should be able to query `server_group` field:
'{"=": {"server_group": "$YOURCLUSTER_ID"}}'

None additional configs are required. Gnocchi has `server_group` filed for `instance` resource-type by default.

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):

    "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)

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

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

Jobin (haibinji) wrote :

You also need to configure the following in /etc/ceilometer/ceilometer.conf and restart the ceilometer service

reserved_metadata_keys = cluster_id

instance_discovery_method = naive

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers