Skip to content

AWS EC2 AutoScaling monitoring Template

Daisuke Ikeda edited this page Aug 18, 2016 · 2 revisions

This is AWS EC2 AutoScaling monitoring Template.

AWS EC2 AutoScaling

Requirements

Operation has been confirmed under the following environments.

  • CentOS7.2 or Amazon Linux 2016.3
  • Python 2.7
  • boto3(AWS SDK for Python)
    • please install this module.(pip install boto3)
  • zabbix-api(Zabbix API library for Python) (https://pypi.python.org/pypi/zabbix-api)
    • please install this module.(pip install zabbix-api)
  • Zabbix 2.2 or 3.0

Architecture

How to use

Only 3 steps.

  1. Download and set a python script
  2. Import template
  3. Register hosts
  4. Set AutoScaling group Tag

1. Download and set a python script

Please download scripts/autoscaling_zabbix.py on your Zabbix Server (External Scripts directory). And please set exec permission to Zabbix Server user(default: zabbix).

2. Import template

Please import templates/3.0/autoscaling_template.xml at Zabbix WebGUI ([Configuration]->[Templates]->Import). (In case of Zabbix 2.2: templates/2.2/autoscaling_template.xml)

3. Register hosts

Please register Zabbix hosts for collectiong AutoScaling groups data.

  • Host name: any (e.g. AutoScaling)
  • Templates: Template AWS Auto Scaling
  • Macros:
    • {$REGION} : set AWS region name(e.g. ap-northeast-1)
    • {$KEY} : set AWS Access Key ID (e.g. AKI........)
    • {$SECRET} : set AWS Secret Access Key
    • {$PREFFER_IF} : set Which interface you want to regist as main interface (e.g. "Private" or "Public")[default: Private]
    • {$SET_MACRO} : set Flag if you want to set AWS credential information to macro of auto registered hosts (e.g. "False" or "True) [default: False]
    • {$ZBX_PASS} : set Zabbix API login password [default: zabbix]
    • {$ZBX_URL} : set Zabbix Dashboard URL [default: http://localhost/zabbix]
    • {$ZBX_USER} : set Zabbix API login username [default: Admin]

4. Set AutoScaling group Tag

This template can assign different monitoring templates for each AutoScaling groups.

Please set the following AutoScaing group tag.

  • Tag name: ZabbixTemplates
  • Tag value: Template AWS EC2,Template OS Linux (You can set multi templates separated by commas.)

Logic of auto regisered host

In case of scale out instances:

  • autosaling_zabbix.py regist all AutoScaling group information include EC2 instances info under the group.
  • In this time, discovered hosts are not set in Zabbix(in other words, New instances), this script regist Zabbix host for these instances that host name is InstanceId and host group is AutoScaling Group name.
  • Addition to assign templates according to the AutoScaling group tag setting.
  • host interface are set EC2 PrivateIP and PublicIP.

In case of scale in instances:

  • If EC2 instances are terminated, autoscaling_zabbix.py can detect these instance info.
  • And change status of hosts for these instances to "Disabled"