Embed an ARMS console page in a self-managed web application
You can embed the Application Real-Time Monitoring Service (ARMS) console into your self-managed web application to view ARMS pages without separate logins or switching between systems.
Background
Embedding the ARMS console into your self-managed web application lets you:
-
Log in to your own system and browse embedded ARMS console pages, such as the application list, application details, and traces.
-
Hide the top navigation bar and left-side navigation pane of the ARMS console. For more information, see Hide the navigation bars.
-
Use Resource Access Management (RAM) to control permissions, for example, by changing full permissions to read-only permissions. For more information, see Use a RAM user to grant permissions.
Workflow
Step 1: Create a RAM user and grant permissions
Create a RAM user with your Alibaba Cloud account and grant the user permission to call Security Token Service (STS) to assume a RAM role.
-
Create a RAM user. For more information, see Create a RAM user.
-
Grant the AliyunSTSAssumeRoleAccess permission to the RAM user. For more information, see Manage permissions for a RAM user.
Step 2: Create a RAM role and grant permissions
Create a RAM role with console access permissions for the RAM user to assume.
-
Create a RAM role. For more information, see Create a RAM role for a trusted Alibaba Cloud account.
-
Grant the RAM role full or read-only permissions. For more information, see Manage permissions for a RAM role.
-
AliyunARMSFullAccess: Full permissions for ARMS.
-
AliyunARMSReadOnlyAccess: Read-only permissions for ARMS.
ImportantTo grant read-only permissions on all ARMS features, you must configure the ReadTraceApp permission for specific resource groups in addition to attaching the AliyunARMSReadOnlyAccess policy. Otherwise, ARMS cannot display the application list that belongs to the authenticated resource group.
-
Step 3: Obtain a temporary AccessKey and security token
Log in to your self-managed web application, and then call the STS AssumeRole operation on the web server to obtain a temporary AccessKey pair and security token as temporary credentials. For more information, see AssumeRole.
Call the AssumeRole operation in one of the following ways:
-
Call the operation in OpenAPI Explorer.
-
Call the operation by using the Java SDK.
The following example uses the Java SDK.
Specify the following parameters when using the Java SDK:
String accessKey = "<accessKeyId>"; //The AccessKey ID of the RAM user.
String accessSecret = "<accessKeySecret>"; //The AccessKey secret of the RAM user.
String roleArn = "<roleArn>"; //The ARN of the RAM role.
You obtain the AccessKey ID and AccessKey secret of the RAM user when you create it. For more information, see Create an AccessKey.
To obtain the ARN of the RAM role, perform the following steps:
Log on to the RAM console as a RAM administrator.
In the left-side navigation pane, choose . You can filter RAM roles by type or search for a specific role. You can view automatically created service-linked roles on the Roles page in the RAM console, or in the response of the ListRoles API operation or the corresponding CLI command.
On the Roles page, click the name of the target RAM role.
-
In the Basic Information section of the RAM role details page, copy the ARN.
Step 4: Obtain a logon token
After you obtain the temporary AccessKey pair and security token from the AssumeRole operation, call the logon service API to obtain a logon token.
The security token from STS may contain special characters. You must URL-encode them before using the token.
Sample request:
https://signin.aliyun.com/federation?Action=GetSigninToken
&AccessKeyId=<Temporary AccessKeyId returned by STS>
&AccessKeySecret=<Temporary AccessKeySecret returned by STS>
&SecurityToken=<Security token returned by STS>
&TicketType=mini
Step 5: Generate a logon-free URL
Use the logon token and the URL of the target ARMS console page to generate a logon-free access URL.
The logon token is valid for three hours. We recommend that you configure your web application to generate a new logon token for each request.
-
In the ARMS console, obtain the URL of the console page that you want to embed.
For example, the URL for an application page in the China (Hangzhou) region is:
https://arms4service.console.aliyun.com/apm?iframeMode=true&pid=${pid}®ionId=${regionId}#/${pid}/homeEndpoints for each region:
-
China (legacy console): arms4service.console.aliyun.com
-
China (new console): armsnext4service.console.aliyun.com
-
Japan: arms-jp4service.console.aliyun.com
-
Southeast Asia: arms-sg4service.console.aliyun.com
-
US: arms-us4service.console.aliyun.com
-
Europe: arms-eu4service.console.aliyun.com
Note-
The URL must be a console address for ARMS application monitoring or browser monitoring; obtain the values for
{pid}and{regionId}from the actual URL. -
To hide the top navigation bar and left-side navigation pane of the ARMS console, add
iframeMode=trueto the search section of the URL. -
To hide only the top navigation bar, add
hideTopbar=trueto the search section of the URL. To hide only the left-side navigation pane, addhideSidebar=true. Using both parameters is equivalent to addingiframeMode=true. If the URL contains a hash value (#), you must place these parameters before the#character. Example:https://trace4service.console.aliyun.com/?hideTopbar=true&hideSidebar=true/#/tracing/${regionId}/list?from=now-3h&to=now&refresh=off.
-
-
Use the logon token and the URL of the ARMS console page to generate a logon-free access URL.
https://signin.aliyun.com/federation?Action=Login &LoginUrl=<The URL to which you are redirected when the logon expires. In most cases, set this to a URL that triggers a 302 redirect from your self-managed web application.> &SigninToken=<The logon token you obtained> &Destination=<The URL of the ARMS console page> -
Access the logon-free URL in a browser.
FAQ
"frame-ancestors" error when using an iframe
Due to security policies, you must use a dedicated service endpoint to embed a page in an iframe. To do this, add the &TicketType=mini parameter as described in Step 4. Then, use the service endpoint domain, https://arms4service.console.aliyun.com, for the Destination URL when generating the link described in Step 5.