Question

Sentry catches loggings and errors from client applications.

The only way I know of creating a project in Sentry is by manually submitting the form in the Web application interface.

I'm searching for a way to create a project into Sentry from the command line in any way (options, config file) ?

This would be greatly valuable for deployment scripts. Otherwise no automation is possible.

Just found this discussion while Googling around but no answer:

https://groups.google.com/d/topic/getsentry/pWglAEHaPUk/discussion

Any idea?

Was it helpful?

Solution

It's a django project, of course you can:

from sentry.models import Project
project = Project(...)
...
project.save()

Edit: You could write a custom management command to get functionality on the command line

Edit by question's author: Yes indeed it is a django project, so like a django project I automated my deployment in the three following steps:

  1. Start Sentry, create users, teams and projects and adjust settings from the admin Web interface
  2. Run dumpdata like you'd do with any django project (sentry will implicitly call manage.py):

    sentry --config=sentry.conf.py dumpdata --indent=2 auth > auth_data.json

    sentry --config=sentry.conf.py dumpdata --indent=2 sentry > sentry_data.json

  3. Deploy step by step:

    sentry --config=sentry.conf.py syncdb --noinput

    sentry --config=sentry.conf.py migrate

    sentry --config=sentry.conf.py loaddata auth_data.json

    sentry --config=sentry.conf.py loaddata sentry_data.json

Works pretty well. Hope this will help others.

OTHER TIPS

As officially stated in Sentry's docs:

# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure()

# Do something crazy
from sentry.models import Team, Project, User

user = User()
user.username = 'admin'
user.email = 'admin@localhost'
user.is_superuser = True
user.set_password('admin')
user.save()

team = Team()
team.name = 'Sentry'
team.owner = user
team.save()

project = Project()
project.team = team
project.owner = user
project.name = 'Default'
project.save()

key = ProjectKey.objects.filter(project=project)[0]
print 'SENTRY_DSN = "%s"' % (key.get_dsn(),)

https://docs.getsentry.com/on-premise/server/faq/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top