# Drupal

### Requirements

* Drupal: 9.x | 10.x | 11.x

### Introduction

The package automatically instrument a Drupal instance and records performance metrics about HTTP requests, DB queries, and Unhandled Exceptions. It also has  a simple API which allows you to monitor custom code blocks in your application.

### Resources

* Website: <https://www.inspector.dev>
* Blog: <https://www.inspector.dev/blog>
* Drupal official page: <https://www.drupal.org/project/inspector_monitoring>

### Installation

Run the command below in your terminal to install the latest version:

```bash
composer require drupal/inspector_monitoring
```

### Configure the Ingestion Key

{% hint style="info" %}
To get a new Ingestion Key sign up for Inspector (<https://app.inspector.dev/register>) and creating a new application.
{% endhint %}

The Inspector Drupal module includes a form to makes you able to configure the monitoring system in a convenient web page.

To access the configuration page navigate to:

```
Admin >> Configuration >> Development >> Inspector Monitoring
```

Paste the Ingestion Key into the input form and click "Save".

### Test & Deploy

Once you have configured the Ingestion Key, try to navigate your website to see the first data flowing into the dashboard.

If everything works well, you are ready to release this integration into the production environment.

Inspector automatically reports:

* HTTP traffic
* Database queries
* Unhandled exceptions

You will be alerted for any error in your application and the [AI Bug Fix](https://docs.inspector.dev/concepts/ai-bug-fixer) will provides you with a ready to use solution in real-time.

<figure><img src="https://2873457055-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LQ51SrLj6qvIRejC1XD%2Fuploads%2FtaRrQI1Fw6qdU4SP71BC%2Fdrupal-monitoring.png?alt=media&#x26;token=e085d42f-833e-4b01-af94-ac496358c560" alt=""><figcaption></figcaption></figure>

### Transport

The transport method refers to the way Inspector sends monitoring data collected into your Drupal installation to the remote platform. We suggest to use `sync` for development or local environments, and `async` for production environment.

* **SYNC -** dev or local environment
* **ASYNC -** prod environment

### Query Logging

By default the module automatically monitors the internal database queries generated from your code, or other modules code. It will help you understand what is going on behind the scene, and immediately identify slow statements that can impact your user experience.

<figure><img src="https://2873457055-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LQ51SrLj6qvIRejC1XD%2Fuploads%2FFIAicV2Ql5aVXFD4hZEK%2Fdrupa-query.png?alt=media&#x26;token=07104e2b-e9e4-44e7-817e-211219f76f2f" alt=""><figcaption></figcaption></figure>

You can eventually enable/disable this monitoring component from the configuration page as per your needs.

### Exception Monitoring

{% hint style="info" %}
**By default every unhandled exception will be reported automatically to be sure you'll be alerted for unpredictable errors in real time.**
{% endhint %}

When an exception is detected you can read the code inside the stacktrace, and monitor its occurrences frequency for a better investigation:

<figure><img src="https://2873457055-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LQ51SrLj6qvIRejC1XD%2Fuploads%2FBt8Ml9qOLPHLjqbTk8cN%2Fdrupal-error.png?alt=media&#x26;token=beb3451e-3714-4116-9d5d-34de35a64f81" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Activate the AI Bug Fix to receive code change proposals for faster resolution: <https://docs.inspector.dev/concepts/ai-bug-fixer>
{% endhint %}
