Add a New Provider Plugin
Provider plugin is being used to update rule configurations to the provider, setup some runtime provider configuration config if any, and transform incoming alert data in Siren's Hook API to a list of *alert.Alert model. More details about the concept of provider plugin can be found here.
Steps to Add a New Plugin
Add a new package
A new plugin could be added as a new package under
plugins/providers/{new_plugin}. Package name should comply with odpf golang standard naming. See the handbook. Ideally you might want to name the package with lower-case and without any-or_signs.Defining Configurations (Optional)
If there is a need to have a generic config for the provider that is being loaded during start-up, you could add a new
AppConfigand assign the config toplugins/providers/config.goto expose it to the server-level config. Siren will recognize and read the config when starting up.Implement Interfaces
Implement
TransformToAlertsYou need to find a way for the provider to send alert to Siren's hook API
{api_version}/alerts/{provider_type}/{provider_id}. You need to implement aTransformToAlertsmethod to parse and transform the body of incoming request received by Siren's hook API to a list of Siren's*alert.Alertmodel.Implement
UpsertRulesYou need to implement
UpsertRulesmethod to push all rules changes to the provider everytime a rule is upserted.Implement
SyncRuntimeConfig(Optional)If a provider supports setting the configuration dynamically and if for each provider's namespace there is a possibility to have different config (e.g. for multitenancy purpose like CortexMetrics), you could implement
SyncRuntimeConfigfunction to push all configurations changes to the provider everytime a new namespace is created or an existing namespace is updated.
Integrate the new plugin with Siren main flow
- Define and add your new type of plugin inside
core/providers/type.go. - Initialize your plugin provider service and add to the
AlertTransformer,ConfigSyncer, andRuleUploaderregistries map incli/deps.
- Define and add your new type of plugin inside