All Products
Search
Document Center

Simple Log Service:SLS bill analysis

Last Updated:May 12, 2025

This topic describes how to view the Simple Log Service (SLS) bill analysis report, customize query and analysis statements, and configure alerts when SLS storage usage reaches a specified threshold.

SLS billing data

Billing data reflects Alibaba Cloud service usage. Use the following query and analysis statement to check your SLS billing details:

* |
select
  BillingDate,
  BillingItem,
  BillingType,
  CostUnit,
  Currency,
  DeductedByCashCoupons,
  DeductedByCoupons,
  DeductedByPrepaidCard,
  DeductedByResourcePackage,
  InstanceConfig,
  InstanceID,
  InstanceSpec,
  InvoiceDiscount,
  Item,
  ListPrice,
  ListPriceUnit,
  NickName,
  OutstandingAmount,
  OwnerID,
  PaymentAmount,
  PretaxAmount,
  PretaxGrossAmount,
  ProductCode,
  ProductDetail,
  ProductName,
  ProductType,
  Region,
  ResourceGroup,
  ServicePeriod,
  SubscriptionType,
  Tag,
  Usage,
  UsageUnit,
  Zone
from
  instance_bill

processed_11

The descriptions of instances and billing items are as follows:

Name

Field

Description

Example

Instance

InstanceID

The smallest granularity resource of a cloud service. For SLS, it is a logstore. The InstanceID format is OwnerId;Project;Logstore;Region.

12345;test-project;test-logstore;cn-guangzhou

Billing item

BillingItem

The SLS billing items, such as storage space and index traffic.

Index traffic

View the SLS bill analysis report

On the Cost Manager page, click Log Service Bill Self-service Analysis to view the detailed bill information, including the costs and usage trends.

The top of the page provides global filtering options. Select the corresponding Project, Logstore, Region, and OwnerId to analyze an instance's usage.

processed_22

The bill analysis offers detailed usage insights for your most used projects and logstores, so you can track their resources.

image

image

SLS billing usage analysis

Example 1: View yesterday's amount

  1. Click Log Service Bill Self-service Analysis and find the Expenses Yesterday chart.

  2. Hover your cursor over image at the top-right corner of the chart, and click Preview Query Statement.

    image

    Query and analysis statement:

    (*) |
    select
      t,
      cost as "Expenses Yesterday",
      (cost - lag(cost, 1, 0) over()) / lag(cost, 1, 0) over() * 100 as "percent"
    FROM
      (
        select
          sum(PretaxAmount) as cost,
          date_format(__time__, '%Y-%m-%d') as t
        FROM
          instance_bill
        where
          (
            productcode = 'sls'
            or productcode = 'slsingest'
          )
          and split_part(InstanceID, ';', 3) like '%%'
          and split_part(InstanceID, ';', 2) like '%%'
          and split_part(InstanceID, ';', 4) like '%%'
          and OwnerId like '%%'
        group by
          t
        order by
          t asc
      )
    limit
      1000
  3. To modify the statement, click Search & Analysis.image

Example 2: Query usage trends of billing items

Use the following query and analysis statement to view the usage trend of each billing item.

 * |
select
  date_trunc('day', __time__) as t,
  BillingItem,
  round(sum(Usage), 2) as "Usage"
from instance_bill
where ProductCode='sls'
group by BillingItem, t

image

Example 3: Query usage details of each project and logstore

Use the following query and analysis statement to query usage details of each project and logstore. Replace ${project_name} with the actual project name.

 * | select
  split_part(instanceId, ';', 2) as project,
  split_part(instanceId, ';', 3) as logstore,
  split_part(instanceId, ';', 4) as region,
  BillingItem as "Billing Item",
  round(sum(Usage), 2) as "Usage"
FROM  instance_bill
where
  ProductCode = 'sls'
  and split_part(instanceId, ';', 2) like '${project_name}'
group by
  BillingItem,
  project,
  logstore,
  region

image

Configure alerts for SLS storage usage

The following example shows how to configure an alert when the SLS storage usage exceeds the threshold.

  1. In the left-side navigation pane, click Alerts. On the Alert Center page, click Create Alert.

    image

  2. On the Create Alert page, configure the related parameters.

    1. Set Check Frequency to Fixed Interval and 1 day. Then, click Create in the Query Statistics field.image

    2. On the Query Statistics page, select a logstore, and set Time Range to Yesterday. Configure the following query and analysis statement to query the storage usage. Then, click Confirm.

      * |
      select
         round(sum(Usage), 2) as "Storage usage"
      from instance_bill
      where ProductCode='sls'
      and BillingItem like '%bucket%'

      image

    3. On the Create Alert page, set Trigger Condition to data matches the expression. Then, set the matching condition to Storage usage greater than your alert threshold. The example uses an alert threshold of 400. For other parameters, refer to Configuration description.

      image

  3. After configuring the alert, view alert records on the alert dashboard.