Sunday, November 16, 2014

Configuring Sentry Monitoring Projects

Creating Our First Team and Project

Alright, we get to play with an actual user interface for a bit. After you get through this phase, you're pretty much set up with Sentry and will be receiving emails and alerts whenever things break.

Prerequisites: If you haven't already set up your Sentry server, check out this guide first.

Once you have the server up and running, it's time to create teams and projects so you can start making use of the dashboard. Head over to the url that your sentry instance is running on and you'll be greeted with this screen:

There won't be any teams or projects configured from the outset. We won't need to add any users for this example, but we do need to create a team. Go a head and click on "Create a New Team" and enter "sentrytest" in the form field.

Now click the button labeled "Create a New Project" and also name it "sentrytest". Select Python as your platform.

You'll now be presented with a settings screen that will help you write your first client. We'll come back to this later. Notice that the settings screen provides instructions for a variety of different languages. You can also view the Dashboard and Stream by clicking the appropriate tabs.

Here's our dashboard where you get an overview of Trends and New Events. It'll come with an example Python exception.

Writing Our Python Client

Go ahead and follow the instructions on the "Configuring Python" screen. After you've installed the dependencies through pip using the command line, you're ready to make a main.py file on your local machine with the example code. You should then be able to run the file with python main.py. If you hit any snags, use the following code instead:

from raven import Client
from django.core.handlers.wsgi import WSGIHandler

client = Client('http://0919da@sentry.codeboxsystems.com/2')
from raven.middleware import Sentry
application = Sentry(WSGIHandler(), client=client)

# record a simple message
client.captureMessage('hello world!')

# capture an exception
try:
  1 / 0
except ZeroDivisionError:
  client.captureException()

Now return to your dashboard and see the new exception. That concludes this article. Good luck learning about all of the things you can do with Sentry!

No comments:

Post a Comment