Embed and share the console
To share Cloud Monitor pages or embed them in a third-party system, you can generate passwordless, login-free links.
Usage notes
Generate a single passwordless link
To quickly get a passwordless link for temporary sharing, use the following method.
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-listObtain 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.
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****************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.
ImportantThis 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.
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.
Generate a Ticket as a RAM user. The following example uses Java:
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>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); } } }
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.