All Products
Search
Document Center

Simple Log Service:Time series mode

Last Updated:Aug 29, 2023

When you create a chart, you can enable the time series mode to display the trend of query and analysis results. In this mode, the chart displays human-readable time information instead of timestamps. This topic describes the concept, benefits, limits, and configuration examples of the time series mode.

Concept

Important

Only line charts (Pro) and flow charts (Pro) support the time series mode.

You can use the time series mode to display the changes of one or more sets of data over a continuous period of time. You can also use the mode to merge the results of multiple query statements. This way, the trend of query and analysis results can be displayed in a more detailed manner.

The __time__ field is the default attribute of each log in Simple Log Service. The field specifies the point in time at which a log is written to Simple Log Service. The point in time also refers to the log time. The __time__ field is in the UNIX timestamp format with seconds as the unit. You can use the __time__ field to create charts in time series mode. This frees you from complex time functions.

The following list describes the differences between the time series mode and a non-time series mode:

  • Time series mode

    • The system automatically optimizes the time span for a more uniform time distribution.

    • In the x-axis, the time is displayed in the mm:ss format. In popovers, the time is displayed in the YYYY-MM-DD hh:mm:ss format.

    • You can add multiple query statements.

    Time series mode
  • Non-time series mode

    • The x-axis shows a longer time span.

    • In the x-axis and popovers, the time is displayed in the UNIX timestamp format. If you want to convert the format, you must include a time function in the query statement.

    • You can add only one query statement.

    Time series mode

Benefits

  • The x-axis shows a more uniform time distribution to reflect the trends of metrics in an effective manner.

  • The system automatically optimizes the time span in the x-axis. This way, more details of query and analysis results are displayed.

  • The time in the x-axis is displayed in the mm:ss format, which makes the time span and points in time easier to read.

  • You can add multiple query statements and merge the results of the statements.

Limits

The time field that is used for the x-axis must be in the UNIX timestamp format with seconds as the unit or in a standard time format. In a standard time format, the time field follows the UTC time standard, such as 2022-02-03T22:30:05+08:00, or the time field can be parsed into a time value that contains the year, month, day, hour, minute, and second information, such as in the YYYY/MM/DD hh:mm:ss format. In this format, a time zone is allowed.

Configuration examples

Example 1: Enable the time series mode and use a line chart to display the trends of page visits (PVs) and unique visitors (UVs) on a website within the previous 24 hours

Time series mode

When you create the line chart, enable the time series mode and configure the parameters based on your business requirements. For more information about how to create a chart and configure a line chart, see Add a chart (Pro) to a dashboard and Line chart (Pro). The following list provides details of the configuration:

  • 1: Select the Logstore in which the required logs are stored and specify a query statement.

    * | select __time__ - __time__ % 3600 as time, COUNT(*) as pv, COUNT(DISTINCT remote_addr) as uv group by time order by time limit 10000
    • __time__ - __time__ % 3600 as time specifies a time interval of 1 hour and an alias of time.

    • remote_addr specifies the IP address of a user terminal. You can use this field to count the number of UVs.

    • You can use the number of logs to count the number of PVs.

  • 2: Set the query time range to 1 Day(Relative).

  • 3: Click Apply to apply the query statement.

  • 4: In the Configure Query and Analysis section of the Common Settings tab, set Axis Y Field to pv and uv.

  • 5: Turn on Time Series Mode.

Example 2: Enable the time series mode and use a line chart to display the trends of inbound traffic and outbound traffic on a website within the previous 24 hours

Time series mode

When you create the line chart, enable the time series mode and configure the parameters based on your business requirements. For more information about how to create a chart and configure a line chart, see Add a chart (Pro) to a dashboard and Line chart (Pro). The following list provides details of the configuration:

  • 1: Select the Logstore in which the required logs are stored and specify a query statement.

    * | select  __time__ - __time__ % 3600 as time , sum(body_bytes_sent)* -1 as net_out, sum(request_length) as net_in group by time order by time limit 10000
    • __time__ - __time__ % 3600 as time specifies a time interval of 1 hour and an alias of time.

    • body_bytes_sent specifies the number of bytes in the response body that is returned to a client. You can use this field to measure outbound traffic.

    • request_length specifies the number of bytes in a request. The bytes in the request line, request headers, and request body are all counted. You can use this field to measure inbound traffic.

  • 2: Set the query time range to 1 Day(Relative).

  • 3: Click Apply to apply the query statement.

  • 4: In the Configure Query and Analysis section of the Common Settings tab, set Axis Y Field to net_out and net_in.

  • 5: Turn on Time Series Mode.