Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(srv): add how to create alerts for srv ressources MTA-5503 #4379

Merged
merged 7 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions menu/navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,10 @@
"label": "Monitor function logs and metrics",
"slug": "monitor-function"
},
{
"label": "Configure alerts for a function",
"slug": "configure-alerts-function"
},
{
"label": "Delete a function",
"slug": "delete-a-function"
Expand Down
158 changes: 158 additions & 0 deletions pages/serverless-containers/how-to/configure-alerts-containers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
meta:
title: How to add alerts to a container
description: Learn how to add monitoring alerts to Serverless Containers with Scaleway.
content:
h1: How to add alerts to a container
paragraph: Learn how to add monitoring alerts to Serverless Containers with Scaleway.
tags: containers 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 Containers 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
- [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 Containers.

**AnyContainerError**

Pending period

: 10s

Summary

: Container `{{ $labels.resource_name }}` is in error.

Query and alert condition

: `serverless_container_status{status="error"} == 1`

Description

: Container `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is in error. Check the console to find out the error message.

**ContainerError**

Pending period

: 10s

Summary

: Container `{{ $labels.resource_name }}` is in error.

Query and alert condition

: `serverless_container_status{status="error",resource_id="your-container-id-here"} == 1`

Description

: Container `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is in error. Check the console to find out the error message.

**AnyContainerHighCPUUsage**

Pending period

: 10m

Summary

: High CPU usage for container `{{ $labels.resource_name }}`.

Query and alert condition

: `serverless_container_cpu_usage_ratio > 90`

Description

: Container `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m.

**ContainerHighCPUUsage**

Pending period

: 10m

Summary

: High CPU usage for container `{{ $labels.resource_name }}`.

Query and alert condition

: `serverless_container_cpu_usage_ratio{resource_id="your-container-id-here"} > 90`

Description

: Container `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m.

**AnyContainerHighMemoryUsage**

Pending period

: 10m

Summary

: High memory usage for container `{{ $labels.resource_name }}`.

Query and alert condition

: `(serverless_container_memory_usage_bytes / serverless_container_memory_limit_bytes) * 100 > 90`

Description

: Container `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available RAM since 10m.

**ContainerHighMemoryUsage**

Pending period

: 10m

Summary

: High memory usage for container `{{ $labels.resource_name }}`.

Query and alert condition

: `(serverless_container_memory_usage_bytes{resource_id="your-container-id-here"} / serverless_container_memory_limit_bytes{resource_id="your-container-id-here"}) * 100 > 90`

Description

: Container `{{ $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 been triggered.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This parameter sets the lowest value your resource is allowed to scale down to:

- If you set a value of `0`, all instances of your resource will be terminated after 15 minutes of inactivity.

- If you set a value of `1` or more, the corresponding number of instances of your resource will remain available at all time.
- If you set a value of `1` or more, the corresponding number of instances of your resource will remain available at all times.

Customizing the minimum scale for Serverless can help ensure that an instance remains pre-allocated and ready to handle requests, reducing delays associated with [cold starts](/serverless-containers/concepts/#cold-start). However, this setting also impacts the costs of your Serverless Container.

Expand Down
158 changes: 158 additions & 0 deletions pages/serverless-functions/how-to/configure-alerts-function.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
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
- [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.

**AnyFunctionError**

Pending period

: 10s

Summary

: Function `{{ $labels.resource_name }}` is in error.

Query and alert condition

: `serverless_function_status{status="error"} == 1`

Description

: Function `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is in error. Check the console to find out the error message.

**FunctionError**

Pending period

: 10s

Summary

: Function `{{ $labels.resource_name }}` is in error.

Query and alert condition

: `serverless_function_status{status="error",resource_id="your-function-id-here"} == 1`

Description

: Function `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is in error. Check the console to find out the error message.

**AnyFunctionHighCPUUsage**

Pending period

: 10m

Summary

: High CPU usage for function `{{ $labels.resource_name }}`.

Query and alert condition

: `serverless_function_cpu_usage_ratio > 90`

Description

: Function `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m.

**FunctionHighCPUUsage**

Pending period

: 10m

Summary

: High CPU usage for function `{{ $labels.resource_name }}`.

Query and alert condition

: `serverless_function_cpu_usage_ratio{resource_id="your-function-id-here"} > 90`

Description

: Function `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available CPU since 10m.

**AnyFunctionHighMemoryUsage**

Pending period

: 10m

Summary

: High memory usage for function `{{ $labels.resource_name }}`.

Query and alert condition

: `(serverless_function_memory_usage_bytes / serverless_function_memory_limit_bytes) * 100 > 90`

Description

: Function `{{ $labels.resource_name }}` with ID `{{ $labels.resource_id }}` is using more than `{{ printf "%.0f" $value }}`% of its available RAM since 10m.

**FunctionHighMemoryUsage**

Pending period

: 10m

Summary

: High memory usage for function `{{ $labels.resource_name }}`.

Query and alert condition

: `(serverless_function_memory_usage_bytes{resource_id="your-container-id-here"} / serverless_function_memory_limit_bytes{resource_id="your-container-id-here"}) * 100 > 90`

Description

: 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 been triggered.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This parameter sets the lowest value your resource is allowed to scale down to:

- If you set a value of `0`, all instances of your resource will be terminated after 15 minutes of inactivity.

- If you set a value of `1` or more, the corresponding number of instances of your resource will remain available at all time.
- If you set a value of `1` or more, the corresponding number of instances of your resource will remain available at all times.

Customizing the minimum scale for Serverless can help ensure that an instance remains pre-allocated and ready to handle requests, reducing delays associated with [cold starts](/serverless-functions/concepts/#cold-start). However, this setting also impacts the costs of your Serverless Function.

Expand Down
Loading