Metricboard howtos

Articles with examples on specific topics; to help you get started quickly.

Topics

How can I visualize metrics from my application backend?

This article describes how you can start sending your application metrics into metricboard.io, by using the API from within your application backend.

Create a feed

In metricboard metrics are grouped in to separate feeds. For example: different feeds for different applications, or a feed for each system you monitor. Each feed has its own API key.

When logged in open the account section of metricboard and click ' New feed'. After you have entered a name for the feed and clicked save you will be presented with the API key for that feed. There will also be code samples you can copy-and-paste directly into your application.

Start sending data

You can now start sending metric data to the feed you just created.

A good way to get interesting metrics is by running queries and getting totals for interesting tables against your database regularly using a scheduling mechanism (i.e cron) each hour.

For example:

  • Total count for all customers, orders, logins, successful payments, etc ...
  • Number of issues in your support system
  • New tasks created in the past 24 hours
  • Active users in the last hour
  • Etc ...

By regularly keeping track of the totals you can extract different kinds of information from the feed later in a dashboard, for example relative growth and trends.

Visualize the data

After your application start sending data to the feed you can begin visualizing it by creating a dashboard.

Simply navigate to 'Dashboards' and click ' New dashboard'

You can now add visualizations to your dashboard. After creating a visualization you should be able to select the metrics your application is sending.

Monitoring proactively

It can be very valuable to get an alert when certain thresholds are exceeded. In this way you can proactivly take action when something goes wrong.

You can monitor metrics in a feed by clicking the 'Monitor' section and then ' New monitor'

Each monitor can monitor one or more metrics in multiple feeds. This way you only have to define a monitor once if you want to monitor multiple applications which emit the same metrics.

About feeds and dashboards

Each dashboard is linked to a specific feed. In this way you can build a dashboard for feed and then clone and link it to another similair feed. If the feed contain the same metrics (i.e monitor the same application but different environments) all visualization will automatically show the correct data.

Complete code example

Below you will find a python example, you can run this with some modifications as a hourly cronjob:


#!/usr/bin/python
import requests
import psycopg2

feed_api_key="api key of a feed" # Presented when creating a feed

db = psycopg2.connect("dbname='' user='' host='localhost' password=''")
cursor = db.cursor()

metrics = {}

for table in [ "orders", "customers"]:
    cursor.execute("""select count(*) from {};""".format(table))
    (count, ) = cursor.fetchone()
    metrics[table] = count

requests.post(url="https://metricboard.io/api/metric".format(user),
              data=metrics,
              headers={'apikey': feed_api_key})

Conclusion

We hope this article was helpful in getting you started quickly.

Comments or questions or need help with integrating? Let us know by contacting us!