If an alert rule monitors data across projects, regions, or Alibaba Cloud accounts, Simple Log Service must assume a RAM role to access the target Logstores or Metricstores. Grant the required permissions to this role.
Scenarios
|
Authorization method |
Scenario |
|
Default |
Monitor different Logstores and Metricstores within the same project. |
|
Use a built-in role |
Monitor Logstores and Metricstores across different projects within the same Alibaba Cloud account. |
|
Custom Role |
Monitor Logstores or Metricstores across different Alibaba Cloud accounts with fine-grained permission control. |
Video tutorial
Step 1: Configure authorization
-
Specify a query statement. For more information, see Create an alert rule.
-
Configure an authorization method.
Use the default authorization method
To monitor different Logstores and Metricstores within the same Project, use the Default authorization method.
On the Advanced Settings tab, set Authorization Method to Default.
Use a built-in role
To monitor Logstores and Metricstores across multiple projects within an Alibaba Cloud account, assign a built-in role to Simple Log Service.
On the Advanced Settings tab, set Authorization Method to Built-in Role. If this is your first time, use the Alibaba Cloud account owner to complete the authorization as prompted. After authorization, Simple Log Service creates a RAM role named
AliyunSLSAlertMonitorRoleand assumes this role to read data from the source Logstores.Use a custom role (within an Alibaba Cloud account)
To monitor different Logstores or Metricstores within the same Alibaba Cloud account with fine-grained permission control, use a Custom Role.
-
Create a RAM role for a trusted Alibaba Cloud service, and select Simple Log Service as the trusted service.
-
Create a custom policy. On the JSON tab of the Create Policy page, replace the existing script in the code editor with the following policy document. For more information, see Using the script editor.
ImportantReplace
ProjectNamein the following script with your actual Project name. For more granular permissions, such as allowing alert rules to be created only in a specific Project, you can specify the Project in theResourceelement of the policy, for example,acs:log:*:*:project/my-project.{ "Statement": [ { "Action": [ "log:ListProject" ], "Effect": "Allow", "Resource": [ "acs:log:*:*:*" ] }, { "Action": [ "log:ListLogStores", "log:GetLogStoreLogs", "log:GetIndex" ], "Effect": "Allow", "Resource": [ "acs:log:*:*:project/Project name/*" ] } ], "Version": "1" } -
Attach the created custom policy to the RAM role. For more information, see Manage permissions for a RAM role.
What to do next
-
Obtain the Alibaba Cloud Resource Name (ARN) of the RAM role. For more information, see View a RAM role.
-
When you use Custom Role authorization, enter the ARN of the RAM role. For more information, see Create an alert rule.
On the Advanced Settings tab, set Authorization method to Custom Role, and then enter the ARN in the Role ARN input box.
Use a custom role (across multiple Alibaba Cloud accounts)
Monitor Logstores or Metricstores across multiple Alibaba Cloud accounts. For example, create an alert rule in Account A that monitors data in the Logstores or Metricstores of Account B.
Use Alibaba Cloud Account B to perform the following steps:
-
Create a RAM role for a trusted Alibaba Cloud service, and select Simple Log Service as the trusted service.
-
Modify the trust policy of the RAM role. For more information, see Edit the trust policy of a RAM role.
ImportantReplace
The ID of Alibaba Cloud account Awith the ID of account A. You can find the account ID in the account center.{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "ID of Alibaba Cloud Account A@log.aliyuncs.com", "log.aliyuncs.com" ] } } ], "Version": "1" } -
Create a custom policy. On the JSON tab of the Create Policy page, replace the existing script in the code editor with the following policy document. For more information, see Using the script editor.
ImportantReplace ProjectName with your actual Project name. For more granular permissions, such as allowing alert rules to be created only in a specific Project, you can specify the Project in the
Resourceelement of the policy, for example,acs:log:*:*:project/my-project.{ "Statement": [ { "Action": [ "log:ListProject" ], "Effect": "Allow", "Resource": [ "acs:log:*:*:*" ] }, { "Action": [ "log:ListLogStores", "log:GetLogStoreLogs", "log:GetIndex" ], "Effect": "Allow", "Resource": [ "acs:log:*:*:project/Project name/*" ] } ], "Version": "1" } -
Attach the created custom policy to the RAM role. For more information, see Manage permissions for a RAM role.
-
Obtain the Alibaba Cloud Resource Name (ARN) of the RAM role. For more information, see View a RAM role.
What to do next
-
Obtain the Alibaba Cloud Resource Name (ARN) of the RAM role. For more information, see View a RAM role.
-
When you create an alert rule in Alibaba Cloud account A, select Custom Role for authorization and enter the ARN of the RAM role from Alibaba Cloud account B in the Role ARN field. For more information, see Create an alert rule.
-
Step 2: Grant permissions to a RAM user
After you configure a Built-in Role or a Custom Role, if a RAM user needs to query a Metricstore or Logstore, the Alibaba Cloud account owner must attach the following permission policy to the RAM user to allow role passing. For more information, see Manage permissions for a RAM user.
{
"Action": "ram:PassRole",
"Effect": "Allow",
"Resource": "acs:ram::ID of Alibaba Cloud Account:Role ARN"
}