wojciecholesiejuk / icinga2-aws-multi-account-instance-discovery

6 stars 0 forks source link

not importing machines #3

Open Omermiz opened 7 years ago

Omermiz commented 7 years ago

Hi, I cannot understand how this works. I copied the config_example.json to config.json, edited it how it should be, and i cannot get any machine when running the script. this is my config:

"info":{
    "name": "configuration file for icinga2-multi-aws module",
    "description": "includes settings for the module"
},
"settings":{
    "hosts_files_location": "/etc/icinga2/conf.d/",
    "hosts_files_location_comment": "### location of the icinga2 conf.d folder",
    "check_frequency": "5",
    "check_frequency_comment": "### how ofter to retrieva a list of aws instances in minutes",
    "install_crontab": "true",
    "install_crontab_comment": "### crontab installation for automated check",
    "all_aws_regions": ["us-east-1", "us-east-2", "us-west-1", "us-west-2", "ap-south-1","ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "eu-central-1", "eu-west-1", "sa-east-1"],
    "all_aws_regions_comment": "### List of aws regions to look up the instances in"
},
"aws_accounts":{
    "myaccount": {
        "comment": "myaccount",
        "regions": ["us-west-2"],
        "regions_comment": "### list of aws regions for this account, if specified, search will be limited to those, and all_aws_regions will be ignored",
        "access_key": "***",
        "access_key_comment": "### aws access key",
        "secret_access_key": "***",
        "secret_access_key_comment": "### secret_access_key",
        "add_host_tag": "Env",
        "add_host_tag": "### name of aws tag key that will enable the host to be added to icinga2",
        "terminated_instances_queue": "https://sqs.us-west-2.amazonaws.com/4013/terminated-ec2-instances",
        "terminated_instances_queue_comment": "SQS Queue to lookup removed EC2 instances",
        "ignore": "false",
        "ignore_comment": "setting to true will ignore adding instances from this account, usefull for testing, changes etc."
    }
}

}

wojciecholesiejuk commented 7 years ago

Hi, you need to set up a cron job running "python icinga2_multi_aws.py" in the required frequency or just run this manually to get some output. This will gather AWS inventory and insert new hosts to Icinga2 and will remove the hosts corresponding to terminated EC2 instances. Script requires icingacli installed in order to run. If you have any output from the script, please post it here and I can review.

Omermiz commented 7 years ago

now this is my output. root@monitor:/srv/icinga2-aws-multi-account-instance-discovery# python icinga2_multi_aws.py {u'': [{'ImageId': 'ami-****', 'InstanceId': 'i-', 'InstanceType': 'r3.large', 'KeyName': '*', 'PublicDnsName': 'ec2----.us-west-2.compute.amazonaws.com', 'PublicIpAddress': '...', 'Tags': [{u'Key': 'Env', u'Value': 'QA'}, {u'Key': 'Name', u'Value': '*'}, {u'Key': 'Environment', u'Value': 'Production'}]}]} Host 'i-***' does not exist ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Objects/IcingaObjectGroups.php:192 with message: The group "aws-" doesn't exists. added node i-

wojciecholesiejuk commented 7 years ago

I do apologize, probably the config isn't rich enough and description for it as well. In the code you have "groups": [ "aws-" + account ], which mean, the script expects "aws-myaccount" host group created in icinga, and fails when it isn't found...

Omermiz commented 7 years ago

I understand. Thank you im trying to fix it now.