Help Center> Log Tank Service> User Guide> Log Alarms> Creating a Metric Filter

Creating a Metric Filter

You can create metric filters in a log stream to monitor keywords, such as Error, Warning, and Fail to root. By checking the keyword frequency, you can have a real-time view of the service running status.

Prerequisites

You have created a log stream.

Creating a Metric Filter

  1. Log in to the LTS console, choose Log Management in the left navigation pane, and click the name of a log group.
  2. In the log stream list, locate the target log stream and click Metric Filter in the Operation column.
    Table 1 Metric filter parameters

    Parameter

    Description

    Filter Name

    Filter names help you distinguish different filters in a log stream.

    It must meet the following requirements:

    • Contains only letters, numbers, hyphens (-), underscores (_), or periods (.).
    • Cannot start or end with a period (.).
    • Contains up to 64 characters.

    Filtering Keyword

    LTS will monitor the configured keyword and count its occurrences in logs of the log stream.

    • Only filtering with a single keyword is supported. If multiple keywords are entered, they are considered a character string.
    • Filtering is case-sensitive and looks for exact matches. Numbers and special characters must be enclosed by double quotation marks.

    Example Log

    Example logs are used to test whether the filtering can match logs with the configured keyword.

    By default, the latest 10 logs are tested. If no match is found, you can search for logs containing the keyword in the raw logs and paste them to the test box to check whether the filtering works. You can also modify the keyword.

    Metric Name

    A metric name corresponds to a filtering keyword and resembles a key in a key-value pair. LTS helps you to carry out metric statistics and release the result to Application Operations Management (AOM) so that you can monitor the frequency of the keyword, set thresholds, and receive alarms when the frequency exceeds the threshold.

    A metric name can contain up to 64 characters. Only letters and numbers are supported. Metric names in a log stream must be unique. Otherwise, statistical data may be inaccurate.

  3. Click OK.

    Click the number in the Metric Filter Numbers column and click the metric name to view monitoring details on AOM.

    Figure 1 Viewing a filter
  4. On the displayed AOM page, choose User-defined Metrics > ALSAlarm to set alarms on metric filters.
    Figure 2 Setting alarms on metric filters

Disabling a Metric Filter

If a filter is no longer needed or becomes invalid because the format or content of logs have changed, you can disable the filter.

  1. On the Log Management page, click the name of a log group.
  2. In the log stream list, click the number or hyphen in the Metric Filter Numbers column of a log stream.
    Figure 3 Disabling a filter
  3. In the filter list, locate the filter you want to disable and click Disable in the Operation column.

    After the filter is disabled, the metric corresponding to the filter will stop to be monitored by AOM.

Deleting a Filter

If you want to create a filter but fail due to insufficient quota (up to 5 filters can be set for a log stream), delete unnecessary filters and try again.

  1. On the Log Management page, click the name of a log group.
  2. In the log stream list, click the number or hyphen in the Metric Filter Numbers column of a log stream.
    Figure 4 Deleting a filter
  3. In the filter list, locate the filter you want to delete and click Delete in the Operation column.

    After the filter is deleted, the metric corresponding to the filter will stop to be monitored by AOM, but is still displayed on AOM. After the data ages, the metric will be automatically deleted.