Embed and share the console

Updated at:

To share Cloud Monitor pages or embed them in a third-party system, you can generate passwordless, login-free links.

Usage notes

Key concepts

Each passwordless, login-free link consists of three parts: a fixed URL, configuration parameters, and an access credential. The access credential is a short-lived, single-use token. Users with the link can access the specified page without logging in to an Alibaba Cloud account.

The following example shows the URL format:

https://cmsnext.console.aliyun.com/next/region/<RegionId>/workspace/<WorkspaceName>/app/apm/application-list?parameter1&parameter2
Note
  • Parameters other than <RegionId> and <WorkspaceName> must be placed after the question mark (?) at the end of the URL.

  • You can set multiple parameters. Separate parameters with an ampersand (&).

Required permissions

  1. If you are a RAM user, grant permissions based on the required operations as described in the following table:

    Important

    The generated link inherits the permissions of the user or role that calls the CreateTicket API. To avoid the security risks of using a primary account, we recommend calling the API as a RAM user.

    Scenario

    Required actions

    Generate a single link

    1. For instructions on how to grant permissions on specific resources, see Examples of custom RAM policies.

    2. To grant permissions to call the CreateTicket API, see Manage RAM user permissions and Create a custom policy.

    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "cms:CreateTicket",
                "Resource": "acs:cms:*:*:ticket/*"
            }
        ]
    }

    Dynamically generate links

    1. Create a RAM user and create a RAM role for a trusted Alibaba Cloud account.

    2. Grant the RAM user STS management permissions (AliyunSTSAssumeRoleAccess). The RAM role requires permissions to call the CreateTicket API. For authorization instructions, see Manage the permissions of a RAM role and Examples of custom RAM policies.

  2. If you use a primary account, you have all permissions by default.

Generate a single passwordless link

To quickly get a passwordless link for temporary sharing, use the following method.

  1. Prepare the link: Log on to the Cloud Monitor 2.0 console. For the values of <RegionId> and <WorkspaceName>, refer to the name and region of your workspace.

    https://cmsnext.console.aliyun.com/next/region/<RegionId>/workspace/<WorkspaceName>/app/apm/application-list
  2. Obtain a Ticket: Call the CreateTicket API to get a Ticket. Each Ticket is single-use for a specific browser or host and expires after one day by default.

  3. Build the link: Append the Ticket to the URL to generate a passwordless, login-free access link.

    https://cmsnext.console.aliyun.com/next/region/<RegionId>/workspace/<WorkspaceName>/app/apm/application-list?sls_ticket=eyJ***************.eyJ******************.KUT****************
  4. Test the link: Paste the generated link into your browser's address bar to test it. If the page opens correctly, the link was created successfully.

    Important
    • This test counts as the link's single use. The Ticket becomes invalid after the test, so you must generate a new one for sharing.

    • We recommend copying the link into a file and then transferring the file. If you send the link directly through third-party software, the link may become invalid if the software pre-fetches it.

Embed in third-party systems: Generate dynamic links

Because links expire when their Tickets do, you must dynamically call the CreateTicket API from your application to periodically generate new Tickets when embedding console pages.

Note
  • By default, a Ticket is valid for 24 hours.

  • While there is no limit on the total number of Tickets you can generate, the CreateTicket API is throttled at 10 QPS per user.

  1. Generate a Ticket as a RAM user. The following example uses Java:

    1. Add Maven dependencies: In the root directory of your Java project, open the pom.xml file and add the following code:

          <dependency>
          <groupId>com.aliyun</groupId>
          <artifactId>cms20240330</artifactId>
          <version>2.3.0</version>
          </dependency>
          <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-openapi</artifactId>
            <version>0.3.2</version>
          </dependency>
          <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-console</artifactId>
            <version>0.0.1</version>
          </dependency>
          <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-util</artifactId>
            <version>0.2.21</version>
          </dependency>
    2. Use the AccessKey pair of the RAM user to create a Ticket. For more information about endpoints, see Endpoints.

      import com.aliyun.tea.*;
      public class Sample {
          /**
           * Use an AccessKey pair (AK/SK) to initialize the client.
           * @return Client
           * @throws Exception
           */
          public static com.aliyun.cms20240330.Client createClient() throws Exception {
              // Hard-coding your AccessKey pair in the project code can lead to security risks. This sample code is for reference only.
              // We recommend using STS for a more secure approach.
              com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                      // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
                      .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                      // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
                      .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
              config.endpoint = "cms.cn-shanghai.aliyuncs.com";
              return new com.aliyun.cms20240330.Client(config);
          }
          public static void main(String[] args_) throws Exception {
              java.util.List<String> args = java.util.Arrays.asList(args_);
              com.aliyun.cms20240330.Client client = Sample.createClient();
              com.aliyun.cms20240330.models.CreateTicketRequest createTicketRequest = new com.aliyun.cms20240330.models.CreateTicketRequest();
              com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
              java.util.Map<String, String> headers = new java.util.HashMap<>();
              try {
                  com.aliyun.cms20240330.models.CreateTicketResponse resp = client.createTicketWithOptions(createTicketRequest, headers, runtime);
                  com.aliyun.teaconsole.Client.log(com.aliyun.teautil.Common.toJSONString(resp));
              } catch (TeaException error) {
                  // The following code is for demonstration purposes only. In a production environment, implement proper exception handling and do not ignore exceptions.
                  // Error message
                  System.out.println(error.getMessage());
                  // Diagnostic address
                  System.out.println(error.getData().get("Recommend"));
                  com.aliyun.teautil.Common.assertAsString(error.message);
              } catch (Exception _error) {
                  TeaException error = new TeaException(_error.getMessage(), _error);
                  // The following code is for demonstration purposes only. In a production environment, implement proper exception handling and do not ignore exceptions.
                  // Error message
                  System.out.println(error.getMessage());
                  // Diagnostic address
                  System.out.println(error.getData().get("Recommend"));
                  com.aliyun.teautil.Common.assertAsString(error.message);
              }
          }
      }
  2. Use the returned Ticket to build the passwordless, login-free link.

Adjust the page display

You can customize the embedded page's display by setting console parameters. Cloud Monitor 2.0 provides various UI parameters to help you integrate the console with your web pages.

Parameters

Common parameters

Parameter

Type

Required

Description

Example

hideSiderbar

boolean

No

Hides the left-side menu.

hideSiderbar=true

hideBreadcrumb

boolean

No

Hides the breadcrumb.

hideBreadcrumb=true

hideTopbar

boolean

No

Hides the Alibaba Cloud global header.

hideTopbar=true

hiddenBack

boolean

No

Hides the back button.

The back button is the ← arrow icon in the service navigation bar, located to the right of the quick query entry.

hiddenBack=true

hiddenCopilot

boolean

No

Hides Copilot.

On an application details page (for example, frontend), a pin/bookmark icon is displayed to the left of the application name and at the far right of the toolbar. Clicking this icon hides Copilot.

hiddenCopilot=true

hideTopbarTabs

boolean

No

Hides the tabs under the app.

The tabs under the app include application monitoring, application list, application topology, trace analysis, continuous profiling, Scenario Analysis, alert management, System Management, and the time picker on the right.

hideTopbarTabs=true

hideEntityTopbar

boolean

No

Hides the app header.

This header refers to the top navigation area of application monitoring, which includes tabs such as application monitoring, application list, application topology, trace analysis, continuous profiling, Scenario Analysis, alert management, and System Management.

hideEntityTopbar=true

var_app_forbiddenTabs

string

No

Hides specified tabs. To hide multiple tabs, separate them with commas.

var_app_forbiddenTabs=metric-explorer,log-explorer

readOnly

boolean

No

Enables read-only mode, which disables dashboard editing.

readOnly=true

hideAlertManagement

boolean

No

Hides alerts. This parameter is currently applicable only to application monitoring.

hideAlertManagement=true

ONLY_ENTITY_OVERVIEW

boolean

No

Restricts navigation to entity query routes. Attempting to navigate outside these routes displays a "no permission" message. Note: This check does not apply to the initial page view.

ONLY_ENTITY_OVERVIEW=true

queryTimeType

long

No

Specifies the time range for queries and analysis. Valid values:

  • 1 to 26: Specifies a predefined time range corresponding to the number.

  • -2: Custom (Relative). You must also configure the start and end parameters. Example: start:-10m,end:now.

  • -3: Custom (On-the-hour). You must also configure the start and end parameters. Example: start:-2h,end:absolute.

  • 99: Custom time range. You must set the startTime and endTime parameters as timestamps.

queryTimeType=2

startTime

timestamp (date)

No

Specifies the start of the query time range. This parameter applies only when queryTimeType is set to 99.

startTime=1547776643

endTime

timestamp (date)

No

Specifies the end of the query time range. This parameter applies only when queryTimeType is set to 99.

endTime=1547776731

Data explorer and dashboard

Parameter

Type

Required

Description

Example

renderChartOnly

boolean

No

Renders only the chart.

renderChartOnly=true

hideDatasourceType

boolean

No

Hides the data source selector.

The data source type drop-down list (currently showing Prometheus) at the top left of the query configuration interface is the data source selector.

hideDatasourceType=true

fixDatasourceConfig

boolean

No

Locks data source configuration options. When this parameter is enabled, options in the query editor, such as region and instance, are locked and cannot be modified.

fixDatasourceConfig=true

chartType

Enum

No

The chart type. Valid values: tablepro, linepro.

In the Prometheus query results area, you can click the Line (linepro) tab to switch to a line chart view to analyze the metric trend.

chartType=linepro

hideChartSelect

boolean

No

hideChartSelect=true

queries

Array<Query>

No

Query configuration.

The query configuration area contains the following elements: at the top are the metrics explorer button (Metric count: 0) and the region and instance filter inputs; in the middle is the expression editor row, where you can enter query expressions; at the bottom are four settings: legend, min step (Auto by default), format (Time series by default), and type (Range query by default).

queries=[{"refId":"A",

"datasource":{"type":"prometheus"},

"regionId":"cn-beijing",

"clusterId":"caa66a552a02846fbb15de610be39ce3c",

"expr":"up"}]

datasourceTypeList

Array<string>

No

List of data source plug-ins.

datasourceTypeList=["prometheus","logstore"]

datasourceConfig

Array<Object>

No

Specifies the configuration for each data source plug-in.

datasourceConfig={"regionList":[{"label":"Beijing","value":"cn-beijing"},{"label":"Shanghai","value":"cn-shanghai"}],"clusterList":[{"label":"Visualization Cluster","value":"caa66a552a02846fbb15de610be39ce3c"},{"label":"Visualization Cluster 2","value":"cluster2"}],"projectList":[{"label":"project1","value":"project1"},{"label":"project2","value":"project2"}],"logstoreList":[{"label":"logstore1","value":"logstore1"},{"label":"logstore2","value":"logstore2"}]}

tags

Array

No

Tags.

tags=[{"key":"a","value":"b"}]