Collectors are plugins responsible for gathering resource information from remote API’s, such as the AWS or GCP APIs.
Probator ships with AWS collectors built-in, but its relatively trivial to implement your own collectors as well. To write your own
collector, you’ll need to implement the BaseCollector
class, which is documented in more details below.
The base collector will require you to implement a number of attributes and methods on your class.
name
- string attributens
- string attributetype
- CollectorType
attributeinterval
- integer attributeoptions
- ConfigOption
list of attributerun
- methodThis is the human-readable name of the collector, for example MyResourceCollector
.
The configuration namespace where the settings for the plugin is created, if applicable. The namespace should use a valid python variable
identifier, so it should not contain any spaces or non-ASCII characters and you should use snake_case
for the namespace.
It’s also considered best practices to prefix the namespace with the plugin type. If our collector is called MyResourceCollector
we
would make the namespace collector_my_resource
.
The type of collector you are creating, which must be one of the probator.constants:CollectorType
values. If you use any other type, the
collector will be loaded but never executed.
The currently supported collector types are:
CollectorType.GLOBAL
CollectorType.AWS_REGION
CollectorType.AWS_ACCOUNT
This setting controls how frequently the collector is executed, in minutes
If supplied, contains a list of all the configuration options for the plugin. The core framework automatically adds any missing configuration
items on startup. The options
variable must contain a list of probator.constants:ConfigOption
objects.
The run
method is the entry-point for the collector, however the method signature varies slightly based on the type of collector you are
writing.
CollectorType | Signature | Arguments |
---|---|---|
GLOBAL | run()
|
No arguments |
AWS_ACCOUNT | run(account)
|
account - An instance of AWSAccount object |
AWS_REGION | run(account, region)
|
account - An instance of AWSAccount<br> region - Name of the region to collect from |
The AWS Collector is the backbone of the core framework and it is shipped as part of the core framework and not a standalone plugin. All collectors are subclasses of the Base Collector
This is actually a collection of many individual collector plugins, one for each type of resource that is being collected. There are two base types of collectors for AWS
The AWS Account Collectors are responsible for collecting resources that are not specific to a given AWS region. Below is a list of the currently implemented account wide collectors:
Collector Class | Resources collected |
---|---|
AWSBaseAccountCollector |
The base collector that all account collectors must be a subclass of |
AWSRoute53Collector |
Route53 zones and records |
AWSS3Collector |
S3 Buckets |
AWSCloudFrontCollector |
CloudFront distributions |
AWSIAMUserCollector |
IAM Users and Access Keys |
The AWS Region collectors collect resources only within the provided region. The list below shows what collectors are shipped as part of the core framework:
Collector Class | Resources collected |
---|---|
AWSEC2InstanceCollector |
EC2 Instances |
AWSEBSVolumeCollector |
EBS Volumes |
AWSEBSSnapshotCollector |
EBS Snapshots |
AWSAMICollector |
Amazon Machine Images (AMIs) |
AWSBeanStalkCollector |
Elastic BeanStalks (web stalks only) |
AWSVPCCollector |
VPCs |
AWSClassicLoadBalancerCollector |
Classic Load Balancers (ELB) |
AWSLoadBalancerCollector |
Application Load Balancers (ALB and NLB) |
AWSENICollector |
Elastic Network Interfaces (ENIs) |
AWSRDSCollector |
RDS Database Instances |
AWSEKSCollector |
EKS Clusters (control-plane) |