This topic describes how to configure a line chart to display query results.

Chart upgrade

Log Service provides charts (Pro) to display query and analysis results. You can use a chart (Pro) to visualize the results of multiple query statements. You can also configure custom settings for fields. You can click Migrate to convert a common line chart to a line chart (Pro). For more information about the line chart (Pro), see Line chart (Pro).
Notice After you convert a common chart to a chart (Pro), you cannot convert the chart (Pro) to a common chart.

Background information

A line chart is used to analyze the value changes of a categorical variable over a continuous time range. In most cases, the analysis is based on a specified time range. You can intuitively view value trends. You can use a line chart to analyze the following change characteristics of values over a specified time range:
  • Increment or decrement
  • Increment or decrement rate
  • Increment or decrement pattern, for example, periodicity
  • Peak value and bottom value

Line charts are the optimal choice for you to analyze value changes over a time range. You can also use a line chart to analyze the value changes of multiple categorical variables in multiple lines over the same time period. This allows you to analyze the relationship between the categorical variables. For example, the values of a categorical variable are proportional or inversely proportional to the values of another categorical variable.

Procedure

  1. Log on to the Log Service console.
  2. In the Projects section, click the name of the project that you want to manage.
  3. Choose Log Storage > Logstores and click the Logstore that you want to manage.
  4. Enter a query statement in the search box, select a time range, and then click Search & Analyze.
  5. On the Graph tab, click the Line chart icon.
  6. On the Properties tab, configure the properties of the line chart.
    Note Each line in a line chart must contain more than two data points. Otherwise, the data trend cannot be generated. We recommend that you select no more than five lines for a line chart.
    Parameter Description
    X Axis The sequential data. In most cases, a time series is selected.
    Left Y Axis The value of the categorical variable. You can select one or more fields for the Y-axis.
    Right Y Axis The numeric data. You can select one or more fields for the right Y-axis. The layer of the right Y-axis is higher than the layer of the left Y-axis.
    Column Marker The column that is displayed as a histogram on the left or right Y-axis. You must select this field from the fields that you selected for Right Y Axis or Left Y Axis.
    Legend The position of the legend in the chart. Valid values: Top, Bottom, Left, and Right.
    Format Left Y-axis The format in which the data on the left and right Y-axis is displayed.
    Format Right Y-axis
    Left Y-axis Minimum Value The minimum value for the left Y-axis and right Y-axis.
    Left Y-axis Minimum Value
    Left Y-axis Maximum Value The maximum value for the left Y-axis and right Y-axis.
    Right Y-axis Maximum Value
    Line Type The type of line that is displayed in the line chart. Valid values: Straight Line and Curve.
    Show Markers If you turn on Show Markers, the data points are displayed.
    Metric Filter If you turn on Metric Filter, you can filter metrics to view specific types of data.
    Legend Width The width of the legend.
    X-axis Scale Density The scale density of the X-axis. Valid values: 3 to 30.
    Scatter Column The Y-axis column where data points are located.
    Scatter Numeric Column The numeric value on the data point column.
    Scatter Size The value range of the data points.
    Anomaly Point Column The column whose anomaly points you want to view. You can configure the Anomaly Point Lower Limit and Anomaly Point Upper Limit parameters for a column.
    • Anomaly Point Lower Limit: Values that are less than the lower limit are highlighted in red.
    • Anomaly Point Upper Limit: Values that exceed the upper limit are highlighted in red.
    Upper Limit Column The area that is formed based on the values.
    Lower Limit Column
    Time Series A series of data points that are listed in chronological order.
    Time Format The time format of the time series.
    Margin The distance between the axis and the borders of the chart. The parameters include Top Margin, Bottom Margin, Left Margin, and Right Margin.

Example of a simple line chart

To query the number of page views (PVs) for the IP address 10.0.0.0 in the last 24 hours, execute the following query statement:

remote_addr: 10.0.0.0 | select date_format(date_trunc('hour', __time__), '%m-%d %H:%i') 
as time, count(1) as PV group by time order by time limit 1000

Set the X Axis parameter to time, the Left Y Axis parameter to PV, and the Legend parameter to Bottom. Adjust the margins based on your business requirements.

Simple line chart

Example of a dual-axis line chart

To query the numbers of PVs and unique visitors (UVs) in the last 24 hours, execute the following query statement:

* | select date_format(date_trunc('hour', __time__), '%m-%d %H:%i') as time, count(1) as PV, approx_distinct(remote_addr) as UV group by time order by time limit 1000

Set the X Axis parameter to time, the Left Y Axis parameter to PV, the Right Y Axis parameter to UV, and the Column Marker parameter to UV.

Dual-axis line chart