omni-lchen / zabbix-cloudwatch

71 stars 61 forks source link

Pushing SQS stats not working #6

Open glenheiberg opened 7 years ago

glenheiberg commented 7 years ago

I've had success with the other templates in pushing CloudFront statistics to Zabbix, but pushing of SQS statistics doesn't seem to work - the template items are never created from the discovery templates.

Trying to push SQS stats yields no usable information from the Zabbix server, even at DebugLevel=4, apart from noting that all the trapped events have failed.

Using zabbix_sender.printData() in zabbixCloudWatch.py yields the following which just re-confirms that the push has failed, but doesn't explain why.

{'host': 'localhost', 'value': 0.0, 'key': u'SQS.ApproximateNumberOfMessagesDelayed.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 5.0, 'key': u'SQS.ApproximateNumberOfMessagesNotVisible.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 0.0, 'key': u'SQS.ApproximateNumberOfMessagesVisible.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 0.0, 'key': u'SQS.NumberOfEmptyReceives.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 0.0, 'key': u'SQS.NumberOfMessagesDeleted.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 0.0, 'key': u'SQS.NumberOfMessagesReceived.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} {'host': 'localhost', 'value': 0.0, 'key': u'SQS.NumberOfMessagesSent.Average["aws_account_1","eu-west-1","production_core_services_medium"]', 'clock': 1478256240} Count: 7

Failures reported by zabbix when sending: {"data": [{"host": "localhost", "value": 0.0, "key": "SQS.ApproximateNumberOfMessagesDelayed.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 5.0, "key": "SQS.ApproximateNumberOfMessagesNotVisible.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 0.0, "key": "SQS.ApproximateNumberOfMessagesVisible.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 0.0, "key": "SQS.NumberOfEmptyReceives.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 0.0, "key": "SQS.NumberOfMessagesDeleted.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 0.0, "key": "SQS.NumberOfMessagesReceived.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}, {"host": "localhost", "value": 0.0, "key": "SQS.NumberOfMessagesSent.Average[\"aws_account_1\",\"eu-west-1\",\"production_core_services_medium\"]", "clock": 1478256240}], "request": "sender data"}

Environment: Ubuntu 14.04.5LTS, Python 2.7.6, Zabbix_server 3.2.0

omni-lchen commented 7 years ago

Please check you have correct macro settings on the zabbix host, {$COMPONENT_SQS}=production_core_services, {$AWS_ACCOUNT}=aws_account_1 {$AWS_REGION}=eu-west-1

glenheiberg commented 7 years ago

Thanks for the suggestion. I've already done so, but still get the same failures.

WeetA34 commented 6 years ago

Hello i had the same issue. item keys are stored in db directly with Macro names (ie. ${AWS_ACCOUNT}, ${AWS_REGION}) When you want to send data, you have to use ${AWS_ACCOUNT} instead of aws_account_1 and ${AWS_REGION) instead of eu-west-1 with zabbix_sender.

As written in https://www.zabbix.com/documentation/3.4/manual/config/items/itemtypes/trapper, Zabbix trapper process does not expand macros used in the item key in attempt to check corresponding item key existence for targeted host.

Rgds Stéphane

WeetA34 commented 6 years ago

Hi again

if you add:

Get aws account

        dict["{#AWS_ACCOUNT}"] = a
        # Get aws region
        dict["{#AWS_REGION}"] = r

in all getSQS* functions of awsLLD.py (seen in getSNSTopics function), you'll be able to use these LLD Macros instead of user Macros ($AWS_ACCOUNT and $AWS_REGION) in item key. So item keys stored in database will contain the real value instead of User Macros variable name then you can send data through zabbix_sender or zabbixCloudWatch.py.

Rgds Stéphane