Drinking coffee or beer in a pub, having a weekend trip, watching a movie, or just sleeping but … your Odoo is down for a day already. Familiar?

odoo mem

When your Odoo ERP is down, your business is also down. You can’t receive goods, can’t sell them and can’t deliver. Internal processes are also stopped. And the longer it lasts, the more money you lose.

To prevent such unexpected issues or timely notify about downs and errors, we always set up monitoring in our Odoo projects.

Table of contents

  1. Sentry for Odoo monitoring
  2. How to install Sentry to Odoo
  3. How to configure Sentry to monitor your Odoo
  4. Summary

Sentry for Odoo monitoring

We usually use Sentry to monitor Odoo instance. And in this guide will show you how to set up Odoo monitoring via Sentry. 

There is a great OCA module that will help us doing so – https://apps.odoo.com/apps/modules/14.0/sentry/

How to install Sentry to Odoo

  1. Deploy Sentry on your server or create an account on an online service https://sentry.io
  2. Create a new project in your profile

Create Sentry project

  3. Deploy the Sentry module to your Odoo server (https://apps.odoo.com/apps/modules/14.0/sentry/).

  4. Install the Python package raven in your virtual environment. Sentry uses the SDK (software development kit) to catch exceptions and warnings. Sentry-sdk contains a set of tools to simplify development and integrate your python project with Sentry.  For earlier versions of Odoo (<14.0) the raven package was used.

pip install --upgrade sentry-sdk

  5. Install the Odoo Sentry module in your Odoo DB.

How to configure Sentry to monitor your Odoo

  1. Add the parameters for monitoring to the odoo.conf file. The description of the parameters can be found in the module’s documentation. The module allows you to flexibly configure Sentry monitoring based on your preferences.
[options]

sentry_dsn = https://<public_key>:<secret_key>@sentry.example.com/<project id>

sentry_enabled = true

sentry_logging_level = warn

sentry_exclude_loggers = werkzeug

sentry_ignore_exceptions = odoo.exceptions.AccessDenied,

    odoo.exceptions.AccessError,odoo.exceptions.MissingError,

    odoo.exceptions.RedirectWarning,odoo.exceptions.UserError,

    odoo.exceptions.ValidationError,odoo.exceptions.Warning,

    odoo.exceptions.except_orm

sentry_include_context = true

sentry_environment = production

   2. The sentry_dsn parameter value must be copied from the Sentry project settings.

Sentry DNS

   3. The sentry_ignore_exceptions parameter contains the exceptions that we want to ignore in monitoring, so that only the most important exceptions are displayed in Sentry. 

AccessDenied Login/password error. For example, when you try to log with a wrong password.
AccessError Access rights error. For example, when you try to read a record that you are not allowed to.
MissingError Missing record(s). For example, when you try to write on a deleted record.
RedirectWarning Warning with a possibility to redirect the user instead of simply displaying the warning message.
UserError Generic error managed by the client. Typically when the user tries to do something that has no sense given the current state of a record. Semantically comparable to the generic 400 HTTP status codes.
ValidationError Violation of python constraints. For example, when you try to create a new user with a login which already exist in the db.
Warning It is a deprecated alias to UserError.
except_orm It is a deprecated alias to UserError.

If there is a need to monitor any of the listed exceptions, you can always remove it from the sentry_ignore_exceptions parameter.

  4. Sentry provides the ability to monitor performance. It is available for the Sentry Python SDK version β‰₯ 0.11.2. To enable performance monitoring it is necessary to set the sentry_traces_sample_rate parameter. This parameter is set between 0 and 1 (For example, to send 20% of transactions, set traces_sample_rate to 0.2.). Be attentive when specifying the value of this parameter, as too high a value may result in poor performance.

   5. You need to restart Odoo to launch monitoring.

That’s it. Now your Odoo server is under control πŸ™‚

 Summary

What benefits Odoo monitoring with Sentry gives:

  • 24/7 log monitoring
  • Detect a serious error before it has serious consequences
  • Saving detailed information about the error, indicating the line of code where it occurredOdoo Sentry error log
  • Reduced time spent looking for problems
  • Can be self-hosted
  • Performance monitoring
  • Notifications by email or messengers
  • User-friendly interface
  • Preserving the mental health of your developers πŸ™‚

Disadvantages of Sentry:

  • The Sentry-client works on a fire-and-forget model. It catches exceptions and sends them to Sentry, but if for some reason (i.e. network issues) it fails to send the exception message to Sentry, we lose information about it.
  • Requires installation and use of a third-party python package in the project.

Calculate the price for your Odoo project

Get a quote >

 

Follow our Linkedin account and subscribe to our newsletter to make sure you don’t miss updates.

ventor.tech || Website || + posts

1+ year of Odoo development experience.
9+ years of developing automation and protection logic for electric networks
Hard skills: Python, Odoo, SQL, Locust