Template Variables

Last updated: 2021-06-03 16:20:53

    Overview

    Templates and variables are dashboard optimization features offered by Grafana to create highly reusable and interactive dashboards. They allow Grafana to get different metrics from data sources and provide a way to dynamically modify them without modifying dashboards. The Tencent Cloud Monitor App currently provides variables such as region, CVM instance, and TencentDB for MySQL instance.

    Note:

    All instance queries allow customizing drop-down list values by the display field, for example: Namespace=QCE/REDIS&Action=DescribeInstances&Region=$region&display=${InstanceId}-${InstanceName}. If display and InstanceAlias appear at the same time, the drop-down list will only show the values of display.

    The following table lists currently available template variables:

    Variable Description Example
    Region See here. Action is fixed at DescribeRegions. Namespace is the namespace of the corresponding Tencent Cloud service, for example, QCE/CVM or QCE/CDB. Only one region can be selected. If you select multiple regions or the All option, the first region value will be used by default. Namespace=QCE/CVM&Action=DescribeRegions
    CVM instance See here. Namespace is fixed at QCE/CVM. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName, PrivateIpAddresses, or PublicIpAddresses. One or more CVM instances can be selected. Namespace=QCE/CVM&Region=ap-beijing&Action=DescribeInstances&InstanceAlias=PublicIpAddresses
    TencentDB for MySQL instance See here. Namespace is fixed at QCE/CDB. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName or Vip. One or more TencentDB instances can be selected. Namespace=QCE/CDB&Region=ap-beijing&Action=DescribeInstances&InstanceAlias=InstanceId
    TencentDB for PostgreSQL instance See here. Namespace is fixed at QCE/CDB. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is DBInstanceId by default and can also be DBInstanceName, PrivateIpAddresses, or PublicIpAddresses. One or more TencentDB instances can be selected. Namespace=QCE/POSTGRES&Region=ap-beijing&Action=DescribeInstances&InstanceAlias=DBInstanceId
    VPC NAT Gateway instance See here. Namespace is fixed at QCE/NAT_GATEWAY. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is NatGatewayId by default and can also be NatGatewayName. One or more NAT Gateway instances can be selected. Namespace=QCE/NAT_GATEWAY&Region=ap-beijing&Action=DescribeInstances&InstanceAlias=NatGatewayId
    VPC Peering Connection instance Namespace is fixed at QCE/PCX. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is peeringConnectionId by default and can also be peeringConnectionName. One or more Peering Connection instances can be selected (CLB does not support selecting multiple instances. Select multiple listeners for it instead). Namespace=QCE/PCX&Region=ap-beijing&Action=DescribeInstances&InstanceAlias=peeringConnectionId
    CLB instance See here. Namespace can be QCE/LB_PRIVATE, QCE/LB_PUBLIC, or QCE/LOADBALANCE. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-guangzhou or a variable value such as $region. InstanceAlias is the display field of the instance, which is LoadBalancerId by default and can also be LoadBalancerName or LoadBalancerVips. One or more CLB instances can be selected. Namespace=QCE/LB_PRIVATE&Action=DescribeInstances&Region=$region&InstanceAlias=LoadBalancerId
    CLB listener See here. Namespace can be QCE/LB_PRIVATE, QCE/LB_PUBLIC, or QCE/LOADBALANCE. Action is fixed at DescribeListeners. Region is the region parameter, which can be a specific region value such as ap-guangzhou or a variable value such as $region. Instance is the instance ID, which can be a specific instance ID such as lbl-rbw529fz or a variable value such as $instance. listenerAlias is the display field of the listener, which is ListenerId by default and can also be ListenerName or Port. One or more CLB listeners can be selected. Namespace=QCE/LB_PRIVATE&Action=DescribeListeners&Region=$region&Instance=$instance&listenerAlias=ListenerId
    TencentDB for MongoDB See here. Namespace is fixed at QCE/CMONGO. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more TencentDB for MongoDB instances can be selected. Namespace=QCE/CMONGO&Region=$region&Action=DescribeInstances
    TencentDB for Redis See here. Namespace is fixed at QCE/REDIS. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more TencentDB for Redis instances can be selected. Namespace=QCE/REDIS&Region=$region&Action=DescribeInstances
    Content Delivery Network (CDN) See here. Namespace is fixed at QCE/CDN. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is Domain by default and can also be ProjectId. One or more CDN instances can be selected. Namespace=QCE/CDN&Region=$region&Action=DescribeInstances
    Bandwidth Package (BWP) See here. Namespace is fixed at QCE/BWP. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is BandwidthPackageId by default and can also be BandwidthPackageName. One or more BWP instances can be selected. Namespace=QCE/BWP&Region=$region&Action=DescribeInstances
    Message Queue CKafka See here. Namespace is fixed at QCE/CKAFKA. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more CKafka instances can be selected. Namespace=QCE/CKAFKA&Region=$region&Action=DescribeInstances
    Elastic IP (EIP) See here. Namespace is fixed at QCE/LB. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is AddressId by default and can also be AddressName or AddressIp. One or more EIP instances can be selected. Namespace=QCE/LB&Region=$region&Action=DescribeInstances
    Cloud File Storage (CFS) See here. Namespace is fixed at QCE/CFS. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is FileSystemId by default and can also be FsName. One or more CFS instances can be selected. Namespace=QCE/CFS&Region=$region&Action=DescribeInstances
    Serverless Cloud Function (SCF) See here. Namespace is fixed at QCE/SCF_V2. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is FunctionId by default and can also be FunctionName. One or more SCF instances can be selected. Namespace=QCE/SCF_V2&Region=$region&Action=DescribeInstances
    Direct Connect - Dedicated Tunnel (DCX) See here. Namespace is fixed at QCE/DCX. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is DirectConnectTunnelId by default and can also be DirectConnectTunnelName. One or more DCX instances can be selected. Namespace=QCE/DCX&Region=$region&Action=DescribeInstances
    Direct Connect - Connection (DC) See here. Namespace is fixed at QCE/DC. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is DirectConnectId by default and can also be DirectConnectName. One or more DC instances can be selected. Namespace=QCE/DC&Region=$region&Action=DescribeInstances
    TencentDB for CYNOSDB_MYSQL Namespace is fixed at QCE/CYNOSDB_MYSQL. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more TencentDB for CYNOSDB_MYSQL instances can be selected. Namespace=QCE/CYNOSDB_MYSQL&Region=$region&Action=DescribeInstances
    TencentDB for TcaplusDB See here Namespace is fixed at QCE/TCAPLUS. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more TencentDB for TcaplusDB instances can be selected. Namespace=QCE/TCAPLUS&Region=$region&Action=DescribeInstances
    TencentDB for SQL Server See here. Namespace is fixed at QCE/SQLSERVER. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be Name. One or more TencentDB for SQL Server instances can be selected. Namespace=QCE/SQLSERVER&Region=$region&Action=DescribeInstances
    VPC - VPN Gateway See here. Namespace is fixed at QCE/VPNGW. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is VpnGatewayId by default and can also be VpnGatewayName. One or more VPN Gateway instances can be selected. Namespace=QCE/VPNGW&Region=$region&Action=DescribeInstances
    VPC - Direct Connect Gateway (DCG) See here. Namespace is fixed at QCE/DCG. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is DirectConnectGatewayId by default and can also be DirectConnectGatewayName. One or more Direct Connect Gateway instances can be selected. Namespace=QCE/DCG&Region=$region&Action=DescribeInstances
    CDN - Province Domain See here. Namespace is fixed at QCE/CDN_LOG_DATA. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is Domain by default and can also be ProjectId. Namespace=QCE/CDN_LOG_DATA&Region=$region&Action=DescribeInstances
    CDN - Province ISP See here. Namespace is fixed at QCE/CDN_LOG_DATA. Action is fixed at DescribeMapInfo. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. Instance is the display field of the instance and can be a variable value such as $instance. Name is the API required parameter and is used to obtain the ISP or province (district) list. Namespace=QCE/CDN_LOG_DATA&Region=$region&Action=DescribeInstances&Instance=$instance&Name=isp
    API Gateway See here. Namespace is fixed at QCE/APIGATEWAY. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is ServiceId by default and can also be ServiceName. Namespace=QCE/APIGATEWAY&Region=$region&Action=DescribeInstances
    API Gateway Service Environment See here. Namespace is fixed at QCE/APIGATEWAY. Action is fixed at DescribeServiceEnvironmentList. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. Instance is the display field of the instance, which can be a specific region value and can also be a variable value such as $instance. Namespace=QCE/APIGATEWAY&Region=$region&Action=DescribeInstances&Instance=$instance
    Cloud Block Storage (CBS) See here. Namespace is fixed at QCE/BLOCK_STORAGE. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is DiskIdby default and can also beDiskName`. One or more CBS instances can be selected. Namespace=QCE/BLOCK_STORAGE&Region=$region&Action=DescribeInstances
    Elasticsearch Service (ES) See here. Namespace is fixed at QCE/CES. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is InstanceId by default and can also be InstanceName. One or more Elasticsearch instances can be selected. Namespace=QCE/CES&Region=$region&Action=DescribeInstances
    CMQ Queue Model See here. Namespace is fixed at QCE/CMQ. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is QueueName by default and can also be QueueId. One or more CMQ queue model instances can be selected. Namespace=QCE/CMQ&Region=$region&Action=DescribeInstances
    CMQ Topic Model See here. Namespace is fixed at QCE/CMQTOPIC. Action is fixed at DescribeInstances. Region is the region parameter, which can be a specific region value such as ap-beijing or a variable value such as $region. InstanceAlias is the display field of the instance, which is TopicName by default and can also be TopicId. One or more CMQ topic model instances can be selected. Namespace=QCE/CMQTOPIC&Region=$region&Action=DescribeInstances

    Creating Variables

    1. Go to a dashboard and click the gear icon in the upper-right corner to go to the dashboard settings page.
    2. Click Variables on the left to go to the variable configuration page and then click + Add variable to go to the variable editing page.

    Editing Variables

    • Name: variable name, which is typically an English string and can be used to replace the original specific value in the dashboard.
    • Label: visible label of the variable, which is used to describe the variable name more explicitly. For example, if Name is set to region, Label can be set to Region.
    • Type: variable query method. Here, only Query can be selected, which means to send a request to the data source to get the variable list.
    • Data source: data source from which to get the variable list. You can select any configured Tencent Cloud Monitor data source.
    • Refresh: variable refresh method, which defines when the variable data is refreshed.
    • Query: variable query statement. For more information, please see the variable examples and descriptions in the above table.

    After all the variable information is completed, you can preview the variable values obtained from a query at the bottom of the page. If they are correct as expected, you can click Add to add the variable. After the variable is added successfully, click Save in the right menu to save it in the dashboard configuration.

    The following shows how to configure the region and CVM instance variables by taking the CVM single-instance monitoring dashboard as an example:

    Note:

    If you want to monitor multiple instances, select Mutli-value.

    Applying Variables

    After the variables are created, selection boxes will be displayed in the top-left corner of the dashboard page, where you can switch the variable values. Variables can be imported with two syntaxes: $varname and [[varname]]. Variables are often used in panel query statements. The following shows how to use variables in queries by taking the CVM single-instance monitoring dashboard as an example. In addition, variables can also be used in panel titles and text panels.