WO2013026312A1 - 基于日志检测的告警方法及系统 - Google Patents

基于日志检测的告警方法及系统 Download PDF

Info

Publication number
WO2013026312A1
WO2013026312A1 PCT/CN2012/076955 CN2012076955W WO2013026312A1 WO 2013026312 A1 WO2013026312 A1 WO 2013026312A1 CN 2012076955 W CN2012076955 W CN 2012076955W WO 2013026312 A1 WO2013026312 A1 WO 2013026312A1
Authority
WO
WIPO (PCT)
Prior art keywords
detected
log
log file
file
detection
Prior art date
Application number
PCT/CN2012/076955
Other languages
English (en)
French (fr)
Inventor
谢钢锋
丁岩
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2013026312A1 publication Critical patent/WO2013026312A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0686Additional information in the notification, e.g. enhancement of specific meta-data
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/085Retrieval of network configuration; Tracking network configuration history
    • H04L41/0853Retrieval of network configuration; Tracking network configuration history by actively collecting configuration information or by backing up configuration information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Definitions

  • the present invention relates to the field of communications, and in particular, to a method and system for alerting based on log detection. Background technique
  • the main purpose of the embodiments of the present invention is to provide a method and system for detecting alarms based on the log detection, so as to solve the problem that the log detection and alarm mode of the prior art cannot detect multiple files at the same time, and the detection mode is poor in generality and cannot be flexibly expanded.
  • an aspect of an embodiment of the present invention provides an alarm method based on log detection.
  • the method for detecting the alarm based on the log detection in the embodiment of the present invention includes: reading configuration data of the log detection, where the configuration data includes: a log file to be detected, a regular expression, and an alarm information; detecting the log file according to the configuration data, to generate a detection result ; Issue an alarm based on the test result Information.
  • the log file is detected according to the configuration data, and the detection result is generated by: reading the to-be-detected log file in the configuration data; detecting the to-be-detected file if the to-be-detected log file is not empty; If there is a new log line in the log file to be detected, the content of the newly added log line is matched with the regular expression to obtain the detection result.
  • the sending the alarm information according to the detection result includes: sending an alarm information if the content of the newly added log line matches the regular expression successfully.
  • the method further includes: setting the log file to be detected as the first log file for detecting; determining whether the log file to be detected is empty, and the log file to be detected is empty.
  • the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • the method further includes: setting the file to be detected as the next file, and determining the current time The log file to be detected is the last log file.
  • the flag of the log file to be detected is set to null.
  • an alarm system based on log detection is provided.
  • the log detection-based alarm system of the embodiment of the present invention includes: a configuration module, configured to read log detection configuration data, where the configuration data includes: a log file to be detected, a regular expression, and an alarm information; a log detection module, configured to be configured according to the configuration The data is detected by the log file to generate a detection result; the alarm interface module is set to send an alarm message according to the detection result.
  • the log detection module includes: a reading module configured to read the to-be-detected log file in the configuration data; and a detection module configured to detect the to-be-detected file if the to-be-detected log file is not empty; , set to detect that there is a new log file to be detected In the case of adding a log line, the content of the newly added log line is matched with the regular expression to obtain the detection result.
  • the alarm interface module includes: an alarm module, configured to send an alarm message when the detection result is that the content of the newly added log line is successfully matched with the regular expression.
  • the system further includes: a setting detecting module, configured to set the to-be-detected log file as the first log file for detecting; the first processing module is configured to determine whether the to-be-detected log file is empty, and the log file to be detected is empty. In the case, the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • a setting detecting module configured to set the to-be-detected log file as the first log file for detecting
  • the first processing module is configured to determine whether the to-be-detected log file is empty, and the log file to be detected is empty. In the case, the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • the system further includes: a second processing module, configured to set the to-be-detected file as the next log file, and determine that the log file to be detected is the last log file, and the log file to be detected is the last log file. In this case, set the flag of the log file to be detected to be empty.
  • a second processing module configured to set the to-be-detected file as the next log file, and determine that the log file to be detected is the last log file, and the log file to be detected is the last log file. In this case, set the flag of the log file to be detected to be empty.
  • the configuration data of the log detection is used, and the configuration data includes: a log file to be detected, a regular expression, and an alarm information; the log file is detected according to the configuration data to generate a detection result; and the alarm is generated according to the detection result.
  • the information solves the problem that the log detection alarm mode of the prior art cannot detect multiple files at the same time, and the detection mode is poorly versatile and cannot be flexibly expanded, thereby achieving a unified multi-service alarm mechanism, achieving flexibility, simplicity, and scalability. , the application of a wide range of effects.
  • FIG. 1 is a schematic structural diagram of a log detection based alarm system according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a log detection based alarm method according to an embodiment of the present invention
  • FIG. 3 is a log based on an embodiment of the present invention. Detailed flowchart of the detected alarm method. detailed description
  • the embodiment of the invention provides a warning method and system based on log detection.
  • FIG. 1 is a schematic structural diagram of an alarm system based on log detection according to an embodiment of the present invention. As shown in FIG. 1 , the system includes: a configuration module, a log detection module, and an alarm interface module.
  • the configuration module is configured to read the configuration data of the log detection, and the configuration data includes: a log file to be detected, a regular expression, and an alarm information; a log detection module, configured to detect the log file according to the configuration data, and generate a detection result; The alarm interface module is configured to send an alarm message according to the detection result.
  • the above embodiment describes the composition of the alarm system based on log detection, including the relationship of internal modules and the external interface of the system.
  • the system consists of configuration data and a program.
  • the configuration can be in the form of a configuration file or a configuration database. It records the configuration data required by the system, including the checked files, regular expressions, and alarm information.
  • the program consists of three modules: The configuration module is mainly responsible for reading the configuration data; the log detection module mainly monitors and reads each log file, and finds that it matches the regular expression after adding the new line; the alarm interface module is responsible for sending The alarm information is generated when the log line is successfully matched. The alarm is generated by the module and sent to the alarm processing system.
  • the system implements a unified multi-service alarm mechanism, achieving the effects of flexibility, simplicity, scalability, and wide application.
  • the configuration module in the foregoing embodiment may provide all configurations required by the system, including target log files to be detected (may be multiple), regular expressions (for matching log lines), and alarm information (for matching). An alarm is generated when successful).
  • log file configuration The configuration provides the number of log files to be detected, and each day The file name of the file.
  • Regular expression configuration Regular expressions are used to match log lines, are highly adaptable, and are very flexible. An alert can be generated by finding a log line that matches the regular expression. If the following log line matches the regular expression, an alarm can be generated. Regular expression:
  • Alarm interface information configuration Provides information required to send an alarm interface, such as alarm code, alarm cause, and alarm description.
  • the log detection module in the above embodiment may include: a reading module, configured to read a log file to be detected in the configuration data; and a detecting module, configured to detect the to-be-detected file if the to-be-detected log file is not empty
  • the matching module is configured to match the content of the newly added log line with the regular expression to obtain the detection result when detecting that there is a new log line in the log file to be detected.
  • the log detection module implements the responsibility of detecting the log file.
  • the alarm interface module in the foregoing embodiment may include: an alarm module, configured to send an alarm message if the detection result is that the content of the newly added log line is successfully matched with the regular expression.
  • the alarm interface module sends the alarm generated by the log detection module to the external alarm processing system.
  • the system may further include: a setting detecting module, configured to set the to-be-detected log file as the first log file for detecting; the first processing module is configured to determine whether the to-be-detected log file is empty, and the log file to be detected is In the empty case, the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • a setting detecting module configured to set the to-be-detected log file as the first log file for detecting
  • the first processing module is configured to determine whether the to-be-detected log file is empty, and the log file to be detected is In the empty case, the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • system in the foregoing embodiment may further include: a second processing module, configured to set the to-be-detected file as the next log file, and determine that the log file to be detected is the last log file, and the log file to be detected In the case of the last log file, it will be detected The file's flag is set to null.
  • a second processing module configured to set the to-be-detected file as the next log file, and determine that the log file to be detected is the last log file, and the log file to be detected In the case of the last log file, it will be detected The file's flag is set to null.
  • FIG. 2 is a flowchart of a method for alerting based on log detection according to an embodiment of the present invention
  • FIG. 3 is a detailed flowchart of a method for alerting based on log detection according to an embodiment of the present invention.
  • the alarm detection method based on the log detection includes the following steps:
  • Step S102 The configuration data of the log detection is read by using the configuration module in FIG. 1, and the configuration data includes: a log file to be detected, a regular expression, and an alarm information.
  • Step S104 performing a detection on the log file according to the configuration data by using the log detection module in FIG. 1 to generate a detection result.
  • Step S106 the alarm interface module in FIG. 1 is used to implement alarm information according to the detection result.
  • the above embodiment implements that the system first acquires configuration information after startup, and then detects each file. For the newly added log line, it matches each regular expression that is set, and if the matching succeeds, the corresponding set should be generated. Alarm. Thereby, a unified multi-service alarm mechanism is realized, which achieves the effects of simple flexibility, strong scalability, and wide application.
  • the detecting the log file according to the configuration data in the foregoing embodiment may include: reading the to-be-detected log file in the configuration data; and detecting the to-be-detected file if the to-be-detected log file is not empty; When it is detected that there is a new line in the log file to be detected, the content of the newly added log line is matched with the regular expression to obtain the detection result.
  • the sending the alarm information according to the detection result may include: sending an alarm information if the content of the newly added log line matches the regular expression successfully.
  • the method may further include: setting the log file to be detected as the first log file for detecting; determining whether the log file to be detected is empty, and the log file to be detected is empty In the case, the system re-reads and detects the log file to be detected after a predetermined sleep time.
  • the method may further include: setting the file to be detected as the next log file, and determining the current time The log file to be detected is the last log file. When the log file to be detected is the last log file, the flag of the log file to be detected is set to null.
  • Step 201 The system reads configuration data, including a log file to be detected, a regular expression, and an alarm information.
  • step 202 the system repeatedly detects the log file in order, and first sets the log file to be checked as the first log file.
  • Step 203 Determine whether the file to be checked is NULL (NULL means that all log files in this round have been checked). Not NULL to 204, otherwise go to 208.
  • Step 204 detecting the file to be inspected. This includes detecting timestamps, reading file contents, and more.
  • Step 205 Determine whether the file to be checked has a new log line. Note: When a file with multiple rows of logs is first detected, all of its current log lines are new. There is a new line to 206, otherwise go to 207.
  • Step 206 Match the newly added row with each regular expression, and send an alarm if the matching succeeds.
  • Step 208 the program sleeps for a period of time, and then continues to detect the log file.
  • the sleep time is configurable according to the business situation, for example, 1 second.
  • the method and system implement detection of multiple log files to generate an alarm, and use regular expression matching as a detecting means, and the configuration is flexible and simple. , it has strong scalability and wide application.
  • the beneficial effects are as follows: Reduce the deployment cost, deploy a set of the system on a host, and then perform log detection and alarm on all applications on the host; versatile, suitable for various application systems: using regular expressions It is effective for common logs; it is flexible in configuration and applicable to any service and any alarms. It has strong scalability and convenient function change: It can increase the detected files and alarms by simply modifying the configuration file. Delete and modify. .
  • modules or steps of the embodiments of the present invention can be implemented by a general computing device, which can be concentrated on a single computing device or distributed in multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device, or they may be separately fabricated into a plurality of integrated circuit modules, or Implementing multiple modules or steps in them as a single integrated circuit module. Thus, embodiments of the invention are not limited to any particular combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明实施例公开了一种基于日志检测的告警及系统。其中,该方法包括:读取日志检测的配置数据,配置数据包括:待检测日志文件、正则表达式以及告警信息;根据配置数据对日志文件进行检测,以生成检测结果;根据检测结果发出告警信息。通过本发明实施例,能够实现统一的多业务告警机制,达到灵活简单、可扩展性强、适用面广的效果。

Description

基于日志检测的告警方法及系统 技术领域
本发明涉及通信领域, 具体而言, 尤其涉及一种基于日志检测的告警 方法及系统。 背景技术
为了保证系统日志检测结果的及时体现, 现有的各种业务和应用系统 的运行状态都需要监控, 对于偏离正常状态的情况要及时发出告警。 常见 技术手段是告警平台制定告警接口, 每个子系统或模块自己检测并产生告 警, 以约定接口传递告警信息给告警平台。 目前也存在通过分析日志来产 生告警的技术方案, 但是这些技术方案往往存在不能同时检测多个文件、 不能适用于所有日志或告警发现机制等不够灵活的问题。
针对现有技术的日志检测告警方式无法同时检测多个文件、 且检测方 式通用性差以及无法灵活拓展的问题, 目前还没有有效的解决方案。 发明内容
本发明实施例的主要目的在于提供一种基于日志检测的告警方法及系 统, 以解决现有技术的日志检测告警方式无法同时检测多个文件、 且检测 方式通用性差以及无法灵活拓展的问题。
为了实现上述目的, 本发明实施例的一方面, 提供了一种基于日志检 测的告警方法。
本发明实施例的基于日志检测的告警方法包括: 读取日志检测的配置 数据, 配置数据包括: 待检测日志文件、 正则表达式以及告警信息; 根据 配置数据对日志文件进行检测, 以生成检测结果; 根据检测结果发出告警 信息。
优先地, 根据配置数据对日志文件进行检测, 以生成检测结果包括: 读取配置数据中的待检测日志文件; 在待检测日志文件不为空的情况下, 对待检测文件进行检测; 在检测到待检测日志文件存在新增日志行的情况 下, 将新增日志行的内容与正则表达式进行匹配处理以获取检测结果。
优先地, 根据检测结果发出告警信息包括: 在检测结果为新增日志行 的内容与正则表达式匹配成功的情况下, 发出告警信息。
优先地, 在读取配置数据中的待检测日志文件之后, 方法还包括: 将待检测日志文件置为首个日志文件进行检测; 判断待检测日志文件 是否为空, 在待检测日志文件为空的情况下, 系统在预定的休眠时间之后, 重新读取并检测待检测日志文件。
优先地, 在根据检测结果发出告警信息之后, 或者在检测到待检测日 志文件不存在新增日志行的情况下, 方法还包括: 将待检测文件设置为下 个曰志文件, 并判断本次待检测日志文件是最后一个日志文件, 在待检测 日志文件为最后一个日志文件的情况下, 将待检测日志文件的标记设置为 空。
为了实现上述目的, 本发明实施例的另一个方面, 提供了一种基于日 志检测的告警系统。
本发明实施例的基于日志检测的告警系统包括: 配置模块, 设置为读 取日志检测的配置数据, 配置数据包括: 待检测日志文件、 正则表达式以 及告警信息; 日志检测模块, 设置为根据配置数据对日志文件进行检测, 以生成检测结果; 告警接口模块, 设置为根据检测结果发出告警信息。
优先地, 日志检测模块包括: 读取模块, 设置为读取配置数据中的待 检测日志文件; 检测模块, 设置为在待检测日志文件不为空的情况下, 对 待检测文件进行检测; 匹配模块, 设置为在检测到待检测日志文件存在新 增日志行的情况下, 将新增日志行的内容与正则表达式进行匹配处理以获 取检测结果。
优先地, 告警接口模块包括: 告警模块, 设置为在检测结果为新增日 志行的内容与正则表达式匹配成功的情况下, 发出告警信息。
优先地, 系统还包括: 设置检测模块, 设置为将待检测日志文件置为 首个日志文件进行检测; 第一处理模块, 设置为判断待检测日志文件是否 为空, 在待检测日志文件为空的情况下, 系统在预定的休眠时间之后, 重 新读取并检测待检测日志文件。
优先地, 系统还包括: 第二处理模块, 设置为将待检测文件设置为下 个日志文件, 并判断本次待检测日志文件是最后一个日志文件, 在待检测 日志文件为最后一个日志文件的情况下, 将待检测日志文件的标记设置为 空。
通过本发明实施例, 采用读取日志检测的配置数据, 配置数据包括: 待检测日志文件、 正则表达式以及告警信息; 根据配置数据对日志文件进 行检测, 以生成检测结果; 根据检测结果发出告警信息, 解决了现有技术 的日志检测告警方式无法同时检测多个文件, 且检测方式通用性差, 无法 灵活拓展的问题, 进而达到了实现统一的多业务告警机制, 达到灵活简单、 可扩展性强、 适用面广的效果。 附图说明
此处所说明的附图用来提供对本发明实施例的进一步理解, 构成本发 明实施例的一部分, 本发明实施例的示意性实施例及其说明用于解释本发 明实施例, 并不构成对本发明实施例的不当限定。 在附图中:
图 1是根据本发明实施例的基于日志检测的告警系统的结构示意图; 图 2是根据本发明实施例的基于日志检测的告警方法的流程图; 以及 图 3是根据本发明实施例的基于日志检测的告警方法的详细流程图。 具体实施方式
为了使本发明实施例所要解决的技术问题、 技术方案及有益效果更加 清楚、 明白, 以下结合附图和实施例, 对本发明实施例进行进一步详细说 明。 应当理解, 此处所描述的具体实施例仅仅用以解释本发明实施例, 并 不用于限定本发明实施例。
本发明实施例提供了一种基于日志检测的告警方法及系统。
图 1是根据本发明实施例的基于日志检测的告警系统的结构示意图。 如图 1所示, 该系统包括: 配置模块、 日志检测模块以及告警接口模块。
其中, 配置模块, 用于读取日志检测的配置数据, 配置数据包括: 待 检测日志文件、 正则表达式以及告警信息; 日志检测模块, 用于根据配置 数据对日志文件进行检测, 生成检测结果; 告警接口模块, 用于根据检测 结果发出告警信息。
上述实施例描述了基于日志检测的告警系统的组成结构, 包括内部模 块的关系、 系统对外的接口。 有上述系统可知, 系统由配置数据和一个程 序组成。 配置的形式可以是配置文件或者配置数据库, 它记录了本系统所 需的配置数据, 包括被检文件、 正则表达式和告警信息。 程序由三个模块 组成: 配置模块主要负责配置数据的读取; 日志检测模块主要对各日志文 件进行监控、 读取, 发现新增行后将之与正则表达式进行匹配; 告警接口 模块负责发送告警信息, 对于日志行匹配成功时, 产生告警, 由该模块发 送到告警处理系统。 该系统实现了统一的多业务告警机制, 达到灵活简单、 可扩展性强、 适用面广的效果。
具体的, 上述实施例中的配置模块可以提供本系统所需的所有配置, 包括要检测的目标日志文件 (可多个), 正则表达式(用于匹配日志行), 告警信息(用于匹配成功时产生告警)。
其中, 日志文件配置: 配置提供要检测的日志文件数量, 以及每个日 志文件的文件名。
正则表达式配置: 正则表达式用于匹配日志行, 适用性强, 而且非常 灵活。 发现与正则表达式匹配的日志行就可以产生告警。 如下面的日志行 与正则表达式是匹配的, 就可以产生一条告警。 正则表达式:
" A.+\[error\].+healthcheck: upstream\((.+)\) stat up -> down "。 日志行: " 2011/03/08 11 :56:53 [error] 14662#0: healthcheck: upstream(10.46.174.2:8080) stat up -> down"。
告警接口信息配置: 提供发送告警接口所需的信息, 比如包括告警码、 告警原因、 告警描述等信息。
上述实施例中的日志检测模块可以包括: 读取模块, 用于读取配置数 据中的待检测日志文件; 检测模块, 用于在待检测日志文件不为空的情况 下, 对待检测文件进行检测; 匹配模块, 用于在检测到待检测日志文件存 在新增日志行的情况下, 将新增日志行的内容与正则表达式进行匹配处理 以获取检测结果。 该日志检测模块实现了责对日志文件进行检测。
上述实施例中的告警接口模块可以包括: 告警模块, 用于在检测结果 为新增日志行的内容与正则表达式匹配成功的情况下, 发出告警信息。 该 告警接口模块实现了把日志检测模块产生的告警发送到外部告警处理系 统。
优选地, 上述系统还可以包括: 设置检测模块, 用于将待检测日志文 件置为首个日志文件进行检测; 第一处理模块, 用于判断待检测日志文件 是否为空, 在待检测日志文件为空的情况下, 系统在预定的休眠时间之后, 重新读取并检测待检测日志文件。
优选地, 上述实施例中的系统还可以包括: 第二处理模块, 用于将待 检测文件设置为下个日志文件, 并判断本次待检测日志文件是最后一个日 志文件, 在待检测日志文件为最后一个日志文件的情况下, 将待检测曰志 文件的标记设置为空。
图 2是根据本发明实施例的基于日志检测的告警方法的流程图; 以及 图 3是根据本发明实施例的基于日志检测的告警方法的详细流程图。
如图 2所示, 该基于日志检测的告警方法包括如下步驟:
步驟 S102, 通过图 1中的配置模块来读取日志检测的配置数据, 配置 数据包括: 待检测日志文件、 正则表达式以及告警信息。
步驟 S104, 通过图 1中的日志检测模块来执行根据配置数据对日志文 件进行检测, 生成检测结果。
步驟 S106, 通过图 1中的告警接口模块来实现根据检测结果发出告警 信息。
上述实施例实现了系统在启动后首先获取配置信息, 然后检测每个文 件, 对于新增日志行, 将其与设定的每个正则表达式进行匹配, 匹配成功 则应产生相应的已设定的告警。 从而实现统一的多业务告警机制, 达到灵 活简单、 可扩展性强、 适用面广的效果。
上述实施例中的根据配置数据对日志文件进行检测, 以生成检测结果 可以包括: 读取配置数据中的待检测日志文件; 在待检测日志文件不为空 的情况下, 对待检测文件进行检测; 在检测到待检测日志文件存在新增曰 志行的情况下, 将新增日志行的内容与正则表达式进行匹配处理以获取检 测结果。
上述实施例中的步驟: 根据检测结果发出告警信息可以包括: 在检测 结果为新增日志行的内容与正则表达式匹配成功的情况下, 发出告警信息。
优选地, 在读取配置数据中的待检测日志文件之后, 方法还可以包括: 将待检测日志文件置为首个日志文件进行检测; 判断待检测日志文件是否 为空, 在待检测日志文件为空的情况下, 系统在预定的休眠时间之后, 重 新读取并检测待检测日志文件。 优选地, 在根据检测结果发出告警信息之后, 或者在检测到待检测日 志文件不存在新增日志行的情况下, 方法还可以包括: 将待检测文件设置 为下个日志文件, 并判断本次待检测日志文件是最后一个日志文件, 在待 检测日志文件为最后一个日志文件的情况下, 将待检测日志文件的标记设 置为空。
具体的, 基于图 3 所示的基于日志检测的告警系统的详细工作流程。 其步驟如下:
步驟 201 , 系统读取配置数据, 包括待检测日志文件、 正则表达式、 告 警信息。
步驟 202, 系统将反复按次序检测日志文件, 首先设置待检日志文件为 首个日志文件。
步驟 203,判断待检文件是否为 NULL (为 NULL代表本轮所有日志文 件都已检查完毕)。 不为 NULL到 204, 否则转 208。
步驟 204, 对待检文件进行检测。 包括检测时间戳、 读取文件内容等。 步驟 205, 判断待检文件是否有新增日志行。 注: 一个已有多行日志的 文件在第一次被检测时, 当前其所有日志行都是新增的。 有新增行到 206, 否则转 207。
步驟 206,把新增行与每个正则表达式进行匹配,匹配成功则发送告警。 步驟 207, 置待检文件为下个日志文件。 若本次待检文件是最后一个日 志文件, 说明本轮所有文件都已检测一遍, 则置待检文件为 NULL来标记。
步驟 208, 程序休眠一段时间, 转 202继续检测日志文件。 休眠时间根 据业务情况可配置, 比如为 1秒钟。
需要说明的是, 本发明实施例在附图的流程图示出的步驟可以在诸如 一组计算机可执行指令的计算机系统中执行, 并且, 虽然在流程图中示出 了逻辑顺序, 但是在某些情况下, 可以以不同于此处的顺序执行所示出或 描述的步驟。
从以上的实施例描述中, 可以看出, 本发明实施例实现了如下技术效 果: 该方法和系统实现对多个日志文件的检测来产生告警, 以正则表达式 匹配为检测手段, 配置灵活简单, 可扩展性强, 适用面广。 有益效果具有 表现在: 降低部署成本, 一台主机上部署一套本系统, 即可对该主机上的 所有应用进行日志检测和告警; 通用性强, 适用于各类应用系统: 采用正 则表达式, 对于普通日志都是有效的; 而且配置灵活, 对任何业务、 任何 告警都是适用的; 扩展性强, 功能变更方便: 只需修改配置文件就可对检 测的文件、 告警等功能进行增加、 删除和修改。。
显然, 本领域的技术人员应该明白, 上述的本发明实施例的各模块或 各步驟可以用通用的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多个计算装置所组成的网络上, 可选地, 它们可以用计算装置 可执行的程序代码来实现, 从而, 可以将它们存储在存储装置中由计算装 置来执行, 或者将它们分别制作成多个集成电路模块, 或者将它们中的多 个模块或步驟制作成单个集成电路模块来实现。 这样, 本发明实施例不限 制于任何特定的硬件和软件结合。
上述说明示出并描述了本发明的一个优选实施例, 但如前所述, 应当 理解本发明实施例并非局限于本文所披露的形式, 不应看作是对其他实施 例的排除, 而可用于各种其他组合、 修改和环境, 并能够在本文所述发明 构想范围内, 通过上述教导或相关领域的技术或知识进行改动。 而本领域 人员所进行的改动和变化不脱离本发明实施例的精神和范围, 则都应在本 发明实施例所附权利要求的保护范围内。

Claims

1、 一种基于日志检测的告警方法, 其中, 包括:
读取日志检测的配置数据, 所述配置数据包括: 待检测日志文件、 正则表达式以及告警信息;
根据所述配置数据对日志文件进行检测, 生成检测结果;
根据所述检测结果发出告警信息。
2、 根据权利要求 1所述的方法, 其中, 根据所述配置数据对日志文 件进行检测, 以生成检测结果包括:
读取所述配置数据中的待检测日志文件;
在所述待检测日志文件不为空的情况下, 对所述待检测文件进行检 测;
在检测到所述待检测日志文件存在新增日志行的情况下, 将所述新 增日志行的内容与所述正则表达式进行匹配处理以获取检测结果。
3、 根据权利要求 2所述的方法, 其中, 根据所述检测结果发出告警 信息包括:
在检测结果为所述新增日志行的内容与所述正则表达式匹配成功的 情况下, 发出所述告警信息。
4、 根据权利要求 2所述的方法, 其中, 在读取所述配置数据中的待 检测日志文件之后, 所述方法还包括:
将所述待检测日志文件置为首个日志文件进行检测;
判断所述待检测日志文件是否为空, 在所述待检测日志文件为空的 情况下, 系统在预定的休眠时间之后, 重新读取并检测所述待检测日志 文件。
5、 根据权利要求 4所述的方法, 其中, 在根据所述检测结果发出告 警信息之后, 或者在检测到所述待检测日志文件不存在新增日志行的情 况下, 所述方法还包括:
将所述待检测文件设置为下个日志文件, 并判断本次待检测日志文 件是最后一个日志文件, 在所述待检测日志文件为最后一个日志文件的 情况下, 将所述待检测日志文件的标记设置为空。
6、 一种基于日志检测的告警系统, 其中, 包括:
配置模块, 设置为读取日志检测的配置数据, 所述配置数据包括: 待检测日志文件、 正则表达式以及告警信息;
日志检测模块, 设置为根据所述配置数据对日志文件进行检测, 生 成检测结果;
告警接口模块 , 设置为根据所述检测结果发出告警信息。
7、 根据权利要求 6所述的系统, 其中, 所述日志检测模块包括: 读取模块, 设置为读取所述配置数据中的待检测日志文件; 检测模块, 设置为在所述待检测日志文件不为空的情况下, 对所述 待检测文件进行检测;
匹配模块, 设置为在检测到所述待检测日志文件存在新增日志行的 情况下, 将所述新增日志行的内容与所述正则表达式进行匹配处理以获 取检测结果。
8、 根据权利要求 7所述的系统, 其中, 所述告警接口模块包括: 告警模块, 设置为在检测结果为所述新增日志行的内容与所述正则 表达式匹配成功的情况下, 发出所述告警信息。
9、 根据权利要求 7所述的系统, 其中, 所述系统还包括: 设置检测模块, 设置为将所述待检测日志文件置为首个日志文件进 行检测;
第一处理模块, 设置为判断所述待检测日志文件是否为空, 在所述 待检测日志文件为空的情况下, 系统在预定的休眠时间之后, 重新读取 并检测所述待检测日志文件。
10、 根据权利要求 9所述的系统, 其中, 所述系统还包括: 第二处理模块, 设置为将所述待检测文件设置为下个日志文件, 并 判断本次待检测日志文件是最后一个日志文件, 在所述待检测日志文件 为最后一个日志文件的情况下, 将所述待检测日志文件的标记设置为空。
PCT/CN2012/076955 2011-08-23 2012-06-15 基于日志检测的告警方法及系统 WO2013026312A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2011102427898A CN102957550A (zh) 2011-08-23 2011-08-23 基于日志检测的告警方法及系统
CN201110242789.8 2011-08-23

Publications (1)

Publication Number Publication Date
WO2013026312A1 true WO2013026312A1 (zh) 2013-02-28

Family

ID=47745901

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076955 WO2013026312A1 (zh) 2011-08-23 2012-06-15 基于日志检测的告警方法及系统

Country Status (2)

Country Link
CN (1) CN102957550A (zh)
WO (1) WO2013026312A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111832260A (zh) * 2020-05-26 2020-10-27 国电南瑞南京控制系统有限公司 一种syslog日志到电力系统通用告警日志的转换方法
CN115174197A (zh) * 2022-07-01 2022-10-11 阿里云计算有限公司 webshell文件的检测方法、系统、电子设备及计算机存储介质
WO2023030391A1 (en) * 2021-09-06 2023-03-09 Wuhan United Imaging Healthcare Co., Ltd. Systems and methods for failure warning
CN116048945A (zh) * 2023-03-29 2023-05-02 摩尔线程智能科技(北京)有限责任公司 设备性能检测方法、装置、电子设备及存储介质
CN117170984A (zh) * 2023-11-02 2023-12-05 麒麟软件有限公司 一种linux系统待机状态的异常检测方法及系统

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105264825B (zh) * 2013-11-19 2018-12-07 华为技术有限公司 告警系统及告警消息处理方法
CN104182321A (zh) * 2014-02-24 2014-12-03 无锡天脉聚源传媒科技有限公司 一种访问错误的监控方法及装置
CN105138593A (zh) * 2015-07-31 2015-12-09 山东蚁巡网络科技有限公司 一种利用正则表达式自定义提取日志关键信息的方法
CN105740121B (zh) * 2016-01-26 2018-08-28 中国银行股份有限公司 一种日志文本监控与预警方法、装置
CN106817253A (zh) * 2017-01-04 2017-06-09 郑州云海信息技术有限公司 日志文件的实时监控及报警的方法和系统
CN111736579B (zh) * 2020-08-26 2020-12-08 北京安帝科技有限公司 基于日志问询留存的工业控制设备安全检测方法
CN112100660A (zh) * 2020-09-15 2020-12-18 中国建设银行股份有限公司 一种日志文件敏感信息检测方法及装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1492336A (zh) * 2003-09-04 2004-04-28 上海格尔软件股份有限公司 基于数据仓库的信息安全审计方法
CN101529862A (zh) * 2006-11-03 2009-09-09 朗讯科技公司 利用字符串分析来检测一个或更多分组网路中的有害业务量的方法和装置
CN101610174A (zh) * 2009-07-24 2009-12-23 深圳市永达电子股份有限公司 一种日志关联分析系统与方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030204574A1 (en) * 2001-03-30 2003-10-30 Oleg Kupershmidt System and method for configuring network access devices

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1492336A (zh) * 2003-09-04 2004-04-28 上海格尔软件股份有限公司 基于数据仓库的信息安全审计方法
CN101529862A (zh) * 2006-11-03 2009-09-09 朗讯科技公司 利用字符串分析来检测一个或更多分组网路中的有害业务量的方法和装置
CN101610174A (zh) * 2009-07-24 2009-12-23 深圳市永达电子股份有限公司 一种日志关联分析系统与方法

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111832260A (zh) * 2020-05-26 2020-10-27 国电南瑞南京控制系统有限公司 一种syslog日志到电力系统通用告警日志的转换方法
CN111832260B (zh) * 2020-05-26 2024-03-26 国电南瑞南京控制系统有限公司 一种syslog日志到电力系统通用告警日志的转换方法
WO2023030391A1 (en) * 2021-09-06 2023-03-09 Wuhan United Imaging Healthcare Co., Ltd. Systems and methods for failure warning
CN115174197A (zh) * 2022-07-01 2022-10-11 阿里云计算有限公司 webshell文件的检测方法、系统、电子设备及计算机存储介质
CN115174197B (zh) * 2022-07-01 2024-03-29 阿里云计算有限公司 webshell文件的检测方法、系统、电子设备及计算机存储介质
CN116048945A (zh) * 2023-03-29 2023-05-02 摩尔线程智能科技(北京)有限责任公司 设备性能检测方法、装置、电子设备及存储介质
CN116048945B (zh) * 2023-03-29 2023-06-23 摩尔线程智能科技(北京)有限责任公司 设备性能检测方法、装置、电子设备及存储介质
CN117170984A (zh) * 2023-11-02 2023-12-05 麒麟软件有限公司 一种linux系统待机状态的异常检测方法及系统
CN117170984B (zh) * 2023-11-02 2024-01-30 麒麟软件有限公司 一种linux系统待机状态的异常检测方法及系统

Also Published As

Publication number Publication date
CN102957550A (zh) 2013-03-06

Similar Documents

Publication Publication Date Title
WO2013026312A1 (zh) 基于日志检测的告警方法及系统
Yuan et al. Context-based online configuration-error detection
US10331625B2 (en) Managing sequential data store
CN106817295B (zh) 一种消息处理装置和方法
US7617413B2 (en) Method of preventing erroneous take-over in a dual redundant server system
US8782472B2 (en) Troubleshooting system using device snapshots
US8521974B2 (en) Migration of data in a distributed environment
US10191789B2 (en) Tracing system operations across remote procedure linkages to identify request originators
CN112486629B (zh) 微服务状态检测方法、装置、电子设备和存储介质
WO2016183967A1 (zh) 一种关键组件的故障告警方法、装置及大数据管理系统
JP2008524677A5 (zh)
CN108038039B (zh) 记录日志的方法及微服务系统
US20130246358A1 (en) Online verification of a standby database in log shipping physical replication environments
US10102088B2 (en) Cluster system, server device, cluster system management method, and computer-readable recording medium
CN110457953B (zh) 一种文件完整性的检测方法和装置
CN109542338B (zh) 一种实现分布式存储系统中节点信息一致性方法及装置
US8438637B1 (en) System, method, and computer program product for performing an analysis on a plurality of portions of potentially unwanted data each requested from a different device
US20130179569A1 (en) Systems and methods for gateway status information handling
CN103701667A (zh) 服务器的心跳的监控方法、装置及系统
CN115080132A (zh) 信息处理方法、装置、服务器及存储介质
CN111414269A (zh) 一种日志告警方法、装置、存储介质及设备
CN117421337B (zh) 数据采集方法、装置、设备及计算机可读介质
US11874821B2 (en) Block aggregation for shared streams
JP2010003132A (ja) 情報処理装置、その入出力装置の故障検出方法及びプログラム
CN111045723B (zh) 关联系统间的代码变更通知方法、装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12824966

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12824966

Country of ref document: EP

Kind code of ref document: A1