[go: up one dir, main page]

CN117033332A - Log processing method, device and equipment - Google Patents

Log processing method, device and equipment Download PDF

Info

Publication number
CN117033332A
CN117033332A CN202311035136.1A CN202311035136A CN117033332A CN 117033332 A CN117033332 A CN 117033332A CN 202311035136 A CN202311035136 A CN 202311035136A CN 117033332 A CN117033332 A CN 117033332A
Authority
CN
China
Prior art keywords
log data
value
hash
current limiting
time
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311035136.1A
Other languages
Chinese (zh)
Inventor
赵勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
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 Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202311035136.1A priority Critical patent/CN117033332A/en
Publication of CN117033332A publication Critical patent/CN117033332A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • G06F16/137Hash-based

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a log processing method, device and equipment, and belongs to the technical field of log processing. The log processing method comprises the following steps: acquiring first log data uploaded by a service system, wherein the first log data comprises a first service tag; determining a log data flow limiting index value of a first service label according to a hash table, wherein the hash table comprises at least one hash node, the hash node is established based on different service labels and hash functions, and the hash node is used for storing the corresponding relation between the service labels and the flow limiting index value; and under the condition that the current limiting index value meets the current limiting condition, prohibiting the first log data from being stored in a cache space of the log system.

Description

日志处理方法、装置及设备Log processing methods, devices and equipment

技术领域Technical field

本申请属于日志处理技术领域,具体涉及一种日志处理方法、装置及设备。This application belongs to the technical field of log processing, and specifically relates to a log processing method, device and equipment.

背景技术Background technique

随着技术的发展,电子设备包含的应用越来越多,各个应用产生的日志数据也越来越多。为了方便后续的查找和分析,需要对日志数据进行缓存。With the development of technology, electronic devices include more and more applications, and each application generates more and more log data. In order to facilitate subsequent search and analysis, log data needs to be cached.

但缓存空间有限,因此在后续的使用中,会出现缓存用尽的情况,无法再存储日志数据,进而导致这部分日志数据丢失。However, the cache space is limited, so in subsequent uses, the cache will be exhausted and the log data can no longer be stored, resulting in the loss of this part of the log data.

发明内容Contents of the invention

本申请实施例的目的是提供一种日志处理方法、装置及设备,能够解决因日志系统的缓存用尽,导致日志丢失的问题。The purpose of the embodiments of this application is to provide a log processing method, device and equipment that can solve the problem of log loss due to the exhaustion of the cache of the log system.

第一方面,本申请实施例提供了一种日志处理方法,包括:In the first aspect, embodiments of the present application provide a log processing method, including:

获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;Obtain the first log data uploaded by the business system, where the first log data includes the first business tag;

根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;Determine the log data current limiting indicator value of the first business tag according to the hash table. The hash table includes at least one hash node. The hash node is established based on different business tags and hash functions. The hash node is used to store the business tag and the hash function. Correspondence between current limiting indicator values;

在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。When the current limiting indicator value meets the current limiting condition, the first log data is prohibited from being stored in the cache space of the log system.

第二方面,本申请实施例提供了一种日志处理装置,包括:In the second aspect, embodiments of the present application provide a log processing device, including:

获取模块,用于获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;The acquisition module is used to acquire the first log data uploaded by the business system, where the first log data includes the first business tag;

确定模块,用于根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;The determination module is used to determine the log data current limit indicator value of the first business tag according to the hash table. The hash table includes at least one hash node. The hash node is established based on different business tags and hash functions. The hash node is To store the corresponding relationship between business labels and current limiting indicator values;

处理模块,用于在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。The processing module is configured to prohibit storing the first log data into the cache space of the log system when the current limiting indicator value meets the current limiting condition.

第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器和存储器,存储器存储可在处理器上运行的程序或指令,程序或指令被处理器执行时实现如第一方面所述的方法的步骤。In a third aspect, embodiments of the present application provide an electronic device. The electronic device includes a processor and a memory. The memory stores programs or instructions that can be run on the processor. When the program or instructions are executed by the processor, the implementation is as in the first aspect. steps of the method.

第四方面,本申请实施例提供了一种可读存储介质,可读存储介质上存储程序或指令,程序或指令被处理器执行时实现如第一方面所述的方法的步骤。In a fourth aspect, embodiments of the present application provide a readable storage medium. Programs or instructions are stored on the readable storage medium. When the programs or instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

第五方面,本申请实施例提供了一种芯片,芯片包括处理器和通信接口,通信接口和处理器耦合,处理器用于运行程序或指令,实现如第一方面所述的方法的步骤。In a fifth aspect, embodiments of the present application provide a chip. The chip includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the steps of the method described in the first aspect.

第六方面,本申请实施例提供了一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如第一方面所述的方法的步骤。In a sixth aspect, embodiments of the present application provide a computer program product, the program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of the method described in the first aspect.

本申请实施例获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。即本申请实施例在获取到业务系统上传的第一日志数据后,可以从哈希表中确定第一业务标签的限流标志值,并在限流标志值满足限流条件时,禁止将第一日志数据存储至日志系统的缓存空间,如此可以避免某一业务类型的日志数据输出量较大而耗尽日志系统的缓存,进而导致其他业务类型的日志数据无法缓存进而丢失的情况,有效提升了各业务类型的日志数据缓存的均衡性。The embodiment of the present application obtains the first log data uploaded by the business system. The first log data includes the first business tag; the log data current limit indicator value of the first business tag is determined according to the hash table, and the hash table includes at least one hash node. , the hash node is established based on different business labels and hash functions. The hash node is used to store the correspondence between the business label and the current limiting indicator value; when the current limiting indicator value meets the current limiting condition, the first log is prohibited from being The data is stored in the cache space of the log system. That is, after obtaining the first log data uploaded by the business system, the embodiment of this application can determine the current limiting flag value of the first business tag from the hash table, and when the current limiting flag value meets the current limiting condition, it is prohibited to use the first log data uploaded by the business system. One log data is stored in the cache space of the log system. This can avoid the situation where the output volume of log data of a certain business type is large and exhaust the cache of the log system, which in turn causes the log data of other business types to be unable to be cached and thus lost, effectively improving the This ensures the balance of log data caching for each business type.

附图说明Description of the drawings

图1为本申请实施例提供的一种日志处理方法的流程图;Figure 1 is a flow chart of a log processing method provided by an embodiment of the present application;

图2为本申请实施例提供的一种日志处理方法的流程图;Figure 2 is a flow chart of a log processing method provided by an embodiment of the present application;

图3为本申请实施例提供的一种日志处理过程的示意图;Figure 3 is a schematic diagram of a log processing process provided by an embodiment of the present application;

图4为本申请实施例提供的一种日志处理装置的结构示意图;Figure 4 is a schematic structural diagram of a log processing device provided by an embodiment of the present application;

图5为本申请实施例提供的一种电子设备的结构示意图;Figure 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;

图6为本申请实施例提供的一种电子设备的硬件结构示意图。FIG. 6 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art fall within the scope of protection of this application.

本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。The terms "first", "second", etc. in the description and claims of this application are used to distinguish similar objects and are not used to describe a specific order or sequence. It is to be understood that the figures so used are interchangeable under appropriate circumstances so that the embodiments of the present application can be practiced in orders other than those illustrated or described herein, and that "first," "second," etc. are distinguished Objects are usually of one type, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and/or" in the description and claims indicates at least one of the connected objects, and the character "/" generally indicates that the related objects are in an "or" relationship.

当开发人员需要分析电子设备出现的bug时,需要依赖于电子设备上的日志系统缓存的日志进行问题的排查与分析。When developers need to analyze bugs that occur in electronic devices, they need to rely on the logs cached by the log system on the electronic devices to troubleshoot and analyze the problem.

随着技术的发展,电子设备支持的业务越来越多,各业务产生的日志也越来越多,在这种情况下,如何保存各业务的日志,对于日志系统是个严峻的挑战。With the development of technology, electronic devices support more and more businesses, and each business generates more and more logs. In this case, how to save the logs of each business is a serious challenge for the log system.

目前主要包括两种方式:第一,通过提高日志线程的优先级,来缓解日志丢失的问题,第二,提高日志系统的缓存空间。Currently, there are two main methods: first, by increasing the priority of the log thread to alleviate the problem of log loss; second, by increasing the cache space of the log system.

针对第一种方式,由于日志线程的优先级升高,占用的中央处理器(CentralProcessing Unit,CPU)的时长较多,导致电子设备的用户界面(User Interface,UI)线程以及收发包线程的CPU的占用率下降,从而会导致屏幕操作卡顿、网络响应慢等,影响电子设备的整体使用性能,降低了用户的使用体验。For the first method, due to the increased priority of the log thread, it occupies a lot of central processing unit (CPU) time, causing the CPU of the user interface (UI) thread of the electronic device and the packet sending and receiving thread to be exhausted. The occupancy rate will decrease, which will lead to screen operation freezes, slow network response, etc., affecting the overall performance of the electronic device and reducing the user experience.

针对第二种方式,提高日志系统的缓存空间,只能延迟问题暴露的时间点,无法从根本上解决日志输出量大,耗尽缓存空间,导致日志丢失的问题。Regarding the second method, increasing the cache space of the log system can only delay the time when the problem is exposed, but cannot fundamentally solve the problem of large log output, exhaustion of cache space, and log loss.

综上,目前提供的日志处理方案均无法有效的解决日志系统的缓存用尽,导致日志丢失的问题。In summary, none of the currently provided log processing solutions can effectively solve the problem of log loss caused by the log system's cache being exhausted.

为此,本申请实施例提供了一种日志处理方法、装置及设备,可以有效解决因日志系统的缓存用尽,导致日志丢失的问题。下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的日志处理方法、装置及设备进行详细地说明。To this end, embodiments of the present application provide a log processing method, device and equipment, which can effectively solve the problem of log loss due to exhaustion of the cache of the log system. The log processing method, device and equipment provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings through specific embodiments and application scenarios.

需要说明的是,本申请实施例提供的日志处理方案同样可以应用于web请求等,也即不仅可以对日志进行限流,也可以对web请求或者其他内容进行限流处理,处理过程类似。It should be noted that the log processing solution provided by the embodiments of this application can also be applied to web requests, etc. That is, not only can logs be flow-limited, but web requests or other content can also be flow-limited. The processing process is similar.

图1为本申请实施例提供的一种日志处理方法的流程图,该方法可以应用于电子设备的日志系统,该电子设备可以是基于ulog的智能设备例如手机、电脑、可穿戴智能设备以及其他嵌入式设备,如路由器等。可穿戴智能设备例如可以是智能手表、智能手环等。Figure 1 is a flow chart of a log processing method provided by an embodiment of the present application. This method can be applied to a log system of an electronic device. The electronic device can be a ulog-based smart device such as a mobile phone, a computer, a wearable smart device, and others. Embedded devices such as routers, etc. Wearable smart devices can be, for example, smart watches, smart bracelets, etc.

如图1所示,该日志处理方法可以包括以下步骤:As shown in Figure 1, the log processing method may include the following steps:

S110、获取业务系统上传的第一日志数据。S110. Obtain the first log data uploaded by the business system.

其中,第一日志数据包括第一业务标签。Wherein, the first log data includes a first service tag.

S120、根据哈希表确定第一业务标签的日志数据限流指标值。S120. Determine the log data current limiting indicator value of the first business tag according to the hash table.

其中,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系。The hash table includes at least one hash node. The hash node is established based on different business labels and hash functions. The hash node is used to store the corresponding relationship between the business label and the current limiting indicator value.

S130、在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。S130. When the current limiting indicator value meets the current limiting condition, it is prohibited to store the first log data in the cache space of the log system.

本申请实施例获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。即本申请实施例在获取到业务系统上传的第一日志数据后,可以从哈希表中确定第一业务标签的限流标志值,并在限流标志值满足限流条件时,禁止将第一日志数据存储至日志系统的缓存空间,如此可以避免某一业务类型的日志数据输出量较大而耗尽日志系统的缓存,进而导致其他业务类型的日志数据无法缓存进而丢失的情况,有效提升了各业务类型的日志数据缓存的均衡性。The embodiment of the present application obtains the first log data uploaded by the business system. The first log data includes the first business tag; the log data current limit indicator value of the first business tag is determined according to the hash table, and the hash table includes at least one hash node. , the hash node is established based on different business labels and hash functions. The hash node is used to store the correspondence between the business label and the current limiting indicator value; when the current limiting indicator value meets the current limiting condition, the first log is prohibited from being The data is stored in the cache space of the log system. That is, after obtaining the first log data uploaded by the business system, the embodiment of this application can determine the current limiting flag value of the first business tag from the hash table, and when the current limiting flag value meets the current limiting condition, it is prohibited to use the first log data uploaded by the business system. One log data is stored in the cache space of the log system. This can avoid the situation where the output volume of log data of a certain business type is large and exhaust the cache of the log system, which in turn causes the log data of other business types to be unable to be cached and thus lost, effectively improving the This ensures the balance of log data caching for each business type.

下面对上述步骤进行详细说明,具体如下所示:The above steps are explained in detail below, as follows:

在S110中,业务系统用于处理不同的业务,业务系统在处理不同的业务时,针对每一种业务可以产生相应的日志数据,并将日志数据上传至日志系统,由日志系统进行缓存,方便后续用户查找和分析。In S110, the business system is used to process different businesses. When the business system processes different businesses, it can generate corresponding log data for each business and upload the log data to the log system, which will be cached by the log system for convenience. Subsequent user search and analysis.

第一业务标签可以是字符串,用于表征第一日志数据的业务类型,不同的业务类型可以对应不同的业务标签。针对不同的业务类型设置不同的业务标签,在后续缓存对应的日志数据时,可以避免集中存储一种或少数几种业务的日志数据,而造成其他类型业务的日志数据丢失的情况。The first service label may be a character string, used to characterize the service type of the first log data, and different service types may correspond to different service labels. Setting different business tags for different business types can avoid the centralized storage of log data for one or a few types of business, resulting in the loss of log data for other types of business when the corresponding log data is subsequently cached.

第一日志数据除了可以包括第一业务标签,还可以包括具体的日志内容。In addition to the first service tag, the first log data may also include specific log content.

示例性地,日志系统可以通过日志管理接口获取业务系统上传的第一日志数据。For example, the log system can obtain the first log data uploaded by the business system through the log management interface.

在S120中,哈希表包括至少一个哈希节点,一个哈希节点对应一个第一业务标签,例如日志系统接收到三种业务标签的日志数据,则哈希节点对应有三个,实际应用时,哈希节点的数量可以基于日志系统接收到的日志数据实时更新。In S120, the hash table includes at least one hash node, and one hash node corresponds to one first service label. For example, if the log system receives log data of three service labels, then there will be three corresponding hash nodes. In actual application, The number of hash nodes can be updated in real time based on log data received by the logging system.

示例性地,哈希节点可以基于业务标签以及哈希函数建立,例如,可以基于哈希函数对业务标签进行哈希运算,得到哈希结果,然后基于该哈希结果建立对应的哈希节点,并将该哈希结果与哈希节点关联存储。For example, the hash node can be established based on the business tag and the hash function. For example, the business tag can be hashed based on the hash function to obtain the hash result, and then the corresponding hash node can be established based on the hash result. And store the hash result in association with the hash node.

本申请实施例对哈希函数不进行限定,例如可以采用BKDRHash,APHash,DJBHash,JSHash,RSHash,SDBMHash,PJWHash,ELFHash等字符串哈希函数。The embodiment of the present application does not limit the hash function. For example, string hash functions such as BKDRHash, APHash, DJBHash, JSHash, RSHash, SDBMHash, PJWHash, and ELFHash may be used.

通过上述字符串哈希函数,可以将第一业务标签由字符串转换为一个身份标识(Ident ity document,ID)值,如此在后续基于第一业务标签查找哈希表时,只需将第一业务标签对应的ID值与哈希表中的各个哈希节点存储的ID值进行比较即可,如此可以大大降低字符串对比占用的时间。Through the above string hash function, the first business tag can be converted from a string into an identity document (ID) value, so that when the hash table is subsequently searched based on the first business tag, the first business tag only needs to be Just compare the ID value corresponding to the business tag with the ID value stored in each hash node in the hash table, which can greatly reduce the time taken by string comparison.

限流指标值可以是能够对第一日志数据限流的指标值,限流指标值可以基于业务系统传入的日志数据实时更新。The current limiting indicator value may be an indicator value capable of limiting the current flow of the first log data, and the current limiting indicator value may be updated in real time based on the log data incoming from the business system.

示例性地,限流指标值可以包括限流标志位,例如限流标志位为0时,表示可以对第一日志数据进行缓存,限流标志位为1时,表示禁止对第一日志数据缓存。For example, the current limiting indicator value may include a current limiting flag bit. For example, when the current limiting flag bit is 0, it indicates that the first log data can be cached; when the current limiting flag bit is 1, it indicates that caching of the first log data is prohibited. .

示例性地,限流指标值还可以包括限流开始时间,例如如果当前时间与限流开始时间的差值小于预设差值,可以禁止缓存第一日志数据,也即如果短时间内接收到大量的第一日志数据,需要对第一日志数据执行限流策略,避免其耗尽日志系统的缓存空间。当前时间可以是确定限流指标值的时间。For example, the current limiting index value may also include the current limiting start time. For example, if the difference between the current time and the current limiting start time is less than a preset difference, caching of the first log data may be prohibited. That is, if the first log data is received in a short period of time, For a large amount of first log data, it is necessary to implement a current limiting policy on the first log data to prevent it from exhausting the cache space of the log system. The current time may be the time at which the current limiting indicator value is determined.

不同业务标签的限流指标值可以关联存储至与业务标签对应的哈希节点上。The current limiting indicator values of different business labels can be stored in association with the hash nodes corresponding to the business labels.

示例性地,日志系统获取第一日志数据后,可以查找哈希表,确定第一业务标签的限流指标值,为后续执行限流策略提供依据。For example, after the log system obtains the first log data, it can search the hash table to determine the current limiting indicator value of the first business tag, thereby providing a basis for subsequent execution of the current limiting policy.

在S130中,限流条件用于对第一日志数据进行限流,即禁止将第一日志数据存储至日志系统的缓存空间。In S130, the current limiting condition is used to limit the current flow of the first log data, that is, it is prohibited to store the first log data in the cache space of the log system.

示例性地,当限流指标值满足限流条件时,禁止将第一日志数据存储至日志系统的缓存空间,当限流指标值不满足限流条件时,允许将第一日志数据存储至日志系统的缓存空间。For example, when the current limiting indicator value meets the current limiting condition, the first log data is prohibited from being stored in the cache space of the log system. When the current limiting indicator value does not meet the current limiting condition, the first log data is allowed to be stored in the log system's cache space. cache space.

本申请实施例通过对不同业务类型的日志数据限流可以有效过滤掉刷屏、无效、冗余以及不加限制的垃圾日志数据,避免这些垃圾日志数据占用较多的缓存空间,而导致正常的日志数据无法缓存进而丢失的情况。The embodiments of this application can effectively filter out spam, invalid, redundant and unrestricted junk log data by limiting the flow of log data of different business types, thereby preventing these junk log data from occupying more cache space and causing normal Log data cannot be cached and is lost.

在一些实施例中,上述S120可以包括以下步骤:In some embodiments, the above S120 may include the following steps:

比较第一业务标签和哈希表;Compare the first business tag and the hash table;

在哈希表中不包括第一业务标签的情况下,建立第一业务标签的哈希节点以及初始化与第一业务标签对应的限流指标值,并将初始化的限流指标值确定为第一业务标签的日志数据限流指标值;When the first service label is not included in the hash table, a hash node of the first service label is established and a current limiting indicator value corresponding to the first service label is initialized, and the initialized current limiting indicator value is determined as the first The log data current limit indicator value of the business tag;

在哈希表中包括第一业务标签的情况下,根据第一业务标签对应的哈希节点确定第一业务标签的日志数据限流指标值。When the hash table includes the first service label, the log data current limiting indicator value of the first service label is determined according to the hash node corresponding to the first service label.

在一些实施例中,为了提高查表效率,可以利用哈希函数对第一业务标签进行哈希运算,得到第一哈希值,并将第一哈希值与哈希表中的各哈希值进行比较,如果第一哈希值与哈希表中的某哈希值相同,可以确定第一业务标签存在于哈希表中,如果第一哈希值与哈希表中的各哈希值均不同,可以确定第一业务标签未存在于哈希表中。In some embodiments, in order to improve the efficiency of table lookup, a hash function can be used to perform a hash operation on the first business tag to obtain the first hash value, and the first hash value can be compared with each hash in the hash table. If the first hash value is the same as a hash value in the hash table, it can be determined that the first business tag exists in the hash table. If the first hash value is the same as each hash value in the hash table If the values are all different, it can be determined that the first service tag does not exist in the hash table.

在一些实施例中,在第一业务标签未存在于哈希表中的情况下,可以建立第一业务标签的哈希节点,并初始化第一业务标签的限流指标值。示例性地,可以新建一个哈希节点,并利用哈希函数对第一业务标签进行哈希运算,得到哈希值,并将该哈希值存储至新建的哈希节点上。In some embodiments, when the first service label does not exist in the hash table, a hash node of the first service label may be established, and the current limiting indicator value of the first service label may be initialized. For example, a new hash node can be created, a hash function is used to perform a hash operation on the first business tag, a hash value is obtained, and the hash value is stored in the newly created hash node.

示例性地,假定哈希表初始包含5个哈希节点,则可以在第哈希表的末尾新增一个哈希节点。For example, assuming that the hash table initially contains 5 hash nodes, a new hash node can be added at the end of the hash table.

在新增哈希节点的情况下,可以初始化第一业务标签的限流指标值,例如可以初始化统计时间、统计值的起始值为1,限流标志位为0,此时不存在限流开始时间。统计时间为统计值的起始值对应的记录时间。When a new hash node is added, the current limiting indicator value of the first service tag can be initialized. For example, the statistical time can be initialized, the starting value of the statistical value is 1, and the current limiting flag is 0. There is no current limiting at this time. Starting time. The statistical time is the recording time corresponding to the starting value of the statistical value.

此时可以将初始化的限流指标值作为第一业务标签的限流指标值,后续再接收到第一日志数据时,该哈希节点上存储的限流指标值可以更新。At this time, the initialized current limiting indicator value can be used as the current limiting indicator value of the first business tag. When the first log data is subsequently received, the current limiting indicator value stored on the hash node can be updated.

在一些实施例中,在第一业务标签存在于哈希表中的情况下,可以根据第一业务标签对应的哈希节点确定第一业务标签的日志数据限流指标值。例如可以将对应哈希节点上存储的限流指标值确定为第一业务标签的日志数据限流指标值。In some embodiments, when the first service label exists in the hash table, the log data current limiting indicator value of the first service label may be determined according to the hash node corresponding to the first service label. For example, the current limiting indicator value stored on the corresponding hash node may be determined as the log data current limiting indicator value of the first service tag.

本申请实施例可以比较第一业务标签和哈希表,确定第一业务标签的限流指标值,为后续执行限流策略提供基础。同时,在比较第一业务标签和哈希表时,可以先基于哈希函数对第一业务标签进行哈希运算,得到第一哈希值,然后将第一哈希值与哈希表中各个哈希节点的哈希值进行比较,如此可以大大降低字符串对比占用的时间,提高了查表的效率。Embodiments of the present application can compare the first service label and the hash table to determine the current limiting index value of the first service label, providing a basis for subsequent execution of the current limiting strategy. At the same time, when comparing the first business tag and the hash table, you can first perform a hash operation on the first business tag based on the hash function to obtain the first hash value, and then compare the first hash value with each of the hash tables. The hash value of the hash node is compared, which can greatly reduce the time taken by string comparison and improve the efficiency of table lookup.

在一些实施例中,上述实施例提到的哈希函数可以根据需要选取,例如可以选取几种常见的哈希算法,然后基于几种测试数据对几种哈希算法进行测试,以选取一种效果最好的哈希算法,用于本申请实施例。In some embodiments, the hash functions mentioned in the above embodiments can be selected as needed. For example, several common hash algorithms can be selected, and then several hash algorithms can be tested based on several test data to select one. The hash algorithm with the best effect is used in the embodiment of this application.

示例性地,可以选取三种哈希算法,分别为:For example, three hashing algorithms can be selected, namely:

算法1:对每个string字符串的每一个字符的asc码相加,再对其%1024取余;Algorithm 1: Add the ASC codes of each character of each string string, and then take the remainder of %1024;

算法2:基于算法1,对得到的余数再加上字符串最后一个字符的asc码;Algorithm 2: Based on Algorithm 1, add the asc code of the last character of the string to the remainder;

算法3:基于BKDRHash算法,再对其%1024取余。Algorithm 3: Based on the BKDRHash algorithm, and then take the remainder of %1024.

示例性地,测试数据可以包括以下三种:For example, test data can include the following three types:

数据1:随机生成的100个字符串,每个字符串长度8;Data 1: 100 randomly generated strings, each string length 8;

数据2:随机生成的500个字符串,每个字符串长度8;Data 2: 500 randomly generated strings, each string length 8;

数据3:随机生成的700个字符串,每个字符串长度8;Data 3: 700 randomly generated strings, each string length 8;

针对每一种算法,可以采用以下两种方式来建表和查表:For each algorithm, the following two methods can be used to create tables and look up tables:

方式一:将数据X通过HASH函计算出一个值,该值记作tagid。在建立哈希表时,若tagid对应处(哈希节点)无数据,直接写入;若tagid对应处已经有数据,并且关键字不匹配,向后新加一个哈希节点;在查找哈希表时,若tagid不一致,则向后遍历下一个哈希节点,继续查找。这里的数据X可以是上述数据1、数据2和数据3,HASH函数可以是上述的算法1、算法2和算法3。Method 1: Calculate a value of data X through the HASH function, and the value is recorded as tagid. When establishing a hash table, if there is no data corresponding to the tagid (hash node), write it directly; if there is data corresponding to the tagid and the keyword does not match, add a new hash node backward; after searching for the hash In the table, if the tagid is inconsistent, the next hash node will be traversed backwards and the search will continue. Data X here can be the above-mentioned data 1, data 2 and data 3, and the HASH function can be the above-mentioned algorithm 1, algorithm 2 and algorithm 3.

方式二:将数据X通过HASH函数计算出一个值,该值记作tagi d。在建立哈希表时,若tagi d对应处(哈希节点)无数据,直接写入;若tagi d对应处已经有数据,并且关键字不匹配,从头遍历哈希表,空位放入;在查找哈希表时,若tagi d不一致,则从头开始遍历哈希表,继续查找。Method 2: Calculate a value from the data X through the HASH function, and the value is recorded as tagi d. When establishing the hash table, if there is no data corresponding to tagi d (hash node), write it directly; if there is data corresponding to tagi d and the keywords do not match, the hash table is traversed from the beginning and the empty bits are put in; When searching the hash table, if tagi d is inconsistent, the hash table will be traversed from the beginning and the search will continue.

针对每一种算法,可以按照上述方式一和方式二,分别对数据1、数据2和数据3进行测试,得到建表的总时长、查表的总时长以及每个字符串的平均耗时时长等参数,具体可以参见表1和表2。For each algorithm, you can test data 1, data 2, and data 3 according to the above methods one and two, respectively, to get the total time to build the table, the total time to look up the table, and the average time of each string. and other parameters, see Table 1 and Table 2 for details.

表1方式一对应的参数Table 1 Parameters corresponding to mode 1

表2方式二对应的参数Table 2 Parameters corresponding to method 2

通过分析上述参数,可以看出方式一和算法3的冲突数较小,平均耗时更小,因此,可以将算法3作为本申请实施例的哈希函数,对第一业务标签进行哈希运算。By analyzing the above parameters, it can be seen that the number of conflicts between Method 1 and Algorithm 3 is smaller, and the average time consumption is smaller. Therefore, Algorithm 3 can be used as the hash function of the embodiment of the present application to perform a hash operation on the first business tag. .

其中,当两个哈希值相同,但对应的字符串的关键字不同时,称这两个哈希值在哈希表中存在冲突。示例性地,当两个哈希值相同,但关键字不同时,可以在哈希表中新增一个哈希节点。Among them, when two hash values are the same but the keywords of the corresponding strings are different, the two hash values are said to conflict in the hash table. For example, when two hash values are the same but the keys are different, a new hash node can be added to the hash table.

上述算法1、算法2和算法3只是其中一种示例,实际应用时,还可以对其他的算法进行测试,过程类似。The above-mentioned Algorithm 1, Algorithm 2 and Algorithm 3 are just one example. In actual application, other algorithms can also be tested, and the process is similar.

上述实施例中的第一哈希值也即上述示例中的tagid,也即可以基于BKDRHash算法对第一业务标签进行运算,然后再对运算结果%1024取余,得到第一哈希值。也即本申请实施例可以将第一业务标签由字符串转换成数值,如此在给予第一业务标签查找哈希表时,可以将字符串对比转换为数值对比,从而可大大提升查表的效率。The first hash value in the above embodiment is also the tagid in the above example, that is, the first service tag can be operated based on the BKDRHash algorithm, and then the operation result %1024 is modulated to obtain the first hash value. That is to say, the embodiment of the present application can convert the first business tag from a string into a numerical value. In this way, when searching the hash table for the first business tag, the string comparison can be converted into a numerical comparison, thereby greatly improving the efficiency of table lookup. .

示例性地,在比较第一业务标签和哈希表时,可以从哈希表的第一个哈希节点开始,也即将第一哈希值与第一个哈希节点的哈希值进行比较,如果两者不同,继续遍历一个哈希节点,也即按照上述方式一的方式进行查表,如此可以减少查表时长。For example, when comparing the first business tag and the hash table, you can start from the first hash node of the hash table, that is, compare the first hash value with the hash value of the first hash node. , if the two are different, continue to traverse a hash node, that is, perform table lookup according to the above method 1, which can reduce the table lookup time.

在本申请实施例中,限流条件与限流指标值有关,示例性地,限流指标值可以包括限流标志位和限流开始时间;In this embodiment of the present application, the current limiting condition is related to the current limiting indicator value. For example, the current limiting indicator value may include a current limiting flag and a current limiting start time;

相应地,限流指标值满足限流条件包括:限流标志位为第一标志位,且限流开始时间与第一时间的第一差值小于第一阈值,第一时间为根据哈希表确定第一业务标签的日志数据限流指标值的时间。Correspondingly, the current limiting index value satisfying the current limiting condition includes: the current limiting flag bit is the first flag bit, and the first difference between the current limiting start time and the first time is less than the first threshold, and the first time is according to the hash table The time to determine the log data current limiting indicator value of the first business tag.

限流开始时间为限制第一日志数据缓存的时间,示例性地,限流开始时间可以基于限流标志位确定。例如限流标志位为0表示不限流,限流标志位为1表示限流,则限流开始时间可以是限流标志位由0切换为1的时间。例如限流标志位是在9:05由0切换为1,则限流开始时间为9:05。The current limiting start time is the time to limit the first log data cache. For example, the current limiting start time can be determined based on the current limiting flag bit. For example, if the current limiting flag bit is 0, it means no current limiting, and if the current limiting flag bit is 1, it means current limiting, then the current limiting start time can be the time when the current limiting flag bit switches from 0 to 1. For example, if the current limit flag switches from 0 to 1 at 9:05, then the current limit start time is 9:05.

第一标志位为限制存储第一日志数据的标志位,例如第一标志位可以设置为1。The first flag bit is a flag bit that restricts storage of the first log data. For example, the first flag bit may be set to 1.

第一时间为根据哈希表确定第一业务标签的日志数据限流指标值的时间,也即限流指标值的确定时间。The first time is the time when the log data current limiting indicator value of the first business tag is determined based on the hash table, that is, the time when the current limiting indicator value is determined.

示例性地,当第一业务标签的限流标志位为1,且第一时间与限流开始时间的第一差值小于第一阈值时,可以禁止将第一日志数据存储至日志系统的缓存空间。第一阈值的大小可以根据实际需要设定,例如可以设置为1分钟或2分钟。For example, when the current limiting flag bit of the first service tag is 1, and the first difference between the first time and the current limiting start time is less than the first threshold, the first log data may be prohibited from being stored in the cache of the log system. space. The size of the first threshold can be set according to actual needs, for example, it can be set to 1 minute or 2 minutes.

本申请实施例可以对业务系统短时间内传入的大量的日志数据进行限流,如此可以避免其耗尽缓存空间,导致其他正常的日志数据因缓存空间耗尽而丢失的问题,提升了各业务类型的日志数据的缓存的均衡性。The embodiments of this application can limit the flow of a large amount of log data incoming from the business system in a short period of time. This can avoid the problem of running out of cache space, causing other normal log data to be lost due to the exhaustion of cache space, and improves the efficiency of various aspects. The balance of caching of business type log data.

在一些实施例中,限流指标值还可以包括统计值和统计时间,统计值表示获取的第一日志数据的数量,统计时间为统计值的起始值对应的记录时间;In some embodiments, the current limiting indicator value may also include a statistical value and a statistical time. The statistical value represents the number of first log data obtained, and the statistical time is the recording time corresponding to the starting value of the statistical value;

相应地,如图2所示,该业务处理方法可以包括以下步骤:Accordingly, as shown in Figure 2, the business processing method may include the following steps:

S210、获取业务系统上传的第一日志数据。S210. Obtain the first log data uploaded by the business system.

S220、根据哈希表确定第一业务标签的日志数据限流指标值。S220. Determine the log data current limiting indicator value of the first service tag according to the hash table.

S230、在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。S230. When the current limiting indicator value meets the current limiting condition, it is prohibited to store the first log data in the cache space of the log system.

S240、在限流标志位和第一差值至少有一个不满足限流条件的情况下,对统计值加1,得到更新后的统计值。S240. When at least one of the current limiting flag bit and the first difference value does not meet the current limiting condition, add 1 to the statistical value to obtain an updated statistical value.

S250、在更新后的统计值大于限流阈值的情况下,获取第一时间与统计时间的第二差值。S250. When the updated statistical value is greater than the current limiting threshold, obtain the second difference between the first time and the statistical time.

S260、在第二差值小于第二阈值的情况下,禁止将第一日志数据存储至日志系统的缓存空间。S260. When the second difference value is less than the second threshold, it is prohibited to store the first log data in the cache space of the log system.

S270、重置统计值、限流标志位以及限流开始时间。S270, reset statistical values, current limiting flag bits and current limiting start time.

其中,S210-S230的过程与上述S110-S130的过程相同,具体可以参见上述S110-S130,为简洁描述,此处不再赘述。Among them, the process of S210-S230 is the same as the above-mentioned process of S110-S130. For details, please refer to the above-mentioned S110-S130. For the sake of concise description, the details will not be repeated here.

下面对上述其他步骤进行详细说明,具体如下所示:The other steps mentioned above are explained in detail below, as follows:

在S240中,示例性地,限流标志位和第一差值至少有一个不满足限流条件,可以是限流标志位为第二标志位,第一差值小于第一阈值;也可以是限流标志位为第一标志位,第一差值不小于第一阈值;还可以是限流标志位为第二标志位,第一差值不小于第一阈值。In S240, for example, at least one of the current limiting flag bit and the first difference value does not meet the current limiting condition. The current limiting flag bit may be the second flag bit, and the first difference value is less than the first threshold; it may also be The current limiting flag is a first flag, and the first difference is not less than the first threshold; the current limiting flag can also be a second flag, and the first difference is not less than the first threshold.

第二标志位用于表征不对第一日志数据进行限流,示例性地,第二标志位可以设置为0。The second flag bit is used to indicate that the current flow of the first log data is not limited. For example, the second flag bit can be set to 0.

统计值用于统计日志系统获取到的第一日志数据的数量。示例性地,在限流标志位和限流开始时间至少有一个不满足限流条件的情况下,可以对统计值加1,从而更新日志系统获取到的第一日志数据的数量,为后续是否对第一日志数据限流提供基础。The statistical value is used to count the number of first log data obtained by the log system. For example, when at least one of the current limiting flag bit and the current limiting start time does not meet the current limiting condition, the statistical value can be increased by 1, thereby updating the number of first log data obtained by the log system to determine whether the subsequent Provides the basis for limiting the flow of first log data.

示例性地,在第一业务标签的限流标志位为0的情况下,可以对统计值加1。示例性地,在第一时间与限流开始时间的第一差值不小于第一阈值的情况下,可以对统计值加1。示例性地,在限流标志位为0且第一时间与限流开始时间的第一差值不小于第一阈值的情况下,可以对统计值加1。For example, when the current limiting flag bit of the first service tag is 0, 1 may be added to the statistical value. For example, if the first difference between the first time and the current limiting start time is not less than the first threshold, 1 may be added to the statistical value. For example, when the current limiting flag is 0 and the first difference between the first time and the current limiting start time is not less than the first threshold, 1 may be added to the statistical value.

在S250中,如果更新后的统计值大于限流阈值,可以获取第一时间与统计时间的第二差值。统计时间为统计值的起始值对应的记录时间,统计值的起始值可以是0或者1,具体可以参见下面的描述。In S250, if the updated statistical value is greater than the current limiting threshold, the second difference between the first time and the statistical time can be obtained. The statistical time is the recording time corresponding to the starting value of the statistical value. The starting value of the statistical value can be 0 or 1. For details, see the description below.

在S260中,若第一时间与统计时间的第二差值小于第二阈值,则可以禁止将第一日志数据存储至日志系统的缓存空间,若第一时间与统计时间的第二差值不小于第二阈值,则可以允许将第一日志数据存储至日志系统的缓存空间。第二阈值的大小可以根据实际需要设定。示例性地,第二阈值可以设置为1分钟。In S260, if the second difference between the first time and the statistical time is less than the second threshold, the first log data may be prohibited from being stored in the cache space of the log system. If the second difference between the first time and the statistical time is not If the value is less than the second threshold, the first log data may be allowed to be stored in the cache space of the log system. The size of the second threshold can be set according to actual needs. For example, the second threshold may be set to 1 minute.

在S270中,在第一时间与统计时间的第二差值小于第二阈值的情况下,除了禁止将第一日志数据存储至日志系统的缓存空间,还需要更新统计值、限流标志位以及限流开始时间。In S270, when the second difference between the first time and the statistical time is less than the second threshold, in addition to prohibiting the storage of the first log data into the cache space of the log system, the statistical value, the current limiting flag bit and the Current limiting start time.

示例性地,统计值可以重置为0,限流标志位可以由0重置为1,并设置限流开始时间。此时统计时间无需更新。For example, the statistical value can be reset to 0, the current limiting flag bit can be reset from 0 to 1, and the current limiting start time can be set. There is no need to update the statistical time at this time.

实际应用时,S260和S270可以同时执行,也可以先执行S260,再执行S270,或者先执行S270,再执行S260。S230和S240可以择一执行。In actual application, S260 and S270 can be executed at the same time, or S260 can be executed first and then S270, or S270 can be executed first and then S260. You can choose one of S230 and S240 to execute.

示例性地,在第一时间与统计时间的第二差值不小于第二阈值的情况下,除了允许将第一日志数据存储至日志系统的缓存空间,也需要更新统计值、统计时间以及限流标志位。For example, when the second difference between the first time and the statistical time is not less than the second threshold, in addition to allowing the first log data to be stored in the cache space of the log system, the statistical value, statistical time and limit also need to be updated. stream flag.

例如统计值可以重置为0,并重置统计时间,也即统计时间从统计值重置为0的时候开始计时。对于已经被限流的哈希节点,可以将限流标志位由1更新为0,也即解除限流。也即本申请实施例仅对短时间内的日志数据进行限流。For example, the statistical value can be reset to 0, and the statistical time can be reset, that is, the statistical time starts counting when the statistical value is reset to 0. For hash nodes that have been current-limited, the current-limiting flag can be updated from 1 to 0, that is, the current limitation is lifted. That is to say, the embodiment of this application only limits the flow of log data within a short period of time.

本申请实施例在限流标志位和限流开始时间至少有一个不满足限流条件时,可以进一步基于第一日志数据的统计值以及统计时间对第一日志数据进行限流处理,也即本申请实施例可以对业务系统短时间内输出的大量日志数据进行限流处理,避免其过度占用其他正常的日志数据的缓存空间。In the embodiment of the present application, when at least one of the current limiting flag bit and the current limiting start time does not meet the current limiting condition, the first log data can be further limited based on the statistical value and statistical time of the first log data, that is, this method The application embodiment can limit the flow of a large amount of log data output by the business system in a short period of time to prevent it from excessively occupying the cache space of other normal log data.

在一些实施例中,在S110之后,该日志处理方法还可以包括以下步骤:In some embodiments, after S110, the log processing method may also include the following steps:

记录获取第一日志数据的第二时间,并从第二时间开始计时;Record the second time when the first log data is obtained, and start timing from the second time;

在预设计时时长内未接收到第一日志数据的情况下,将哈希表中与第一日志数据对应的限流指标值从与第一业务标签对应的第一哈希节点中删除。If the first log data is not received within the preset timing period, the current limiting indicator value corresponding to the first log data in the hash table is deleted from the first hash node corresponding to the first service label.

示例性地,针对获取到的每一个第一日志数据,可以记录获取第一日志数据的第二时间,并从该第二时间开始计时,如果预设计时时长内未再接收到第一日志数据,此时可以将第一业务标签的哈希值以及对应的限流标志值从对应的哈希节点中移除,哈希节点可以保留。示例性地,预设计时时长可以设置为3分钟。For example, for each first log data obtained, a second time at which the first log data is obtained can be recorded, and the timing starts from the second time. If the first log data is not received again within the preset timing period, , at this time, the hash value of the first business tag and the corresponding current limit flag value can be removed from the corresponding hash node, and the hash node can be retained. For example, the preset timing duration can be set to 3 minutes.

以第一业务标签与第一哈希节点对应为例,如果预设计时时长内日志系统一直未接收到第一日志数据,则可以将第一哈希节点上存储的第一业务标签的哈希值和对应的限流指标值移除。Taking the correspondence between the first business label and the first hash node as an example, if the log system has not received the first log data within the preset timing period, the hash of the first business label stored on the first hash node can be value and the corresponding current limiting indicator value are removed.

如此可以降低哈希表的内存占用量,以及降低对应哈希值在哈希表中的冲突概率。This can reduce the memory footprint of the hash table and reduce the probability of collision of the corresponding hash value in the hash table.

由于某业务标签的日志数据在一段时间内未传入日志系统,导致部分哈希节点可能为空,即未包含哈希值以及对应的限流标志值,因此,在第一业务标签的哈希值与各哈希节点的哈希值均不同的情况下,也可以在空位的哈希节点中直接插入第一业务标签的哈希值以及对应的限流标志值,也即按照上述方式一建表。Since the log data of a certain business tag has not been transmitted to the log system for a period of time, some hash nodes may be empty, that is, they do not contain the hash value and the corresponding current limit flag value. Therefore, in the hash of the first business tag When the value is different from the hash value of each hash node, you can also directly insert the hash value of the first business tag and the corresponding current limit flag value into the empty hash node, that is, build it according to the above method. surface.

本申请实施例通过业务标签来区分不同的业务类型,并基于哈希函数建立哈希表,以此统计不同业务类型的日志输出频率和输出数量,并对超过阈值的日志数据,限制其存储,以此来达到对日志数据实时监控限流的目的。The embodiment of this application uses business tags to distinguish different business types, and establishes a hash table based on the hash function to count the log output frequency and output quantity of different business types, and limit the storage of log data that exceeds the threshold. This is used to achieve the purpose of real-time monitoring and flow limiting of log data.

下面通过一个示例,对本申请实施例提供的日志处理过程进行说明,具体如下所示:The following uses an example to illustrate the log processing process provided by the embodiment of this application, as follows:

如图3所示,日志系统接收业务系统上传的日志数据,该日志数据以业务标签(字符串)进行区分,通过哈希算法对业务标签进行哈希运算,得到哈希值,然后判断哈希值是否存在于哈希表,如果该哈希值存在于哈希表,进一步判断限流标志位和第一时间与限流开始时间的差值,如果限流标志位为1且该差值小于第一阈值,则禁止将该哈希值对应的日志数据存储至日志系统的缓存空间,并继续判断下一条日志数据。As shown in Figure 3, the log system receives log data uploaded by the business system. The log data is distinguished by business tags (strings). The business tags are hashed through a hash algorithm to obtain the hash value, and then the hash is determined. Whether the value exists in the hash table. If the hash value exists in the hash table, further determine the current limit flag and the difference between the first time and the current limit start time. If the current limit flag is 1 and the difference is less than When the first threshold is reached, the log data corresponding to the hash value is prohibited from being stored in the cache space of the log system, and the next piece of log data is continued to be judged.

如果限流标志位为0,和/或,该差值不小于第一阈值,对该哈希值对应的哈希节点的统计值加1,然后进一步判断更新后的统计值是否大于限流阈值,如果更新后的统计值不大于限流阈值,则允许将该哈希值对应的日志数据存储至日志系统的缓存空间,如果更新后的统计值大于限流阈值,可以进一步判断第一时间与统计时间的差值与第二阈值的关系。If the current limiting flag is 0, and/or, the difference is not less than the first threshold, add 1 to the statistical value of the hash node corresponding to the hash value, and then further determine whether the updated statistical value is greater than the current limiting threshold. , if the updated statistical value is not greater than the current limiting threshold, the log data corresponding to the hash value is allowed to be stored in the cache space of the log system. If the updated statistical value is greater than the current limiting threshold, it can be further determined that the first time and The relationship between the statistical time difference and the second threshold.

如果第一时间与统计时间的差值小于第二阈值,则重置对应哈希节点的统计值、限流标志位以及限流开始时间,并禁止将对应的日志数据存储至日志系统的缓存空间。如果第一时间与统计时间的差值不小于第二阈值,则允许将对应的日志数据存储至日志系统的缓存空间,并重置对应哈希节点的统计值(置0)以及统计时间,对于已经限流的哈希节点,将其限流标志位更新为0,解除限流。If the difference between the first time and the statistical time is less than the second threshold, the statistical value, current limiting flag bit, and current limiting start time of the corresponding hash node are reset, and the corresponding log data is prohibited from being stored in the cache space of the log system. . If the difference between the first time and the statistical time is not less than the second threshold, the corresponding log data is allowed to be stored in the cache space of the log system, and the statistical value of the corresponding hash node (set to 0) and the statistical time are reset. For hash nodes that have been current-limited, update their current-limit flag bits to 0 to lift the current limit.

如果该哈希值未存在于哈希表,则建立对应的哈希节点,并设置统计时间、统计值(置1)、限流标志位(置0)。If the hash value does not exist in the hash table, the corresponding hash node is established, and the statistical time, statistical value (set to 1), and current limit flag (set to 0) are set.

通过上述方案,可以显著提升各个业务类型日志输出的均衡性,即不会因为某个业务日志疯狂刷屏,而导致正常的缓存空间不够用,日志丢失。也即各个业务类型的日志均能有一部分可以存储至缓存空间中。此外,基于哈希函数对业务标签进行哈希运算,以将字符串对比转换为哈希值对比,极大地提高了日志系统的处理性能。Through the above solution, the balance of the log output of each business type can be significantly improved, that is, the normal cache space will not be enough and the logs will not be lost because of a certain business log crazily refreshing the screen. That is to say, part of the logs of each business type can be stored in the cache space. In addition, the business tags are hashed based on the hash function to convert the string comparison into a hash value comparison, which greatly improves the processing performance of the log system.

需要说明的是,本申请实施例在限流标志值满足限流条件时,除了可以禁止将日志数据存储至缓存空间,还可以进行告警,或者对于限流的日志数据,也可以加入黑名单,将未限流的日志数据加入白名单等。It should be noted that when the current limiting flag value meets the current limiting condition, in the embodiment of the present application, in addition to prohibiting the storage of log data in the cache space, an alarm can also be issued, or the log data with current limiting can also be added to a blacklist. Add unlimited log data to the whitelist, etc.

需要说明的是,本申请实施例提供的日志处理方法,执行主体可以为日志处理装置,或者该日志处理装置中的用于执行日志处理方法的处理模块。本申请实施例中以日志处理装置执行日志处理方法为例,说明本申请实施例提供的日志处理装置。It should be noted that, for the log processing method provided by the embodiment of the present application, the execution subject may be a log processing device, or a processing module in the log processing device for executing the log processing method. In the embodiment of the present application, the log processing device executing the log processing method is taken as an example to illustrate the log processing device provided by the embodiment of the present application.

图4为本申请实施例提供的一种日志处理装置的结构示意图。Figure 4 is a schematic structural diagram of a log processing device provided by an embodiment of the present application.

如图4所示,该日志处理装置400可以包括:As shown in Figure 4, the log processing device 400 may include:

获取模块401,用于获取业务系统上传的第一日志数据,所述第一日志数据包括第一业务标签;The acquisition module 401 is used to acquire the first log data uploaded by the business system, where the first log data includes the first business tag;

确定模块402,用于根据哈希表确定所述第一业务标签的日志数据限流指标值,所述哈希表包括至少一个哈希节点,所述哈希节点基于不同的业务标签以及哈希函数建立,所述哈希节点用于存储业务标签与限流指标值的对应关系;Determination module 402, configured to determine the log data current limiting indicator value of the first service tag according to a hash table. The hash table includes at least one hash node, and the hash node is based on different service tags and hashes. The function is established, and the hash node is used to store the corresponding relationship between the business tag and the current limiting indicator value;

处理模块403,用于在所述限流指标值满足限流条件的情况下,禁止将所述第一日志数据存储至日志系统的缓存空间。The processing module 403 is configured to prohibit storing the first log data in the cache space of the log system when the current limiting indicator value meets the current limiting condition.

本申请实施例获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。即本申请实施例在获取到业务系统上传的第一日志数据后,可以从哈希表中确定第一业务标签的限流标志值,并在限流标志值满足限流条件时,禁止将第一日志数据存储至日志系统的缓存空间,如此可以避免某一业务类型的日志数据输出量较大而耗尽日志系统的缓存,进而导致其他业务类型的日志数据无法缓存进而丢失的情况,有效提升了各业务类型的日志数据缓存的均衡性。The embodiment of the present application obtains the first log data uploaded by the business system. The first log data includes the first business tag; the log data current limit indicator value of the first business tag is determined according to the hash table, and the hash table includes at least one hash node. , the hash node is established based on different business labels and hash functions. The hash node is used to store the correspondence between the business label and the current limiting indicator value; when the current limiting indicator value meets the current limiting condition, the first log is prohibited from being The data is stored in the cache space of the log system. That is, after obtaining the first log data uploaded by the business system, the embodiment of this application can determine the current limiting flag value of the first business tag from the hash table, and when the current limiting flag value meets the current limiting condition, it is prohibited to use the first log data uploaded by the business system. One log data is stored in the cache space of the log system. This can avoid the situation where the output volume of log data of a certain business type is large and exhaust the cache of the log system, which in turn causes the log data of other business types to be unable to be cached and thus lost, effectively improving the This ensures the balance of log data caching for each business type.

在本申请实施例的一些可能实现中,确定模块401,具体用于:In some possible implementations of the embodiments of this application, the determination module 401 is specifically used to:

比较第一业务标签和哈希表;Compare the first business tag and the hash table;

在哈希表中不包括第一业务标签的情况下,建立第一业务标签的哈希节点以及初始化与第一业务标签对应的限流指标值,并将初始化的限流指标值确定为第一业务标签的日志数据限流指标值;When the first service label is not included in the hash table, a hash node of the first service label is established and a current limiting indicator value corresponding to the first service label is initialized, and the initialized current limiting indicator value is determined as the first The log data current limit indicator value of the business tag;

在哈希表中包括第一业务标签的情况下,根据第一业务标签对应的哈希节点确定第一业务标签的日志数据限流指标值。When the hash table includes the first service label, the log data current limiting indicator value of the first service label is determined according to the hash node corresponding to the first service label.

在本申请实施例的一些可能实现中,限流指标值包括限流标志位和限流开始时间;In some possible implementations of the embodiments of this application, the current limiting indicator value includes a current limiting flag and a current limiting start time;

限流指标值满足限流条件包括:限流标志位为第一标志位,且限流开始时间与第一时间的第一差值小于第一阈值,第一时间为根据哈希表确定第一业务标签的日志数据限流指标值的时间。The current limiting indicator value satisfies the current limiting conditions including: the current limiting flag bit is the first flag bit, and the first difference between the current limiting start time and the first time is less than the first threshold, and the first time is determined based on the hash table. The time of the log data current limiting indicator value of the business tag.

在本申请实施例的一些可能实现中,限流指标值还包括统计值和统计时间,统计值表示获取的第一日志数据的数量,统计时间为统计值的起始值对应的记录时间;In some possible implementations of the embodiments of this application, the current limiting indicator value also includes a statistical value and a statistical time. The statistical value represents the number of first log data obtained, and the statistical time is the recording time corresponding to the starting value of the statistical value;

处理模块403,还用于在确定模块402根据哈希表确定第一业务标签的日志数据限流指标值之后,在限流标志位和第一差值至少有一个不满足限流条件的情况下,对统计值加1,得到更新后的统计值;The processing module 403 is also configured to, after the determination module 402 determines the log data current limiting index value of the first service tag according to the hash table, if at least one of the current limiting flag bit and the first difference value does not meet the current limiting condition. , add 1 to the statistical value to obtain the updated statistical value;

获取模块401,还用于在更新后的统计值大于限流阈值的情况下,获取第一时间与统计时间的第二差值;The acquisition module 401 is also configured to acquire the second difference between the first time and the statistical time when the updated statistical value is greater than the current limiting threshold;

处理模块403,还用于在第二差值小于第二阈值的情况下,禁止将第一日志数据存储至日志系统的缓存空间;以及,重置统计值、限流标志位以及限流开始时间。The processing module 403 is also configured to prohibit storing the first log data into the cache space of the log system when the second difference is less than the second threshold; and to reset the statistical value, the current limiting flag bit, and the current limiting start time. .

在本申请实施例的一些可能实现中,处理模块403,还用于在获取模块获取业务系统上传的第一日志数据之后,记录获取第一日志数据的第二时间,并从第二时间开始计时;以及,In some possible implementations of the embodiments of this application, the processing module 403 is also configured to record the second time when the first log data is obtained after the acquisition module obtains the first log data uploaded by the business system, and start timing from the second time. ;as well as,

在预设计时时长内未接收到第一日志数据的情况下,将哈希表中与第一日志数据对应的限流指标值从与第一业务标签对应的第一哈希节点中删除。If the first log data is not received within the preset timing period, the current limiting indicator value corresponding to the first log data in the hash table is deleted from the first hash node corresponding to the first service label.

本申请实施例通过业务标签来区分不同的业务类型,并基于哈希函数建立哈希表,以此统计不同业务类型的日志输出频率和输出数量,并对超过阈值的日志数据,限制其存储,以此来达到对日志数据实时监控限流的目的。The embodiment of this application uses business tags to distinguish different business types, and establishes a hash table based on the hash function to count the log output frequency and output quantity of different business types, and limit the storage of log data that exceeds the threshold. This is used to achieve the purpose of real-time monitoring and flow limiting of log data.

本申请实施例中的应用于电子设备的日志处理装置可以是装置,也可以是电子设备中的部件,例如集成电路或芯片。该电子设备可以是终端,也可以为除终端之外的其他设备。示例性的,电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、移动上网装置(Mobile Internet Device,MID)、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、机器人、可穿戴设备、超级移动个人计算机(ultra-mobilepersonal computer,UMPC)、上网本或者个人数字助理(personal digital assistant,PDA)等,还可以为服务器、网络附属存储器(NetworkAttached Storage,NAS)、个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。The log processing device applied to electronic equipment in the embodiment of the present application may be a device or a component in the electronic equipment, such as an integrated circuit or a chip. The electronic device may be a terminal or other devices other than the terminal. For example, the electronic device may be a mobile phone, a tablet computer, a notebook computer, a handheld computer, a vehicle-mounted electronic device, a mobile Internet device (MID), or augmented reality (AR)/virtual reality (VR). ) equipment, robots, wearable devices, ultra-mobile personal computers (UMPC), netbooks or personal digital assistants (PDA), etc., and can also be servers, network attached storage (Network Attached Storage, NAS) , personal computer (PC), television (TV), teller machine or self-service machine, etc., the embodiments of this application are not specifically limited.

本申请实施例中的电子设备可以为具有操作系统的电子设备。该操作系统可以为安卓(Android)操作系统,可以为iOS操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。The electronic device in the embodiment of the present application may be an electronic device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiments of this application.

本申请实施例提供的应用于电子设备的日志处理装置能够实现图1至图3的应用于电子设备的日志处理方法实施例中的各个过程,为避免重复,这里不再赘述。The log processing device applied to electronic equipment provided by the embodiment of the present application can implement each process in the embodiment of the log processing method applied to electronic equipment in Figures 1 to 3. To avoid duplication, the details will not be described here.

如图5所示,本申请实施例还提供一种电子设备,包括处理器501和存储器502,存储器502存储可在处理器501上运行的程序或指令,该程序或指令被处理器501执行时实现上述投屏方法实施例的各个步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。As shown in Figure 5, this embodiment of the present application also provides an electronic device, including a processor 501 and a memory 502. The memory 502 stores programs or instructions that can be run on the processor 501. When the program or instructions are executed by the processor 501 Each step of the above embodiment of the screen projection method can be implemented and the same technical effect can be achieved. To avoid repetition, the details will not be described again here.

需要说明的是,本申请实施例中的电子设备包括上述所述的移动电子设备和非移动电子设备。It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

图6为本申请实施例提供的一种电子设备的硬件结构示意图。FIG. 6 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.

该电子设备600包括但不限于:射频单元601、网络模块602、音频输出单元603、输入单元604、传感器605、显示单元606、用户输入单元607、接口单元608、存储器609、以及处理器610等部件。The electronic device 600 includes but is not limited to: radio frequency unit 601, network module 602, audio output unit 603, input unit 604, sensor 605, display unit 606, user input unit 607, interface unit 608, memory 609, processor 610, etc. part.

本领域技术人员可以理解,电子设备600还可以包括给各个部件供电的电源(比如电池),电源可以通过电源管理系统与处理器610逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。图6中示出的电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,在此不再赘述。Those skilled in the art can understand that the electronic device 600 may also include a power supply (such as a battery) that supplies power to various components. The power supply may be logically connected to the processor 610 through a power management system, thereby managing charging, discharging, and function through the power management system. Consumption management and other functions. The structure of the electronic device shown in Figure 6 does not constitute a limitation on the electronic device. The electronic device may include more or less components than shown in the figure, or combine certain components, or arrange different components, which will not be described again here. .

其中,输入单元604,用于获取业务系统上传的第一日志数据,所述第一日志数据包括第一业务标签;Among them, the input unit 604 is used to obtain the first log data uploaded by the business system, where the first log data includes the first business tag;

处理器610,用于根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;以及,Processor 610, configured to determine the log data current limiting indicator value of the first business tag according to the hash table. The hash table includes at least one hash node. The hash node is established based on different business tags and hash functions. The hash node Used to store the correspondence between business tags and current limiting indicator values; and,

在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。When the current limiting indicator value meets the current limiting condition, the first log data is prohibited from being stored in the cache space of the log system.

本申请实施例获取业务系统上传的第一日志数据,第一日志数据包括第一业务标签;根据哈希表确定第一业务标签的日志数据限流指标值,哈希表包括至少一个哈希节点,哈希节点基于不同的业务标签以及哈希函数建立,哈希节点用于存储业务标签与限流指标值的对应关系;在限流指标值满足限流条件的情况下,禁止将第一日志数据存储至日志系统的缓存空间。即本申请实施例在获取到业务系统上传的第一日志数据后,可以从哈希表中确定第一业务标签的限流标志值,并在限流标志值满足限流条件时,禁止将第一日志数据存储至日志系统的缓存空间,如此可以避免某一业务类型的日志数据输出量较大而耗尽日志系统的缓存,进而导致其他业务类型的日志数据无法缓存进而丢失的情况,有效提升了各业务类型的日志数据缓存的均衡性。The embodiment of the present application obtains the first log data uploaded by the business system. The first log data includes the first business tag; the log data current limit indicator value of the first business tag is determined according to the hash table, and the hash table includes at least one hash node. , the hash node is established based on different business labels and hash functions. The hash node is used to store the correspondence between the business label and the current limiting indicator value; when the current limiting indicator value meets the current limiting condition, the first log is prohibited from being The data is stored in the cache space of the log system. That is, after obtaining the first log data uploaded by the business system, the embodiment of this application can determine the current limiting flag value of the first business tag from the hash table, and when the current limiting flag value meets the current limiting condition, it is prohibited to use the first log data uploaded by the business system. One log data is stored in the cache space of the log system. This can avoid the situation where the output volume of log data of a certain business type is large and exhaust the cache of the log system, which in turn causes the log data of other business types to be unable to be cached and thus lost, effectively improving the This ensures the balance of log data caching for each business type.

在本申请实施例的一些可能实现中,处理器610,具体用于:In some possible implementations of the embodiments of this application, the processor 610 is specifically used to:

比较第一业务标签和哈希表;Compare the first business tag and the hash table;

在哈希表中不包括第一业务标签的情况下,建立第一业务标签的哈希节点以及初始化与第一业务标签对应的限流指标值,并将初始化的限流指标值确定为第一业务标签的日志数据限流指标值;When the first service label is not included in the hash table, a hash node of the first service label is established and a current limiting indicator value corresponding to the first service label is initialized, and the initialized current limiting indicator value is determined as the first The log data current limit indicator value of the business tag;

在哈希表中包括第一业务标签的情况下,根据第一业务标签对应的哈希节点确定第一业务标签的日志数据限流指标值。When the hash table includes the first service label, the log data current limiting indicator value of the first service label is determined according to the hash node corresponding to the first service label.

在本申请实施例的一些可能实现中,限流指标值包括限流标志位和限流开始时间;In some possible implementations of the embodiments of this application, the current limiting indicator value includes a current limiting flag and a current limiting start time;

限流指标值满足限流条件包括:限流标志位为第一标志位,且限流开始时间与第一时间的第一差值小于第一阈值,第一时间为根据哈希表确定第一业务标签的日志数据限流指标值的时间。The current limiting indicator value satisfies the current limiting conditions including: the current limiting flag bit is the first flag bit, and the first difference between the current limiting start time and the first time is less than the first threshold, and the first time is determined based on the hash table. The time of the log data current limiting indicator value of the business tag.

在本申请实施例的一些可能实现中,限流指标值还包括统计值和统计时间,统计值表示获取的第一日志数据的数量,统计时间为统计值的起始值对应的记录时间;In some possible implementations of the embodiments of this application, the current limiting indicator value also includes a statistical value and a statistical time. The statistical value represents the number of first log data obtained, and the statistical time is the recording time corresponding to the starting value of the statistical value;

处理器610,还用于在确定模块根据哈希表确定第一业务标签的日志数据限流指标值之后,在限流标志位和第一差值至少有一个不满足限流条件的情况下,对统计值加1,得到更新后的统计值;The processor 610 is also configured to: after the determination module determines the log data current limiting indicator value of the first service tag according to the hash table, if at least one of the current limiting flag bit and the first difference value does not meet the current limiting condition, Add 1 to the statistical value to obtain the updated statistical value;

输入单元604,还用于在更新后的统计值大于限流阈值的情况下,获取第一时间与统计时间的第二差值;The input unit 604 is also used to obtain the second difference between the first time and the statistical time when the updated statistical value is greater than the current limiting threshold;

处理器610,还用于在第二差值小于第二阈值的情况下,禁止将第一日志数据存储至日志系统的缓存空间;以及,重置统计值、限流标志位以及限流开始时间。The processor 610 is also configured to prohibit storing the first log data into the cache space of the log system when the second difference is less than the second threshold; and to reset the statistical value, the current limiting flag bit, and the current limiting start time. .

在本申请实施例的一些可能实现中,处理器610,还用于在获取模块获取业务系统上传的第一日志数据之后,记录获取第一日志数据的第二时间,并从第二时间开始计时;以及,In some possible implementations of the embodiments of this application, the processor 610 is also configured to record the second time when the first log data is obtained after the acquisition module obtains the first log data uploaded by the business system, and start timing from the second time. ;as well as,

在预设计时时长内未接收到第一日志数据的情况下,将哈希表中与第一日志数据对应的限流指标值从与第一业务标签对应的第一哈希节点中删除。If the first log data is not received within the preset timing period, the current limiting indicator value corresponding to the first log data in the hash table is deleted from the first hash node corresponding to the first service label.

本申请实施例通过业务标签来区分不同的业务类型,并基于哈希函数建立哈希表,以此统计不同业务类型的日志输出频率和输出数量,并对超过阈值的日志数据,限制其存储,以此来达到对日志数据实时监控限流的目的。The embodiment of this application uses business tags to distinguish different business types, and establishes a hash table based on the hash function to count the log output frequency and output quantity of different business types, and limit the storage of log data that exceeds the threshold. This is used to achieve the purpose of real-time monitoring and flow limiting of log data.

应理解的是,本申请实施例中,输入单元604可以包括图形处理器(GraphicsProcessing Unit,GPU)6041和麦克风6042,图形处理器6041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。显示单元606可包括显示面板6061,可以采用液晶显示器、有机发光二极管等形式来配置显示面板6061。用户输入单元607包括触控面板6071以及其他输入设备6072中的至少一种。触控面板6071,也称为触摸屏。触控面板6071可包括触摸检测装置和触摸控制器两个部分。其他输入设备6072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (Graphics Processing Unit, GPU) 6041 and a microphone 6042. The graphics processor 6041 is responsible for the processing of images by an image capture device (such as Process the image data of still pictures or videos obtained by the camera). The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072 . Touch panel 6071, also called touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include but are not limited to physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be described again here.

存储器609可用于存储软件程序以及各种数据。存储器609可主要包括存储程序或指令的第一存储区和存储数据的第二存储区,其中,第一存储区可存储操作系统、至少一个功能所需的应用程序或指令(比如声音播放功能、图像播放功能等)等。此外,存储器609可以包括易失性存储器或非易失性存储器,或者,存储器609可以包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synch link DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本申请实施例中的存储器609包括但不限于这些和任意其它适合类型的存储器。Memory 609 may be used to store software programs as well as various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, Image playback function, etc.) etc. Additionally, memory 609 may include volatile memory or non-volatile memory, or memory 609 may include both volatile and non-volatile memory. Among them, the non-volatile memory can be read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), electrically removable memory. Erase programmable read-only memory (Electrically EPROM, EEPROM) or flash memory. Volatile memory can be random access memory (Random Access Memory, RAM), static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (Synch link DRAM) , SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DRRAM). Memory 609 in embodiments of the present application includes, but is not limited to, these and any other suitable types of memory.

处理器610可包括一个或多个处理单元;可选的,处理器610集成应用处理器和调制解调处理器,其中,应用处理器主要处理涉及操作系统、用户界面和应用程序等的操作,调制解调处理器主要处理无线通信信号,如基带处理器。可以理解的是,上述调制解调处理器也可以不集成到处理器610中。The processor 610 may include one or more processing units; optionally, the processor 610 integrates an application processor and a modem processor, where the application processor mainly handles operations related to the operating system, user interface, application programs, etc., Modem processors mainly process wireless communication signals, such as baseband processors. It can be understood that the above modem processor may not be integrated into the processor 610.

本申请实施例还提供一种可读存储介质,可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述应用于电子设备的日志处理方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。Embodiments of the present application also provide a readable storage medium. Programs or instructions are stored on the readable storage medium. When the program or instructions are executed by the processor, each process of the above embodiment of the log processing method applied to electronic devices is implemented, and can achieve the same technical effect, so to avoid repetition, we will not repeat them here.

其中,处理器为上述实施例中所述的电子设备中的处理器。可读存储介质包括计算机可读存储介质,如计算机只读存储器ROM、随机存取存储器RAM、磁碟或者光盘等。Wherein, the processor is the processor in the electronic device described in the above embodiment. Readable storage media include computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disks or optical disks.

本申请实施例另提供了一种芯片,芯片包括处理器和通信接口,通信接口和处理器耦合,处理器用于运行程序或指令,实现上述应用于电子设备的日志处理方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。An embodiment of the present application also provides a chip. The chip includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above embodiment of the log processing method applied to electronic devices. And can achieve the same technical effect. To avoid repetition, they will not be described again here.

应理解,本申请实施例提到的芯片还可以称为系统级芯片、系统芯片、芯片系统或片上系统芯片等。It should be understood that the chips mentioned in the embodiments of this application may also be called system-on-chip, system-on-a-chip, system-on-a-chip or system-on-chip, etc.

本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如上述应用于电子设备的日志处理方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。Embodiments of the present application provide a computer program product. The program product is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above log processing method embodiments applied to electronic devices, and can To achieve the same technical effect, to avoid repetition, we will not repeat them here.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。It should be noted that, in this document, the terms "comprising", "comprises" or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or device that includes a series of elements not only includes those elements, It also includes other elements not expressly listed or inherent in the process, method, article or apparatus. Without further limitation, an element defined by the statement "comprises a..." does not exclude the presence of additional identical elements in a process, method, article or apparatus that includes that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, but may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. Functions may be performed, for example, the methods described may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is better. implementation. Based on this understanding, the technical solution of the present application can be embodied in the form of a computer software product that is essentially or contributes to related technologies. The computer software product is stored in a storage medium (such as ROM/RAM, disk, CD), including several instructions to cause a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in various embodiments of this application.

上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only illustrative and not restrictive. Those of ordinary skill in the art will Inspired by this application, many forms can be made without departing from the purpose of this application and the scope protected by the claims, all of which fall within the protection of this application.

Claims (11)

1. A log processing method, comprising:
acquiring first log data uploaded by a service system, wherein the first log data comprises a first service tag;
determining a log data flow limiting index value of the first service label according to a hash table, wherein the hash table comprises at least one hash node, the hash node is established based on different service labels and hash functions, and the hash node is used for storing the corresponding relation between the service labels and the flow limiting index value;
and under the condition that the current limiting index value meets the current limiting condition, prohibiting the first log data from being stored in a cache space of a log system.
2. The method of claim 1, wherein determining the log data restriction index value for the first traffic label from the hash table comprises:
comparing the first service tag with the hash table;
under the condition that the hash table does not comprise the first business label, a hash node of the first business label is established, a flow limiting index value corresponding to the first business label is initialized, and the initialized flow limiting index value is determined to be the log data flow limiting index value of the first business label;
And under the condition that the hash table comprises the first service label, determining a log data flow limiting index value of the first service label according to the hash node corresponding to the first service label.
3. The method of claim 1, wherein the current limit indicator value comprises a current limit flag bit and a current limit start time;
the current limiting index value meeting a current limiting condition includes: the current limiting flag bit is a first flag bit, a first difference value between the current limiting start time and a first time is smaller than a first threshold value, and the first time is the time for determining the log data current limiting index value of the first service tag according to a hash table.
4. The method according to claim 3, wherein the current limit index value further includes a statistic value representing the number of the first log data acquired and a statistic time corresponding to a start value of the statistic value;
after the determining the log data flow restriction index value of the first service tag according to the hash table, the method further includes:
adding 1 to the statistical value under the condition that at least one of the current limiting zone bit and the first difference value does not meet the current limiting condition to obtain an updated statistical value;
Acquiring a second difference value between the first time and the statistical time under the condition that the updated statistical value is larger than a current limiting threshold value;
if the second difference value is smaller than a second threshold value, the first log data is forbidden to be stored in a cache space of the log system;
and resetting the statistic value, the current limit flag bit and the current limit starting time.
5. The method of claim 1, wherein after the obtaining the first log data uploaded by the service system, the method further comprises:
recording a second time for acquiring the first log data, and starting timing from the second time;
and deleting the current limiting index value corresponding to the first log data in the hash table from the first hash node corresponding to the first service label under the condition that the first log data is not received within a preset time duration.
6. A log processing apparatus, comprising:
the system comprises an acquisition module, a service system and a service system, wherein the acquisition module is used for acquiring first log data uploaded by the service system, and the first log data comprises a first service tag;
the determining module is used for determining the log data flow limiting index value of the first service label according to a hash table, the hash table comprises at least one hash node, the hash node is established based on different service labels and hash functions, and the hash node is used for storing the corresponding relation between the service labels and the flow limiting index value;
And the processing module is used for prohibiting the first log data from being stored in the cache space of the log system under the condition that the current limiting index value meets the current limiting condition.
7. The apparatus according to claim 6, wherein the determining module is specifically configured to:
comparing the first service tag with the hash table;
under the condition that the hash table does not comprise the first business label, a hash node of the first business label is established, a flow limiting index value corresponding to the first business label is initialized, and the initialized flow limiting index value is determined to be the log data flow limiting index value of the first business label;
and under the condition that the hash table comprises the first service label, determining a log data flow limiting index value of the first service label according to the hash node corresponding to the first service label.
8. The apparatus of claim 6, wherein the current limit indicator value comprises a current limit flag bit and a current limit start time;
the current limiting index value meeting a current limiting condition includes: the current limiting flag bit is a first flag bit, a first difference value between the current limiting start time and a first time is smaller than a first threshold value, and the first time is the time for determining the log data current limiting index value of the first service tag according to a hash table.
9. The apparatus of claim 8, wherein the current limit index value further comprises a statistics value and a statistics time, the statistics value representing the number of the first log data acquired, the statistics time being a recording time corresponding to a start value of the statistics value;
the processing module is further configured to add 1 to the statistics value under a condition that at least one of the current limit flag bit and the first difference value does not satisfy the current limit condition after the determining module determines the log data current limit index value of the first service label according to the hash table, so as to obtain an updated statistics value;
the obtaining module is further configured to obtain a second difference value between the first time and the statistical time when the updated statistical value is greater than a current limiting threshold;
the processing module is further configured to prohibit storing the first log data to a cache space of the log system if the second difference value is smaller than a second threshold value; and resetting the statistics, the current limit flag bit and the current limit start time.
10. The apparatus of claim 6, wherein the processing module is further configured to record a second time for acquiring the first log data after the acquiring module acquires the first log data uploaded by the service system, and start timing from the second time; the method comprises the steps of,
And deleting the current limiting index value corresponding to the first log data in the hash table from the first hash node corresponding to the first service label under the condition that the first log data is not received within a preset time duration.
11. An electronic device comprising a processor and a memory storing a program or instructions executable on the processor, which when executed by the processor, implement the steps of the method of any one of claims 1 to 5.
CN202311035136.1A 2023-08-16 2023-08-16 Log processing method, device and equipment Pending CN117033332A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311035136.1A CN117033332A (en) 2023-08-16 2023-08-16 Log processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311035136.1A CN117033332A (en) 2023-08-16 2023-08-16 Log processing method, device and equipment

Publications (1)

Publication Number Publication Date
CN117033332A true CN117033332A (en) 2023-11-10

Family

ID=88633294

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311035136.1A Pending CN117033332A (en) 2023-08-16 2023-08-16 Log processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN117033332A (en)

Similar Documents

Publication Publication Date Title
WO2017185616A1 (en) File storage method and electronic equipment
CN112422484B (en) Method, apparatus, and storage medium for determining scenario for processing security event
CN111756644B (en) Hot spot current limiting method, system, equipment and storage medium
KR101719500B1 (en) Acceleration based on cached flows
CN104025520B (en) Method for creating lookup table, query method, controller, forwarding device and system
CN113486037B (en) Method, manager and cache server for updating cache data
US20210250404A1 (en) Video data storage method and device in cloud storage system
CN112711564B (en) Merge processing method and related equipment
CN111930305A (en) Data storage method and device, storage medium, electronic device
CN110222046B (en) List data processing method, device, server and storage medium
CN104123102A (en) IP hard disk and data processing method thereof
US9659041B2 (en) Model for capturing audit trail data with reduced probability of loss of critical data
CN107016296B (en) Data index construction method, data index reading method, data index construction device, data reading device and electronic equipment
CN117033332A (en) Log processing method, device and equipment
WO2020220534A1 (en) Middleware-based data processing method and related apparatus
CN117112614A (en) Online evolution method, device, equipment and storage medium for execution plan
CN116955271A (en) Method and device for storing data copy, electronic equipment and storage medium
CN114968558A (en) Memory cleaning method and related equipment
CN112395613B (en) Static feature library loading method, device and equipment
CN115766696A (en) A file upload method, device, electronic equipment and storage medium
CN103502953B (en) Method and device for improving concurrency performance of distributed object storage system
CN113672248A (en) A patch acquisition method, device, server and storage medium
CN111629227A (en) Video conversion method, device, system, electronic device and storage medium
CN116915703B (en) Table entry expulsion method, device and electronic equipment
CN114356579B (en) Memory cache service node analysis method, device and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination