Set up reOptimize to publish Pub/Sub messages to a topic of your choice when certain events occur. For example, publish a message when a budget reaches a threshold that you have set.
You must set up enrichments access as explained here before we can publish messages to your topic.
Setting up Push API
- Create a new Pub/Sub topic in a project of your choice.
- Grant Pub/Sub Publisher permissions to the service account you added in Enrichments tab (see prerequisites if you did not setup enrichments).
- In reOptimize, click on your name and select "Company Settings".
- Click on "Push API" tab.
- If your Push API tab is disabled you must first setup enrichments.
- Write the topic resource ID (e.g. projects/my-project-id/topics/my-topic-name) under the "Push API" tab and click Save.
- If your topic ID was saved successfully, you will be presented with a button that allows you to send a test message for your convenience.
Supported event types
reOptimize will automatically publish messages to your topic on certain events. The event type will be sent as an attribute of the Pub/Sub message under the key "eventType".
- TEST_EVENT: When you click the send test message button.
- ALERT_THRESHOLD_EXCEEDED: When a budget reaches a threshold that you have set.
We have created some samples to how you can use these events in this GitHub repository.
For example, the "disable-project-billing" example will create a Cloud Function that will unlink a project from billing account when the project spend exceeds a budget for that project.