TrackIt uses a simple recommendation plugin system aimed at making the creation of new checks easier.
It allows you to focus on writing only the logic for your check, all the rest is taken care of by TrackIt.
A simple example of plugin is available at plugins/account/unusedEBS
.
There are a few rules a plugin must respect in order to work:
func init() {
core.AccountPlugin{
Name: "My unique plugin name",
Description: "My plugin description",
Category: "My plugin category (example: EC2)",
Label: "The label used to display the number of checks (will be displayed with the following format on the front end: <passed> <label>(s))"
Func: myHandlerFunction,
BillingDataOnly: false, // Set to true if the plugin does not require a role to access the AWS API
}.Register()
}
type PluginParams struct {
Context context.Context
User users.User
AwsAccount aws.AwsAccount
AccountId string
AccountCredentials *credentials.Credentials
ESClient *elastic.Client
}
-
Context
is a standard GO context that you should use when needed -
User
is the current user, seeusers/users.go
for more details -
AwsAccount
is the current AWS account, seeaws/aws.go
for more details -
AccountId
is the current AWS account id -
AccountCredentials
are AWS credentials for the current account that you can use to reach the AWS API -
ESClient
is an ElasticSearch client that you can use to retrieve data from our ElasticSearch (for example billing data)
type PluginResult struct {
Result string
Status string
Details []string
Error string
Checked int
Passed int
}
-
Result
should contain a short summary of the result of your check -
Status
defines the color used to display the result (should be green/orange/red) -
Details
can be used to give more insight about the result -
Error
should expose an error message if your plugin was not able to generate a result -
Checked
should contain the total number of checks run by the plugin -
Passed
should contain the number of checks that passed successfully
Your plugin must be imported in plugins/plugins.go
in order to be loaded at startup.
If you use API calls that are not yet allowed in our policies, you should add them in policies/all_policies.json
and policies/tool_policies/monitor_ressources.json
All contributions are appreciated, feel free to create a pull request against the stg
branch, the trackit team will make it available to everyone after review.
Some utilities functions are available in plugins/utils
, feel free to add new functions if you think they could be useful for other plugins.