This expression does the trick:

 

```

value_attribute: ". | value['usage'] | value.get('rgw.main', {'size':0}) | value['size']"

```

 

Thanks !

 

JF

 

From: Rafael Weingärtner <rafaelweingartner@gmail.com>
Sent: jeudi, 13 octobre 2022 13:41
To: Taltavull Jean-François <jean-francois.taltavull@elca.ch>
Cc: openstack-discuss <openstack-discuss@lists.openstack.org>
Subject: Re: [Ceilometer] Dynamic pollsters : dot in JSON keyname

 

 

EXTERNAL MESSAGE - This email comes from outside ELCA companies.

In such cases, you need to use the "Dynamic pollsters operations" to process the sample, and retrieve the key as "rgw.main.size". By default, this value ("rgw.main.size") is interpreted as a nested dictionary. I mean, an object with a key "rgw", and then, another one that has a key "main", where there is a dict, with a key "size".

 

To handle such cases, you would need something similar to: `value_attribute: "usage || value['rgw.main'] | value['size']"`. However, that might not address all use cases. You will also need to handle situations when there is no key "rgw.main" in the response samples.

 

On Wed, Oct 12, 2022 at 12:17 PM Taltavull Jean-François <jean-francois.taltavull@elca.ch> wrote:

Hello Rafael,

To get the the size, in GB, occupied by buckets I need to manipulate a JSON key which contains a dot in its name:

````
- name: "radosgw.containers.objects.size"
  sample_type: "gauge"
  unit: "B"
  value_attribute: "rgw.main.size"  <------------------------------------"rgw.main" is a JSON key, with a dot in its name, which belongs to "bucket.usage" JSON container
  url_path: "http://FQDN/admin/bucket?stats=True"
  module: "awsauth"
  authentication_object: "S3Auth"
  authentication_parameters: my_access_key,my_secret_key,FQDN
  user_id_attribute: "owner"
  project_id_attribute: "tenant"
  resource_id_attribute: "id"
  response_entries_key: "usage"
````

But with this dynamic pollster definition, I get the python error "KeyError: 'rgw' ".

In this case, is there a specific syntax to define "value_attribute" or am I doing something the wrong way ?


Jean-Francois



--

Rafael Weingärtner