# 6.4. ML monitoring with Evidently and Grafana \[OPTIONAL CODE PRACTICE]

{% embed url="<https://youtu.be/S4zFqbLhAp8?si=BEfLZteDmj94XPpD>" %}

**Video 4**. [ML monitoring with Evidently and Grafana \[OPTIONAL CODE PRACTICE\]](https://youtu.be/S4zFqbLhAp8?si=BEfLZteDmj94XPpD), by Emeli Dral

In this video, we show how to add ML monitoring metrics to the Grafana dashboard using Evidently as an evaluation layer and storing the metrics in a Postgres database.

**Want to go straight to code?** Here is the [code example](https://github.com/evidentlyai/ml_observability_course/tree/main/module6/grafana_monitoring_dashboard) to follow along.

**Outline:**\
[00:00](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=0s) Introduction\
[00:25](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=25s) Install Grafana and set up the Postgres database\
[03:18](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=198s) Script overview, imports, and logging\
[04:50](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=290s) Create a table statement\
[06:30](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=390s) Load data and simulate production usage\
[07:30](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=450s) Connect to a database and create a table\
[10:32](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=632s) Calculate metrics and insert them into Postgres\
[16:00](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=960s) Write a function to compute metrics in batches\
[18:58](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=1138s) Run services, execute and debug the script\
[23:21](https://www.youtube.com/watch?v=S4zFqbLhAp8\&t=1401s) Create dashboards in Grafana


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.evidentlyai.com/ml-observability-course/module-6-deploying-an-ml-monitoring-dashboard/ml-monitoring-evidently-grafana-code-practice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
