You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Use other systems to analyze logs
Embed externally built systems into TLS console
Copy page
Download PDF
Embed externally built systems into TLS console
TLS provides a console embedding feature, which supports embedding the query and analysis page and dashboard page into the self-built web pages of external systems. You can log in to some pages of the TLS console without password in the external system and perform related actions. This article describes the steps to embed the TLS console into an external system.​
Background information​
The console's embedding feature leverages Security Token Service (STS) to enable custom identity proxy for users. You can grant IAM users access to specific data and pages, use this identity to create temporary credentials via STS, and obtain a temporary login token. When you access embedded TLS console pages, authentication is performed via the temporary login token encapsulated in the URL. No IAM user account and password are required during the access process, and the login is seamless. ​
Steps​
1 Obtain a temporary security token ​
When logging in to a self-built external system, you need to access Volcengine STS from the external system's server to get a temporary security token issued by STS. When accessing STS, you need to create an IAM role and grant log service resource access permissions for the IAM role. You also need to create an IAM user to assume the specified IAM role and send an AssumeRole request as the IAM user to obtain a temporary security token. This temporary security token can be used to access TLS resources within the IAM role's permission scope. For more details, see Access logging services through STS.​
The process for creating an IAM role, granting permissions, and obtaining a temporary security token is as follows. For details, see Access logging services through STS.​
  1. Create an IAM role.​
  1. Grant TLS permissions to the IAM role.​
  • On the embedded TLS console page, you can grant the IAM role the system default permission TLSReadOnlyAccess, which allows the role to view all TLS resources and pages. You can also create custom authorization policies based on the list of TLS operations and resources that can be authorized. For details, see Authorizable operation and delegated resources.​
  1. Create an IAM user.​
  1. Grant the IAM user permissions to assume an IAM role and call AssumeRole.​
  1. Set a trust policy for the IAM role to allow the specified IAM user to assume this role.​
  1. Grant the IAM user STSAssumeRoleAccess permission.​
  1. Call the AssumeRole API to obtain temporary security credentials.​
Notice​
The DurationSeconds request parameter in the AssumeRole API specifies the validity period of the temporary security token. After it expires, you need to call the API again to obtain a new temporary security token, which is required to request a login Token.​
2 Obtain login Token​
The login Token (SigninToken) is a temporary access Token provided by the STS service. External system servers must use the login Token to generate password-free access links for TLS.​
Call the STS API getSigninTokenWithSTS to obtain the login Token. In the request, temporary AK, SK, and sessionToken are required to specify, all of which are temporary security tokens obtained from 1 Obtain a temporary security token Create a sub-user.​
Notice​
  • The login Token is valid for 15 minutes by default and can not be changed. Make sure to build and authenticate the access link before the Token expires. After expiration, you must request a new login Token from getSigninTokenWithSTS.​
  • After completing a login with the login Token, it becomes invalid. If you refresh the page, you will need to request a new login Token.​
Example:​
​
https://console.volc-embed.com/api/passport/login/getSigninTokenWithSTS​
&accessKeyId=<temporary AK obtained via AssumeRole>​
&secretAccessKey=<temporary Secret obtained via AssumeRole>​
&sessionToken=<temporary Token obtained via AssumeRole>​
&sessionDuration=<The duration of login state. You need to log in if it expires. The unit is second, ranging from 900 to 43200.>​
​
3 Generate password-free access link​
The password-free access link format for TLS console is as follows.​
​
https://console.volc-embed.com/api/passport/login/loginWithSigninToken?signinToken=${signinToken}&redirectURI=${target_console_url}​
​
Parameters in the link are described in the following table.​
​
Parameters​
Description​
signinToken​
The login token obtained in Step 2.​
redirectURI​
Supports access links for embedded TLS pages. Currently, the query and analysis page and dashboard page support embedded TLS.​
Notice​
  • Before using the following redirectURI link, encode the link with encodeURL first. That is to say, you need to replace ${regionId}, ${projectId}, and ${dashboardId} in the link with actual values, and then encode the URL using encodeURL.​
  • Query and analysis page​
  • ​
    https://console.volc-embed.com/tls/region:tls+${regionId}/project/${projectId}/search?​
    ​
  • Dashboard page​
  • ​
    https://console.volc-embed.com/tls/region:tls+${regionId}/project/${projectId}/dashboard/${dashboardId}​
    ​
​
4 Embed pages in external systems​
Embed TLS console into third-party custom web pages using iFrame. You can refer to the following examples to embed the TLS console page into external systems. The src value should be set to the password-free access link generated in step 3.p​
Notice​
To avoid access issues caused by browser compatibility, we recommend using Chrome to visit this page.​
​
<body> ​
<iframe src="target_url" width="1200" height="800" id="tlsIframePage"></iframe> ​
</body>​
​
FAQs​
How to set the login session duration for embedded pages​
After logging into log service console page via a third-party system's web page without a password, the login status will be maintained for a period of time. After expiration, the application server needs to reacquire and refresh the Token so that the user can log in again.​
The login duration of the embedded page is specified by the sessionDuration parameter in the getSigninTokenWithSTS API. When calling the getSigninTokenWithSTS API, set the login duration for the embedded page using the sessionDuration request parameter. The sessionDuration is measured in seconds and can be set from 900 to 43,200.​
The login session duration for embedded pages (sessionDuration) follows the DurationSeconds parameter of the AssumeRole API by default, which is set to 1 hour. By default, the ExpiredTime returned by the AssumeRole API is both the expiration time of the temporary security token and the end time of the login session.​
Code examples​
Node.js​
​
const {Service} = require('@volcengine/openapi');​
const axios= require("axios");​
​
class StsService extends Service {​
constructor(props) {​
super({​
...props,​
defaultVersion: "2018-01-01",​
serviceName: "sts",​
});​
}​
}​
​
async function main() {​
const stsService = new StsService()​
stsService.setAccessKeyId('xxx');​
stsService.setSecretKey('yy')​
stsService.setHost('sts.volcengineapi.com')​
​
// Call assumeRole to obtain a temporary security token.​
const assumeRole = stsService.createAPI('AssumeRole', {​
method: 'GET',​
});​
​
const token = await assumeRole({​
RoleTrn: 'trn:iam::${accountId}:role/${user name}',​
RoleSessionName: 'tlsiframe'​
})​
​
const { AccessKeyId, SecretAccessKey, SessionToken } = token.Result.Credentials;​
​
​
// Obtain the login token using the temporary security token.​
const signinResp = await axios.post('https://console.volc-embed.com/api/passport/login/getSigninTokenWithSTS', {​
"accessKeyId": AccessKeyId,​
"secretAccessKey": SecretAccessKey,​
"sessionToken": SessionToken​
})​
​
const signinToken = signinResp.data.Result.SigninToken;​
​
// Generate a password-free login link using signinToken.​
const url = `https://console.volc-embed.com/api/passport/login/loginWithSigninToken?signinToken=${signinToken}&redirectURI=${encodeURIComponent('https://console.volc-embed.com/tls/region:tls+cn-beijing/project/${projectId}/search')}`​
console.log(url)​
}​
main();​
​
Python​
​
# coding=utf-8​
from __future__ import absolute_import​
from __future__ import division​
from __future__ import print_function​
​
import os​
import json​
import requests​
​
from urllib.parse import quote​
from volcengine.sts.StsService import StsService​
​
​
if __name__ == "__main__":​
# When initializing the client, it is recommended to dynamically obtain identity authentication information such as Volcengine AccessKeys through environment variables, so as to avoid data security risks caused by hard-coding AccessKeys. For detailed instructions, please refer to https://www.volcengine.com/docs/6470/1166455.​
access_key_id = os.environ["VOLCENGINE_ACCESS_KEY_ID"]​
access_key_secret = os.environ["VOLCENGINE_ACCESS_KEY_SECRET"]​
​
sts_service = StsService()​
sts_service.set_ak(access_key_id)​
sts_service.set_sk(access_key_secret)​
​
role_trn = "trn:iam::yourAccountID:role/yourRole"​
role_session_name = "tlsiframe"​
target_console_url = "https://console.volc-embed.com/tls/region:tls+cn-beijing"​
​
# Call the AssumeRole interface to obtain the temporary security token.​
assume_role_params = {​
"DurationSeconds": "900",​
"RoleSessionName": role_session_name,​
"RoleTrn": role_trn​
}​
assume_role_resp = sts_service.assume_role(assume_role_params)​
​
assume_rule_ak = assume_role_resp["Result"]["Credentials"]["AccessKeyId"]​
assume_role_sk = assume_role_resp["Result"]["Credentials"]["SecretAccessKey"]​
session_token = assume_role_resp["Result"]["Credentials"]["SessionToken"]​
​
# Obtain login token.​
url_str = "https://console.volc-embed.com/api/passport/login/getSigninTokenWithSTS"​
url_str = url_str + "?accessKeyId=" + quote(assume_rule_ak)​
url_str = url_str + "&secretAccessKey=" + quote(assume_role_sk)​
url_str = url_str + "&sessionToken=" + quote(session_token)​
url_str = url_str + "&sessionDuration=3600"​
​
get_signin_token_with_sts_resp = json.loads(requests.post(url_str).content)​
signin_token = get_signin_token_with_sts_resp["Result"]["SigninToken"]​
​
# Build password-free access links.​
result = "https://console.volc-embed.com/api/passport/login/loginWithSigninToken"​
result = result + "?signinToken=" + quote(signin_token)​
result = result + '&redirectURI=' + quote(target_console_url)​
​
print(result)​
​
Go​
​
​
package main​
​
import (​
"encoding/json"​
"fmt"​
"io/ioutil"​
"net/http"​
"net/url"​
​
"github.com/volcengine/volc-sdk-golang/service/sts"​
)​
​
var ( // Set by yourself​
testAk = ""​
testSk = ""​
roleTrn = ""​
roleSessionName = ""​
targetConsoleUrl = ""​
)​
​
func main() {​
var ( // Calculated in demo​
accessKeyId string​
secretAccessKey string​
sessionToken string​
signinToken string​
generatedUrl string​
)​
​
var client = &http.Client{}​
// 1. Obtain a temporary security token​
{​
sts.DefaultInstance.Client.SetAccessKey(testAk)​
sts.DefaultInstance.Client.SetSecretKey(testSk)​
​
resp, _, err := sts.DefaultInstance.AssumeRole(&sts.AssumeRoleRequest{​
DurationSeconds: 900,​
RoleTrn: roleTrn,​
RoleSessionName: roleSessionName,​
})​
if err != nil {​
panic(err)​
}​
accessKeyId = resp.Result.Credentials.AccessKeyId​
secretAccessKey = resp.Result.Credentials.SecretAccessKey​
sessionToken = resp.Result.Credentials.SessionToken​
}​
​
// 2. Obtain login token​
{​
urlStr := "https://console.volc-embed.com/api/passport/login/getSigninTokenWithSTS"​
urlStr += "?accessKeyId=" + url.QueryEscape(accessKeyId)​
urlStr += "&secretAccessKey=" + url.QueryEscape(secretAccessKey)​
urlStr += "&sessionToken=" + url.QueryEscape(sessionToken)​
urlStr += "&sessionDuration=3600"​
​
req, err := http.NewRequest("POST", urlStr, nil)​
if err != nil {​
panic(err)​
}​
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")​
​
rawResp, err := client.Do(req)​
if err != nil {​
panic(err)​
}​
defer rawResp.Body.Close()​
body, _ := ioutil.ReadAll(rawResp.Body)​
​
type GetSigninTokenWithSTSResp struct {​
Result struct {​
SigninToken string​
}​
}​
var resp GetSigninTokenWithSTSResp​
json.Unmarshal(body, &resp)​
signinToken = resp.Result.SigninToken​
}​
​
// 3. Build a password-free access link​
{​
urlStr := "https://console.volc-embed.com/api/passport/login/loginWithSigninToken"​
urlStr += "?signinToken=" + url.QueryEscape(signinToken)​
urlStr += "&redirectURI=" + url.QueryEscape(targetConsoleUrl)​
generatedUrl = urlStr​
}​
fmt.Printf("Generated url: %s\n", generatedUrl)​
return​
}​
​
​
Last updated: 2026.03.12 18:50:42