[ZBX-23136] AWS EC2 template is not showing EBS volumes Created: 2023 Jul 21  Updated: 2024 Apr 10  Resolved: 2023 Oct 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 6.0.19
Fix Version/s: None

Type: Problem report Priority: Major
Reporter: Jiri Mikes Assignee: Alexander Bakaldin
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

AWS EC2 (over 100 instances), EBS volumes (over 500)


Attachments: PNG File image-2023-07-21-13-09-46-332.png     PNG File image-2023-07-21-13-14-05-999.png     PNG File image-2023-08-02-12-20-24-029.png     PNG File image-2023-08-02-12-21-03-652.png     PNG File image-2023-08-02-12-36-53-669.png     PNG File image-2023-08-02-12-38-17-184.png    
Team: Team INT

 Description   

Steps to reproduce:

  1. Download template AWS EC2 by HTTP
  2. Create API Key/secret in AWS, setup permissions
  3. Configure host in Zabbix (required macros)

Result:
Result converted to text: {"error":"TypeError: cannot read property 'item' of null."}
**

Expected:
Returned list of EBS volumes

Solution:
{}Remove this line from JavaScript:
{{}}

payload['MaxResults'] = 100,

By tests: AWS API is getting first 100 volumes, after this is applying filter on this result



 Comments   
Comment by Jiri Mikes [ 2023 Jul 21 ]

Part of Javascript before:

payload['Action'] = 'DescribeVolumes',
payload['Version'] = '2016-11-15',
payload['Filter.1.Name'] = 'attachment.instance-id',
payload['Filter.1.Value'] = AwsEbs.params.instance_id;

Part of Javascript after modification:

payload['Action'] = 'DescribeVolumes',
payload['MaxResults'] = 100,
payload['Version'] = '2016-11-15',
payload['Filter.1.Name'] = 'attachment.instance-id',
payload['Filter.1.Value'] = AwsEbs.params.instance_id;

Item: aws.ec2.get_volumes

Similar problem is in item: aws.ec2.get_alarms

Comment by Evgenii Gordymov [ 2023 Aug 02 ]

Hello, jirimikes!
What is the largest number of vol on one EC2?

I was unable to reproduce the issue in 6.0.19. 

1. Create AWS EC2 with 9 vol. 

2. Reduced the number to 5 in JS 

payload['MaxResults'] = 5 

Can you show the logs and the test result in the web interface

add this string in JS to see raw data

Zabbix.log(3, '[ AWS EBS ] VOL: ' + JSON.stringify(volumes)) 

example logs

 

 

 

Comment by Riaan Olivier [ 2023 Aug 23 ]

Please note that I spend allot of time with Amazon on this and found out that there documentation (DescribeVolumes - Amazon Elastic Compute Cloud) states the following:

nextToken

The token to include in another request to get the next page of items. This value is null when there are no more items to return.

 

This basically means that you need to loop until the nextToken is null. I have made an update to the code to accommodate this with the MaxResults still set to 100 and it returns the results correctly now. Please note that this is the way every AWS API works. I also fixed the fact that nextToken was spelled as NextToken in this loopkup:

volumes.DescribeVolumesResponse.nextToken

Reference to pull request that fixes this template

https://github.com/zabbix/zabbix/pull/108

Comment by Alexander Bakaldin [ 2023 Oct 03 ]

It was resolved during ZBXNEXT-8283.

Generated at Sat Apr 26 04:03:26 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.