Graphite with .Net and Ubuntu 11.10

This is a quick write-up on how to get started with graphite as a .Net developer. We’re going to start using graphite with a virtual machine in VirtualBox, although you could use something else also.


  1. Download/install VirtualBox
  2. Download/install Ubuntu
  3. Download/install Graphite
  4. Expose VM to network
  5. Use Graphite from C#

Download/install VirtualBox

Start by downloading and installing virtualbox.

The installer is a “Next – next – next” type of installer, so just click through it.

Download/install Ubuntu

Once installed, download and install ubuntu as a new virtual machine.

Now, what you have to do is to bring up a terminal window. Press Win and type Terminal in the input field and launch the terminal.

A bit on the terminal and sudo

When working with a linux, you have to type sudo before any command that makes changes to ‘root’-owned directories such as /etc/ and /opt/ where we are going to install graphite, Apache and other dependencies.

pushd pushes a folder onto an in-memory stack and changes the current directory to the first argument, while popd pops the stack and moves to the previous directory.

You can paste into the terminal with [CTRL]+[SHIFT]+[V] and copy with [CTRL]+[SHIFT]+[C]. Another tab in the terminal is created with [CTRL]+[SHIFT]+[T] – this can be nice to have if you want to look up data about your VM, such as its ip (with ‘ifconfig’).

Installing Graphite

This gist contains the commands you can use to install graphite.

When you have followed the gist, try to navigate to or http://[::1]/ from Firefox. You should be able to see the graphite start page.

Expose the VM to the network

When you have a graphite installation, you likely want to start logging things into it – perhaps you already have a piece of software you want to enable metrics from. In order to reach the virtual machine from other computers on the network.

In order to do this, shut down the virtual machine and change its network interface to be ‘bridged’ – this is in order to let your DHCP server give the server and IP rather than only having access to it through your private computer-LAN-to-VM (NATted). Change the following: Machine Settings > Network > Adapter 1 > Attached to: [Bridged].

Start the virtual machine again.

Now check with ifconfig from the Terminal what IP the machine has, and navigate to that IP from your main development operating system. You should be able to see the graphite install now and the example data you added (from the last line of the gist).

Use the graphite from C#

Now it’s time to log some data with C# into your brand new graphite install!

Open VS and create a new console application. Using Tools > Library Package Manager > Package Manager Console, type “install-package Graphite.NET”, targeting your new console project.

Then type this code in the main method (put a using Graphite; directive on top):

Try and run the program!

Now you should have some nice data point in graphite! Zoom in the latest minute so that you can see them.


  • Michael Grace –

Leave a Reply