[Music] let's take a look at how we can create grafana managed alerts in grafana9 first let's navigate to the alerting tab to do that we can click the bell icon on the left hand side we can see here that we have not yet created any alert rules so let's create one now we can click the blue new electoral button which will take us to the create alert rule page here we can choose between three different kinds of rule grafana managed alert mimir or loki alert and mimir or loki recording rule in this example we are going to be looking at how to create grafana managed alerts so we will keep graphing managed alert checked let's start by creating an alert on a simple query we want to know if our http server is returning 500 internal server errors we have a prometheus server that is collecting metrics from our http server so we have chosen our prometheus data source from the data source menu let's now select our metric http request total and we want to create an alert when the status code is 500 since this is a counter we want to add a rate function to see the rate at which our server is returning 500 internal server errors to make this query alertable we need to reduce it to a single value to do this we can use either a classic condition or we can use a reduce and math expression classic conditions provide simple aggregation functions such as average min max and sum and let us create alerts when this value exceeds the threshold reduce and math expressions let us create more complex alerting conditions and are particularly useful when we want to create an alert rule that uses multiple queries to determine whether the alert should fire when using a reduce and math expression if the condition is greater than or equal to 1 we can just create a reduced expression without the math expression when creating a graphile managed alert it is possible to set both the evaluation interval and the duration we want this alert to evaluate every minute and for the alert to fire if we are seeing 500 internal server errors for at least five minutes next let's pick a rule name this should be short but descriptive as it's what you will see in your alert notifications let's use the name http request failures once we have chosen a name for our alert rule we can pick an existing folder or create a new one let's use the folder i created earlier called http monitoring now we need to assign this rule to a rule group rule groups in grafana are equivalent to those in prometheus let's use the same name as the folder http monitoring we can now save this rule if we now go to the alerting tab we can see that our alert is okay if our http server starts to return http 500 internal server errors we will see that the alert has changed to pending as grifollo must wait five minutes before the alert can fire if the server continues to return 500 internal server errors for five minutes then this alert will transition from pending to firing otherwise we can expect it to return to okay [Music] you