Home

Awesome

OpenCost Plugins

OpenCost plugins make extending OpenCost’s coverage into new external cost sources (e.g. monitoring, data platforms, cloud services, and other SaaS solutions) available to the open source community. They allow for the ingestion of arbitrary cost data into OpenCost through conformance to the FOCUS spec.

How plugins work

Any plugin released within this repository can be deployed alongside OpenCost. When deployed, OpenCost will query all installed plugins with a request for the following:

The plugins are expected to return a response that conforms to the aforementioned FOCUS spec for the given window and resolution. OpenCost will then store the response, and continue to request data for further time ranges.

The FOCUS spec is broken up into two parts:

See this ExcaliDraw diagram for a more details overview of the plugin system

Creating a new plugin

At the most basic level, all a plugin needs to do is gather cost data given a time window and resolution. The logistics of this are straightforward, but the complexity of the implementation will depend on the data source in question.

Plugin setup

Design the configuration

All plugins require a configuration. For example, the Datadog plugin configuration takes in some information required to authenticate with the Datadog API. This configuration will be defined by a struct inside <repo>/<plugin>/<plugin>plugin/.

Implement the plugin

Once the configuration is designed, it's time to write the plugin. Within <repo>/<plugin>/cmd/main/>, create main.go:

Implement tests (highly recommended)

Write some unit tests to validate the functionality of your new plugin. See the Datadog unit tests for reference.

Submit it!

Now that your plugin is implemented and tested, all that's left is to get it submitted for review. Create a PR based off your branch and submit it, and an OpenCost developer will review it for you.

Plugin system limitations

Contributors

Thanks to all the individuals who have given their time and effort towards creating and maintaining these plugins:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tr> <td align="center"><a href="https://github.com/sajit"><img src="https://avatars.githubusercontent.com/u/675316?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sajit Mathew Kunnumkal</b></sub></a><br /><a href="https://github.com/opencost/opencost-plugins/commits?author=sajit" title="Code">💻</a><br /><sub><b>MongoDB Atlas Plugin</b></sub></a><br /</td> </tr> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->