wawastein / zabbix-cloudwatch

Cloudwatch integration for Zabbix 3.x
GNU General Public License v3.0
33 stars 53 forks source link

Receiving negative values #1

Closed dartua closed 7 years ago

dartua commented 7 years ago

Hi, You did a great job. Many thanks! But there is a problem, I receiving negative values -1 instead of 0.

image

wawastein commented 7 years ago

Hi, If you look into code, you'll see this: # Return -1 if there are no datapoints It's the only case script returns a negative. In your case I'd play with time period setting. Try running script manually, passing different period parameters. Use --debug switch to see Boto3 request response. Debugging example is described at the very end of blog entry here: https://awawastuff.wordpress.com/2017/04/13/zabbix-and-cloudwatch-integration/

wawastein commented 7 years ago

Hey @dartua, did my advice help?

dartua commented 7 years ago

Hi, well, yes maybe you are right. But in the same time I use another script with the same time period of 1m, the script gives me correct values. I noticed that in case if we have no data we get "-1", but in fact we should get "0". As for me, it would be more convenient.

wawastein commented 7 years ago

@dartua it might be depending on what that other script internally uses. I use boto3 and don't modify the time period which is passed to script. My practice says it's better to pass 2x normal period to script to ensure you get at least 1 datapoint. I've seen people go for normal period + 2 mins, so this is the option. I chose not to do any implicit modification of time period inside code, so user can open zabbix and see exactly what is passed, so (s)he can use same settings in AWS CLI for example, and get same result.

As to why -1 is returned if no datapoints are present: 0 in this case would indicate that script received valid response from AWS and metric result was 0. And this is simply not the case, it can be misleading. Not having datapoints in response can be indicative of some problems with your AWS resource, or with AWS itself. I had a situation when Cloudwatch didn't return any data for one of services for about 12 hrs. Knowing that was useful.

In your case I'd advise to simply change item's data type from Int to Float (this will make -1 a suitable data for item), increase time period to 2x what you have now (since 2 mins instead of 1 isn't much of a change) and if you'd like to track it, add trigger of "information" severity level in case item returns -1, like it's done in "EC2: No datapoints for {#NAME}" trigger in basic template which ships with this code. Or you might just ignore this case of -1 then.

dartua commented 7 years ago

@wawastein Ok. I got it. Thanks for you help.