You can embed a Grafana dashboard into your self-managed web application to view it without logging on, which avoids switching between systems.
Limitations
You can only embed dashboards from the shared edition of Managed Service for Grafana into a self-managed web application.
Background information
By embedding a Grafana dashboard into your self-managed web application, you can:
-
Log on to your own system and view the embedded Grafana dashboard.
-
Hide the Grafana top navigation bar and left-side navigation pane. For instructions, see Step 5.
How it works
Step 1: Create a RAM user
Use your Alibaba Cloud account to create a RAM user and grant it permissions to call the Security Token Service (STS) AssumeRole operation.
-
Log on to the Resource Access Management (RAM) console with your Alibaba Cloud account (root account) or as a RAM administrator.
-
In the left-side navigation pane, choose Identities > Users.
-
On the Users page, click Create User.
-
On the Create User page, enter a Logon Name and Display name in the User Account Information section. In the Access Method section, select Console Access, and then click OK.
ImportantFor security, the RAM console displays the AccessKey secret only once. Be sure to save it in a secure location.
-
In the Create Authorization panel, add the AliyunSTSAssumeRoleAccess policy in the Policy section, and then click OK.
Step 2: Create a RAM role
Create a RAM role and grant it permissions to access the console. The RAM user will assume this role to access the console.
-
Grant the role full or read-only permissions on Application Real-Time Monitoring Service (ARMS). For instructions, see Manage permissions for a RAM role.
-
AliyunARMSFullAccess: Full permissions on ARMS.
-
AliyunARMSReadOnlyAccess: Read-only permissions on ARMS.
-
Step 3: Obtain temporary credentials
Log on to your self-managed web application. On the web server, call the STS AssumeRole operation to obtain temporary credentials: a temporary AccessKey ID, an AccessKey secret, and an STS token. For more information about the AssumeRole operation, see AssumeRole.
You can call the AssumeRole operation in one of the following ways:
-
Use OpenAPI Explorer.
-
Use the Java SDK.
This topic uses the Java SDK as an example.
When you use the Java SDK, specify the following parameters:
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 when you create the RAM user. For more information, see Create an AccessKey.
To obtain the Alibaba Cloud Resource Name (ARN) of the RAM role, perform the following steps:
-
On the RAM console, on the page, click the name of the target RAM role in the list.
-
On the role details page, copy the ARN in the Basic Information section.
Step 4: Obtain a logon token
After obtaining the temporary credentials by calling the STS AssumeRole operation, call the logon service to obtain a logon token.
The STS token returned by STS may contain special characters. You must URL-encode these characters before use.
Sample request:
https://signin.alibabacloud.com/federation?Action=GetSigninToken
&AccessKeyId=<The temporary AccessKey ID returned by STS>
&AccessKeySecret=<The temporary AccessKey secret returned by STS>
&SecurityToken=<The STS token returned by STS>
If you are a virtual network operator, you must also add the &TicketType=mini parameter.
Step 5: Generate a logon-free URL
Use the logon token and the URL of the Grafana dashboard you want to embed to generate a logon-free URL. This URL allows users to access the Grafana dashboard from your self-managed web application without logging on.
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 Grafana, get the URL of the dashboard you want to embed.
Note-
To hide the left-side navigation pane, add
kiosk=tvto the URL's query string. -
To hide the top navigation bar and left-side navigation pane, add
kioskto the URL's query string. -
To hide the top navigation bar and left-side navigation pane but keep the time range picker in the upper-right corner, add
kiosk=tv2to the URL's query string.
-
-
Use the logon token and the Grafana dashboard URL to generate the logon-free URL.
http://signin.alibabacloud.com/federation?Action=Login &LoginUrl=<The URL to which users are redirected if the logon fails. This is typically the URL that your application configures for 302 redirects.> &Destination=<The URL of the Grafana dashboard> &SigninToken=<The logon token you obtained> -
Open the logon-free URL in your browser.