wawastein / zabbix-cloudwatch

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

Support for Tags #18

Open ddpana opened 5 years ago

ddpana commented 5 years ago

Hello, Thank you for your great work! I would like to be able to monitor only resources with specified tags (e.g. Monitoring=True). If you have over 100 resources, and you don't want to get alerts for most of them, you want to filter resources by tags. I succeeded to do that for EC2 and for RDS, but for ELBv2 for example it's a bit harder, because you need to get the resources from resourcegroupstaggingapi first, to get the ARN of all loadbalancers by tags, and after that, get the resources from elbv2 api.

Can I ask to add the possibility to discover only the resources based on the tags ?

sherrerq commented 4 years ago

Hello @ddpana,

Could you make some advances in our research? I am interested in.

sherrerq commented 4 years ago

Good morning,

I know how to get AWS resources filtered by tag. These are the commands and outputs:

aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=xxxxx --resource-type-filters ec2:instance --tags-per-page 100

{ "ResourceTagMappingList": [ {

        "ResourceARN": "arn:aws:ec2:eu-west-1:xxxxxxxxxx:instance/i-xxxxxxxxx",
        "Tags": [
            {
                "Key": "Environment",
                "Value": "xxxxxx"
            },
            {
                "Key": "Name",
                "Value": "xxxxxxxxx"
            },
            {
                "Key": "Project",
                "Value": "xxxxxx"
            }

        ]
    }

}

aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=name --resource-type-filters rds:cluser --tags-per-page 100

{ "ResourceTagMappingList": [ { "ResourceARN": "arn:aws:rds:eu-west-1:xxxxxxxx:cluster:cluster-xxxxxxxx", "Tags": [ { "Key": "Environment", "Value": "xxxxxxxxx" }, { "Key": "Name", "Value": "xxxxxxxxxxx" }, { "Key": "Project", "Value": "xxxxx" }

        ]
    }

} aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=name --resource-type-filters rds:db --tags-per-page 100 { "ResourceTagMappingList": [ { "ResourceARN": "arn:aws:rds:eu-west-1:xxxxxxx:db:xxxxxxxxxx", "Tags": [ { "Key": "Environment", "Value": "xxxxxxx" }, { "Key": "Name", "Value": "xxxxxxxx" }, { "Key": "Project", "Value": "xxxxxxx" } ] }

}

aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=name --resource-type-filters s3 --tags-per-page 100 { "ResourceTagMappingList": [ { "ResourceARN": "arn:aws:s3:::xxxxxx", "Tags": [ { "Key": "Environment", "Value": "xxxxx" }, { "Key": "Project", "Value": "xxxxx" }, { "Key": "Role", "Value": "xxxxx" } ] } ] }

aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=name --resource-type-filters elasticloadbalancing --tags-per-page 100 { "ResourceTagMappingList": [ { "ResourceARN": "arn:aws:elasticloadbalancing:eu-west-1:xxxxxxxxxxx:loadbalancer/app/xxxxxxxxxxxxx/xxxxxxxxx", "Tags": [ { "Key": "Environment", "Value": "xxxxxxxxxx" }, { "Key": "Project", "Value": "xxxxxxx" } ] } }

What I would like is to integrate it in discover scripts and somehow convert the tag called "Project" in a Host Group. Thanks to that, we can filter in Monitoring/latest data by the project using the field "Host groups" Any ideas?

diegosainz commented 4 years ago

Hi @sherrerq and @ddpana,

After a quick look on this it seems that a way to do it is to implement host prototypes (check docs) but this would create the hosts alongside with the groups. It is mainly intended for virtual machines, but might be adapted to something like this.

Another approach is to write a completely independent script that uses the Zabbix API to assign groups to the existing hosts directly.

Anyway, I won't be able to help on this one, it is far from what I'm actively using and don't have the setup to implement it/test it.

sherrerq commented 4 years ago

Hello @ddpana ! Did you manage to discover by tag?

Regards

backaf commented 4 years ago

I would be interesting in this as well because I have a Batch processing cluster in my environment so these hosts are also discovered and I end up with a lot of discovered EC2 hosts and triggers which are only relevant for app servers.