azure云数据库_将Azure SQL数据库警报集成到Slack

azure云数据库

Database administrators have a lot of tasks and responsibilities but perhaps the most challenging task is performance tuning. Because performance tuning issues can cause huge problems in the business area, database administrators have to monitor performance metrics and have to get immediate, if not sooner, notifications when the performance values cross an optimal state. Generally, this notification comes by e-mail.

数据库管理员有很多任务和职责,但是最具挑战性的任务可能是性能调整。 由于性能调整问题可能会在业务领域引起巨大的问题,因此数据库管理员必须监视性能指标,并且必须在性能值超过最佳状态时立即(如果不是很快的话)获得通知。 通常,此通知通过电子邮件发送。

In our business lives, we follow our e-mails regularly but some issues are more significant than others and we need to respond quickly. On the other hand, communication platforms rapidly change and software vendors offer new application solutions to users. Therefore, sometimes traditional e-mail communication is not enough for us. The software vendors who become aware of this situation release new applications. These applications are becoming more popular. Because these applications offer or claim to us a simple, clear and understandable communication system. Due to above-mentioned features, if we get database performance notifications over these applications, thus situation provides greater flexibility and speed. Because of all these reasons, in this article, we will integrate Azure SQL alert notifications to Slack. We will use the below architecture diagram to achieve this integration.

在我们的业务生活中,我们会定期跟踪电子邮件,但是某些问题比其他问题更重要,因此我们需要快速响应。 另一方面,通信平台Swift变化,软件供应商为用户提供新的应用程序解决方案。 因此,有时传统的电子邮件通信对我们来说还不够。 意识到这种情况的软件供应商会发布新的应用程序。 这些应用程序变得越来越流行。 因为这些应用程序向我们提供或要求我们提供一个简单,清晰和可理解的通信系统。 由于上述功能,如果我们通过这些应用程序获得数据库性能通知,则情况将提供更大的灵活性和速度。 由于所有这些原因,在本文中,我们将Azure SQL警报通知集成到Slack 。 我们将使用下面的架构图来实现这种集成。

azure云数据库_将Azure SQL数据库警报集成到Slack

Now, we will learn something about technologies which we will use in this integration.

现在,我们将学习有关将在此集成中使用的技术的一些知识。

Slack: Slack can be defined as a team communication application. Slack is used in many companies, especially where information firm usage is very high. Slack supports more than 30 programming languages and team members can share code, text very easily. At the same time, you can use this software in mobile devices.

松弛 松弛可以定义为团队沟通应用程序。 Slack用于许多公司,尤其是在信息公司使用率很高的公司。 Slack支持30多种编程语言,团队成员可以轻松共享代码,文本。 同时,您可以在移动设备中使用该软件。

Webhook: Webhook is an HTTP callback which provides transfer information applies to other applications. The most important feature of webhook is the ability to transfer data real time. When an event is fired in an application, webhook sends this data to another application.

Webhook :Webhook是一个HTTP回调,它提供适用于其他应用程序的传输信息。 Webhook的最重要功能是实时传输数据的能力。 当在应用程序中触发事件时,webhook会将数据发送到另一个应用程序。

Pagerduty: We can define Pagerduty like this. Pagerduty is a service based operations performance platform which you can handle incidents and notifications in your business environment. Pagerduty can integrate a lot of monitoring services or tools. Pagerduty has advanced notification capability. It provides phone, e-mail or SMS notifications. At the same time, you can create and customize notification rules.

Pagerduty :我们可以这样定义Pagerduty。 Pagerduty是基于服务的运营绩效平台,您可以在业务环境中处理事件和通知。 Pagerduty可以集成许多监视服务或工具。 Pagerduty具有先进的通知功能。 它提供电话,电子邮件或SMS通知。 同时,您可以创建和自定义通知规则。

为Azure SQL创建警报规则 (Create an alert rule for Azure SQL)

Azure SQL offers a lot of feature for cloud databases. One of these features is the “Alert Rule”. Now we will look at them; how to create a database alert rule.

Azure SQL为云数据库提供了很多功能。 这些功能之一是“警报规则”。 现在我们来看一下它们; 如何创建数据库警报规则。

After login to Azure portal, we will navigate SQL databases and then click on “Alert Rules”.

登录到Azure门户后,我们将导航SQL数据库,然后单击“警报规则”。

azure云数据库_将Azure SQL数据库警报集成到Slack

azure云数据库_将Azure SQL数据库警报集成到Slack

We will click “Add alert” and will reach “Add an alert rule” screen.

我们将单击“添加警报”,然后进入“添加警报规则”屏幕。

azure云数据库_将Azure SQL数据库警报集成到Slack

In this screen, we have to fill some fields. This field has following definitions

在此屏幕中,我们必须填写一些字段。 该字段具有以下定义

Resource defines the name of SQL Server database name

资源定义SQL Server数据库名称的名称

Metric defines the performance counter where you want to get a notification

指标定义要在其中获得通知的性能计数器

Condition and Threshold define the formula of alert

条件和阈值定义警报的公式

Period defines how long time the metric remains in this condition

周期定义指标在此条件下保持多长时间

Email owners, contributors, and readers defines when the notification triggered these stakeholders will get an e-mail about notification

电子邮件所有者,贡献者和阅读者定义了通知何时触发,这些利益相关者将获得有关通知的电子邮件

Additional Administrator email(s) defines if you want to add additional emails you can add here

其他管理员电子邮件定义是否要添加其他电子邮件,可以在此处添加

Webhook defines where you can provide your webhook URL for which you want to transfer alerts.

Webhook定义了您可以在其中提供要为其传输警报的Webhook URL的位置。

Now we will complete definition about alerts. For this demonstration we will select “Failed Connections”. When somebody tries to connect Azure SQL and gets a connection error, this alert will be triggered. Also, you can find another metrics in this menu. These are;

现在,我们将完成有关警报的定义。 对于此演示,我们将选择“失败的连接”。 当有人尝试连接Azure SQL并收到连接错误时,将触发此警报。 另外,您可以在此菜单中找到其他指标。 这些是;

  • Blocked by Firewall

    被防火墙阻止
  • Failed Connections

    连接失败
  • Successfully connections

    成功连接
  • CPU percentage

    CPU百分比
  • Deadlocks

    死锁
  • DTU (Database Throughput Unit) percentage

    DTU(数据库吞吐量单位)百分比
  • DTU (Database Throughput Unit) limit

    DTU(数据库吞吐量单位)限制
  • DTU (Database Throughput Unit) used

    使用了DTU(数据库吞吐量单位)
  • LOG IO percentage

    LOG IO百分比
  • Data IO percentage

    数据IO百分比
  • Sessions percentage

    会话百分比
  • Total database size

    数据库总大小
  • Workers percentage

    工人比例
  • In-Memory OLTP storage percentage

    内存中OLTP存储百分比

azure云数据库_将Azure SQL数据库警报集成到Slack

As we need a webhook URL, we will provide this URL in Pagerduty. For this reason, we will login to Pagerduty and will set Pagerduty service settings and Slack integration.

由于我们需要一个Webhook URL,因此将在Pagerduty中提供此URL。 因此,我们将登录到Pagerduty并设置Pagerduty服务设置和Slack集成。

在Pagerduty中为Azure创建服务并集成到Slack (Create service for Azure in Pagerduty and integrate to Slack)

In this part of the article, we will log into to Pagerduty because we need the webhook URL. This URL provides communication between Azure and Pagerduty. When the notification is triggered, this alert information transfers to Pagerduty immediately. Another note about this communication is this data transfer uses JSON format.

在本文的这一部分中,我们将登录到Pagerduty,因为我们需要webhook URL。 此URL提供Azure和Pagerduty之间的通信。 触发通知后,此警报信息将立即传输到Pagerduty。 关于此通信的另一个说明是此数据传输使用JSON格式。

Now, we will log into Pagerduty and then will navigate “Configuration” and click “Services”.

现在,我们将登录到Pagerduty ,然后将导航至“配置”并单击“服务”。

azure云数据库_将Azure SQL数据库警报集成到Slack

We will click add news services and will select Azure.

我们将单击“添加新闻服务”,然后选择“ Azure”。

azure云数据库_将Azure SQL数据库警报集成到Slack

We will click “Add Service” and service will be created. This service provides webhook URL.

我们将单击“添加服务”,然后将创建服务。 该服务提供webhook URL。

In this step, we will integrate Pagerduty service to Slack.

在这一步中,我们将把Pagerduty服务集成到Slack。

azure云数据库_将Azure SQL数据库警报集成到Slack

We will click “New Extensions” and will select “Extension Type” as Slack. You can find another application for integration (JIRA, ServiceNow, Hipchat etc.)

我们将单击“新扩展名”,并将“扩展名类型”选择为“松弛”。 您可以找到另一个集成应用程序(JIRA,ServiceNow,Hipchat等)。

azure云数据库_将Azure SQL数据库警报集成到Slack

We will write slack account name and then click “Authorize”.

我们将输入松弛的帐户名,然后单击“授权”。

azure云数据库_将Azure SQL数据库警报集成到Slack

In order to complete this step, Pagerduty will redirect to the authorization page.

为了完成此步骤,Pagerduty将重定向到授权页面。

azure云数据库_将Azure SQL数据库警报集成到Slack

In this screen, we can select Slack channel where our messages will come. We have completed Pagerduty and Slack integration. Now, we need webhook URL. We can find this URL under the service “View” menu.

在此屏幕中,我们可以选择消息将进入的备用信道。 我们已经完成了Pagerduty和Slack的集成。 现在,我们需要webhook URL。 我们可以在“查看”菜单下找到该URL。

azure云数据库_将Azure SQL数据库警报集成到Slack

azure云数据库_将Azure SQL数据库警报集成到Slack

Now, we will return Azure portal and then copy this URL to Azure alert screen webhook field. Finally, we will click “OK”

现在,我们将返回Azure门户,然后将此URL复制到Azure警报屏幕webhook字段。 最后,我们将点击“确定”

azure云数据库_将Azure SQL数据库警报集成到Slack

After, we create an alert we can see this alert rules in the “Alert Rules” panel.

之后,我们创建一个警报,我们可以在“警报规则”面板中看到此警报规则。

azure云数据库_将Azure SQL数据库警报集成到Slack

When a notification occurs you can see this notification on Pagerduty web page.

发生通知时,您可以在Pagerduty网页上看到此通知。

azure云数据库_将Azure SQL数据库警报集成到Slack

At the same time, this notification will be sent to Slack. When I will log into my mobile phone Slack application, I can see the notification.

同时,此通知将发送到Slack。 当我登录到手机的Slack应用程序时,可以看到通知。

azure云数据库_将Azure SQL数据库警报集成到Slack

The above image was taken from a mobile device. In this image, we can find information about notificatiosn or you can change activity type “Acknowledge” or “Resolve” and this activity type information will be sent to Pagerduty.

上图是从移动设备上拍摄的。 在此图中,我们可以找到有关通知的信息,或者您可以更改活动类型“ Acknowledge”或“ Resolve”,并且该活动类型信息将发送到Pagerduty。

Conclusion

结论

This article’s goal is to combine the powerful benefits of different products. When we go back to the architecture diagram, you can see that, in fact, we have combined three different products to improve the speed, flexibility and ability to respond to monitoring alerts.

本文的目标是结合不同产品的强大优势。 回到架构图,您可以看到,实际上,我们结合了三种不同的产品,以提高速度,灵活性以及对监视警报的响应能力。

翻译自: https://www.sqlshack.com/integrating-azure-sql-database-alerts-into-slack/

azure云数据库