Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Last active November 24, 2016 10:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhelmer/ce2354e7c11eb2848c2e to your computer and use it in GitHub Desktop.
Save rhelmer/ce2354e7c11eb2848c2e to your computer and use it in GitHub Desktop.
Socorro Webapp

Running the Crash-Stats Web UI

If you have Socorro Lite installed (https://gist.github.com/rhelmer/1475ac173362edefa469), this guide will show you how to install the crash reporting web UI Crash-Stats that powers https://crash-stats.mozilla.com

The Django application uses both PostgreSQL and ElasticSearch (and supports Filesystem or S3 for pulling up crashes directly), so make sure to run the processor with all three crash storage classes configured (and set up per the Socorro Lite install doc):

socorro processor \
  --destination.crashstorage_class='
    socorro.external.crashstorage_base.PolyCrashStorage' \
  --destination.storage_classes='
    socorro.external.fs.crashstorage.FSLegacyDatedRadixTreeStorage,
    socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage,
    socorro.external.postgresql.crashstorage.PostgreSQLCrashStorage' \
  --destination.storage1.elasticsearch_base_settings=./socorro_index_settings.json

Now, clone and run the Crash-Stats Django app from the socorro-webapp repository:

  git clone https://github.com/rhelmer/socorro-webapp.git
  cd socorro-webapp
  # you could instead "workon crashreports" if you want to share virtualenvs
  mkvirtualenv crashstats
  pip install -r requirements.txt
  sudo apt-get update
  sudo apt-get install node-less
  # copy default config
  cp crashstats/settings/local.py-dist crashstats/settings/local.py
  ./manage.py syncdb --noinput
  # be sure to use an email address you control below
  ./manage.py makesuperuser youremail@example.com
  ./manage.py runserver

You should now be able to log in to http://localhost:8000 as an admin using the superuser email address passed to makesuperuser.

Each product you wish to have reports on must be added via the Socorro admin UI:

http://crash-stats/admin/products/

All products must have one or more releases:

http://crash-stats/admin/releases/

The new releases should be “featured” so they are used as defaults and show up in all reports:

http://crash-stats/admin/featured-versions/

Active Daily Install (ADI)

Most graphs and some reports in the Socorro Web UI depend on having an estimate of Active Daily Installs for each release, in order to express crashes as a ratio of crashes per install.

You should insert an ADI number (or estimate) for each day per release into the raw_adi table in PostgreSQL:

  psql breakpad
  -- args: adi_count, date, product_name, product_os_platform,
  --       product_os_version, product_version, build, product_guid,
  --       update_channel
  INSERT INTO raw_adi VALUES (15, '2014-01-01', 'TestApp', 'Linux', '2.6.18',
                             '1.0', '20140101165243',
                             '{testapp@example.com}', 'release');

The source of this data is going to be very specific to your application, you can see how we automate this for crash-stats.mozilla.com in this job:

https://github.com/mozilla/socorro/blob/master/socorro/cron/jobs/fetch_adi_from_hive.py

Generating reports for the Crash-Stats Web UI using Crontabber

Crontabber produces reports in PostgreSQL, most are updated once per day.

In order for Socorro to generate reports for the Web UI, a "crontabber" task must be run once every 5 minutes. This can be added to your crontab:

  # FIXME, won't work as-is
  # Socorro cron job manager
  */5 * * * * socorro /data/socorro/application/scripts/crons/crontabber.sh

Production Crash-Stats Web UI

For production use, run the Crash-Stats Django app under uwsgi:

uwsgi -H ~/.virtualenvs/crashstats --wsgi-file wsgi/socorro-crashstats.py -s my_socket

Then configure your webserver to pass connections to that socket.

Nginx: http://uwsgi-docs.readthedocs.org/en/latest/Nginx.html

Apache: http://uwsgi-docs.readthedocs.org/en/latest/Apache.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment