-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(srv): add how to create alerts for srv ressources MTA-5503
- Loading branch information
1 parent
a604efc
commit cab144e
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
pages/serverless-functions/how-to/configure-alerts-function.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
meta: | ||
title: How to add alerts to a function | ||
description: Learn how to add monitoring alerts to Serverless Functions with Scaleway. | ||
content: | ||
h1: How to add alerts to a function | ||
paragraph: Learn how to add monitoring alerts to Serverless Functions with Scaleway. | ||
tags: functions alerts grafana threshold monitoring cockpit | ||
dates: | ||
validation: 2025-02-10 | ||
posted: 2025-02-10 | ||
categories: | ||
- serverless | ||
--- | ||
|
||
This page shows you how to configure alerts for Scaleway Serverless Functions using Scaleway Cockpit and Grafana. | ||
|
||
<Macro id="requirements" /> | ||
|
||
- A Scaleway account logged into the [console](https://console.scaleway.com) | ||
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization | ||
- Scaleway resources you can monitor | ||
- [Created Grafana credentials](/cockpit/how-to/retrieve-grafana-credentials/) with the **Editor** role | ||
- [Enabled](/cockpit/how-to/enable-alert-manager/) the alert manager, and [activated preconfigured alerts](/cockpit/how-to/activate-managed-alerts/) | ||
- [Created](/cockpit/how-to/add-contact-points/) at least one contact point | ||
- Selected the **Scaleway Alerting** alert manager in Grafana | ||
|
||
1. [Log in to Grafana](/cockpit/how-to/access-grafana-and-managed-dashboards/) using your credentials. | ||
2. Click the **Toggle menu** then click **Alerting**. | ||
3. Click **Alert rules** and **+ New alert rule**. | ||
4. Scroll down to the **Define query and alert condition** section and click **Switch to data source-managed alert rule**. | ||
<Message type="important"> | ||
This allows you to configure alert rules managed by the data source of your choice, instead of using Grafana's managed alert rules. | ||
</Message> | ||
|
||
5. Type in a name for your alert. | ||
6. Select the data source you want to configure alerts for. For the sake of this documentation, we are choosing the **Scaleway Metrics** data source. | ||
7. In the Metrics browser drop-down, select the metric you want to configure an alert for. Refer to the table below for details on each alert for Serverless Functions. | ||
|
||
| Rule name | Pending period | Summary | Query and alert condition | Description | | ||
|----------------------------|----------------|---------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| AnyFunctionError | 10s | Function `{{ $labels.resource_name }}` is in error. | `serverless_function_status{status="error"} == 1 ` | Function `{{ $labels.resource_name }}` with id `$labels.resource_id }}` is in error. Check the console to find out the error message. | | ||
| FunctionError | | Function `{{ $labels.resource_name }}` is in error. | `serverless_function_status{status="error",resource_id="your-function-id-here"} == 1 ` | Function `{{ $labels.resource_name }}` with id `{{ $labels.resource_id }}` is in error. Check the console to find out the error message. | | ||
| AnyFunctionHighCPUUsage | 10m | High CPU usage for function `{{ $labels.resource_name }}`. | `serverless_function_cpu_usage_ratio > 90 ` | Function `{{ $labels.resource_name }}` with id `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m. | | ||
| FunctionHighCPUUsage | | High CPU usage for function `{{ $labels.resource_name }}`. | `serverless_function_cpu_usage_ratio{resource_id="your-function-id-here"} > 90 ` | Function `{{ $labels.resource_name }}` with id `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m. | | ||
| AnyFunctionHighMemoryUsage | 10m | High memory usage for function `{{ $labels.resource_name }}` | `(serverless_function_memory_usage_bytes / serverless_function_memory_limit_bytes) * 100 > 90 ` | Function `{{ $labels.resource_name }}` with id `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available RAM since 10m. | | ||
| FunctionHighMemoryUsage | | High memory usage for function `{{ $labels.resource_name }}` | `(serverless_function_memory_usage_bytes{resource_id="your-container-id-here"} / serverless_function_memory_limit_bytes{resource_id="your-container-id-here"}) * 100 > 90` | Function `{{ $labels.resource_name }}` with id `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available RAM since 10m. | | ||
|
||
8. Select labels that apply to the metric you have selected in the previous step, to target your desired resources and fine-tune your alert. | ||
9. Select one or more values for your labels. | ||
10. Click **Use query** to generate your alert based on the conditions you have defined. | ||
11. Select a folder to store your rule, or create a new one. Folders allow you to easily manage your different rules. | ||
12. Select an evaluation group to add your rule to. Rules within the same group are evaluated sequentially over the same time interval. | ||
13. In the **Set alert evaluation behavior** field, configure the amount of time during which the alert can be in breach of the condition(s) you have defined until it triggers. | ||
<Message type="note"> | ||
For example, if you wish to be alerted after your alert has been in breach of the condition for 2 minutes without interruption, type `2` and select `minutes` in the drop-down. | ||
</Message> | ||
14. Optionally, add a summary and a description. | ||
15. Click **Save rule** at the top right corner of your screen to save your alert. Once your alert meets the requirements you have configured, you will receive an email to inform you that your alert has triggered. |