Kraken.io quota monitoring

Kraken.io Monitor

In case you are using Kraken.io within your applications, no matter if this involves direct API calls or using an extension / plugin, you might start to wonder if there is an easy way to enable notifications based on your quota’s. This post explains how this can be achieved in 5 minutes using Azure Logic Apps!

Kraken.io quota monitoring – the API

We, Dev & Ops, are spending lots of time designing and implementing robust and scalable systems however, sometimes forget about the simple things. The things that might be responsible for some embarrassing situations, for example when running out of Kraken.io credits…

At the moment, Kraken.io doesn’t support the option to configure quota usage notifications based on something which can be easily integrated into existing reporting frameworks like webhooks.

Fortunately, Kraken.io does exposes account usage data which can be accessed programmatically using the REST API. I’ve included the details on what’s currently available below.

Example JSON result when calling https://api.kraken.io/user_status

At this point we only need a way to automate usage tracking and the option to send for example email notifications or integrate with an existing system. Now, achieving this can be done in many ways. But as many might know, I’m an enthusiast of Azure Logic Apps and therefore decided to implement this by creating a new Logic App workflow.

Calling the Kraken.io API from Logic Apps

Building the Logic Apps workflow is very simple and only takes a couple of minutes.

Step 1 – Create a new Logic Apps within the Azure management portal. I’m calling my workflow krakenQuotaCheck, but feel free no name it anything you like.

Step 2 – Open the new Logic App in the Designer and add a Recurrence action with a time interval of one hour.

Add Recurrence action

Add new action

Step 3 – Add a new HTTP action and provide the following information however, make sure to replace your-api-key and your-api-secret with your Kraken.io details as found within the Kraken.io account information section.

Method:POST
Uri:https://api.kraken.io/user_status
Body:{ “auth”: { “api_key”: “your-api-key”, “api_secret”: “your-api-secret” } }

Call Kraken.io API

Step 4 – Add a new condition and click on Edit in advanced mode. Within the input box make make sure to enter the following condition:

Which translates into the following: Check if you have used over 90% of your quota.

condition

Step 5 – The last step is responsible for sending a Action / notification type of your liking; email, Http call, log a message, creating a Tweet or writing a custom Action.

I’m creating another HTTP Action for this sample which is calling http://requestb.in/ so we can see the results.

Test Alert

Testing and debugging

Luckily, you don’t have to wait for an hour, just click on Select Trigger within the toolbar to execute the workflow manually.

Run workflow

Action step execution details are available for each Run in case needed. This also includes the message details as can be seen within the images below.

Run details

Messages

And here the result within requestb.in. I was using a free account which already run out of credits and therefor able to have a positive test.

results

Conclusion

As you can see it was very simple to create a process which automatically notifies you based on the available data exposed via the Kraken.io API. You can alter the logic and follow-up actions based on your requirements.

If you are interested to know more about Azure Logic Apps, please take a look at my other blog articles.

Post Navigation