Skywalking-based Metric Collection Method and Related Devices

Through the Skywalking indicator acquisition method, CPU occupancy, heap memory and non-heap memory indicators are collected and calculated, which solves the problem of inaccurate collection in the existing technology, realizes more accurate monitoring data, and provides stronger support for operation and maintenance.

CN115269332BActive Publication Date: 2025-06-27国家电网有限公司客户服务中心
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210919159.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2025-06-27
Estimated Expiration
2042-08-02

AI Technical Summary

Technical Problem

In the prior art, there are problems of inaccurate acquisition of CPU occupancy, heap memory and non-heap memory indicators, resulting in inconvenient operation and maintenance analysis and positioning problems.

Method used

The index acquisition method based on Skywalking is adopted to collect CPU acquisition data related to CPU occupancy through the pre-deployed Skywalking probe, and the CPU occupancy index is obtained through the total CPU time slice function calculation; data related to heap memory and non-heap memory are collected at the same time, and accurate indicators are obtained through the corresponding function calculation.

Benefits of technology

It realizes accurate collection of CPU occupancy, heap memory and non-heap memory indicators, improves monitoring value, and provides more powerful data support for problem positioning during operation and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269332B_ABST
    Figure CN115269332B_ABST
Patent Text Reader

Abstract

The present application provides a method for collecting metrics based on Skywalking and related devices. The method includes: using pre-deployed Skywalking probes to collect first-time CPU collection data and second-time CPU collection data related to CPU occupancy metrics, heap memory metric association data, and main memory data related to non-heap memory, then obtaining the total CPU time slices at the first time and the total CPU time slices at the second time through the first total CPU time slice function and the second total CPU time slice function, and then calculating the CPU occupancy metric through the CPU occupancy rate function; calculating the heap memory metric through the heap memory function; calculating the non-heap memory metric through the non-heap memory optimization function; storing the CPU occupancy metric, the heap memory metric, and the non-heap memory metric through Skywalking. This makes the obtained CPU occupancy metric, heap memory metric, and non-heap memory metric more accurate and effective, providing more powerful data support for metric monitoring during the operation and maintenance process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data collection, and particularly to a metric collection method and related devices based on Skywalking. Background Art

[0002] When measuring the performance of a server, metric data is often involved. Each metric has a unique meaning. In many cases, when problems occur online, certain metrics often show abnormalities. In most cases, certain metrics will show abnormalities in advance before the problem occurs.

[0003] Based on the above situation, when using the metric collection methods in the prior art to collect metrics such as CPU (Central Processing Unit) occupancy rate, heap memory, and non-heap memory, there are problems of inaccurate collection and no monitoring value, which causes certain inconvenience to operation and maintenance analysis and problem location. Summary of the Invention

[0004] In view of this, the purpose of this application is to propose a metric collection method and related devices based on Skywalking to solve or partially solve the above technical problems.

[0005] Based on the above purpose, the first aspect of this application provides a metric collection method based on Skywalking, including:

[0006] Collect first-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice at the first time through a first total CPU time slice function according to the first-time CPU collection data;

[0007] Collect second-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice at the second time through a second total CPU time slice function according to the second-time CPU collection data;

[0008] Calculate the CPU occupancy rate metric by calculating the total CPU time slice at the first time and the total CPU time slice at the second time through a CPU occupancy rate function;

[0009] Collect heap memory metric association data through a pre-deployed Skywalking probe, and calculate the heap memory metric based on the heap memory metric association data through a heap memory function;

[0010] Collect the main memory data related to the non-heap memory through the pre-deployed Skywalking probes, and calculate the non-heap memory metrics according to the main memory data through the non-heap memory optimization function;

[0011] Take the CPU occupancy rate metrics, the heap memory metrics, and the non-heap memory metrics as the final collected metrics, and store the final collected metrics through the Skywalking.

[0012] Optionally, the first-time CPU collection data includes:

[0013] The number of CPU time slices occupied by the user space at the first time and the number of CPU time slices occupied by the kernel space at the first time and the number of CPU time slices occupied by the processes with changed priorities in the user process space at the first time and the number of idle CPU time slices at the first time and the number of CPU time slices occupied by waiting for input / output at the first time and the number of CPU time slices occupied by hard interrupts at the first time and the number of time slices occupied by soft interrupts at the first time ;

[0014] The specific first total CPU time slice function is:

[0015] .

[0016] Optionally, the second-time CPU collection data includes:

[0017] The number of CPU time slices occupied by the user space at the second time and the number of CPU time slices occupied by the kernel space at the second time and the number of CPU time slices occupied by the processes with changed priorities in the user process space at the second time and the number of idle CPU time slices at the second time and the number of CPU time slices occupied by waiting for input / output at the second time and the number of CPU time slices occupied by hard interrupts at the second time and the number of time slices occupied by soft interrupts at the second time ;

[0018] The specific second total CPU time slice function is:

[0019] .

[0020] Optionally, the specific CPU occupancy rate function is:

[0021] 。

[0022] Optionally, the heap memory metric associated data includes Eden area data , survivor area data and tenured generation area data , where the heap memory includes: Eden area, survivor area and tenured generation area;

[0023] The heap memory function is specifically:

[0024] 。

[0025] Optionally, the non-heap memory optimization function is specifically:

[0026] 。

[0027] Optionally, the time interval between the first time and the second time is 1 second.

[0028] Based on the same inventive concept, a second aspect of the present application provides a metric collection device based on Skywalking, including:

[0029] The first total CPU time slice processing module is configured to collect first-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice of the first time through a first total CPU time slice function according to the first-time CPU collection data;

[0030] The second total CPU time slice processing module is configured to collect second-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice of the second time through a second total CPU time slice function according to the second-time CPU collection data;

[0031] The CPU occupancy rate metric acquisition module is configured to calculate the CPU occupancy rate metric by passing the total CPU time slice of the first time and the total CPU time slice of the second time through a CPU occupancy rate function;

[0032] The heap memory metric acquisition module is configured to collect heap memory metric associated data through a pre-deployed Skywalking probe, and calculate the heap memory metric based on the heap memory metric associated data through a heap memory function;

[0033] The non-heap memory metric acquisition module is configured to collect main memory data related to non-heap memory through a pre-deployed Skywalking probe, and calculate non-heap memory metrics based on the main memory data through a non-heap memory optimization function;

[0034] The metric storage module is configured to use the CPU occupancy rate metric, the heap memory metric, and the non-heap memory metric as the final collected metrics, and store the final collected metrics through the Skywalking.

[0035] Based on the same inventive concept, a third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.

[0036] Based on the same inventive concept, a fourth aspect of the present application provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions for causing a computer to execute the method described in the first aspect.

[0037] As can be seen from the above, the method and related devices for collecting metrics based on Skywalking provided in this application use the pre-deployed Skywalking probes to collect the first-time CPU collection data related to the CPU occupancy rate metric, calculate the total CPU time slice at the first time through the first total CPU time slice function according to the first-time CPU collection data, use the pre-deployed Skywalking probes to collect the second-time CPU collection data related to the CPU occupancy rate metric, calculate the total CPU time slice at the second time through the second total CPU time slice function according to the second-time CPU collection data, and then calculate the CPU occupancy rate metric by passing the total CPU time slice at the first time and the total CPU time slice at the second time through the CPU occupancy rate function. It can accurately collect the data related to the CPU occupancy rate metric, thereby making the obtained CPU occupancy rate metric more accurate and ensuring the monitoring value. In addition, by using the probes to collect the associated data of the heap memory metric and calculating the heap memory metric through the heap memory function based on the associated data of the heap memory metric, it can accurately collect the associated data of the heap memory metric, thereby making the obtained heap memory metric more accurate and ensuring the monitoring value. Similarly, by using the probes to collect the main memory data related to the non-heap memory and calculating the non-heap memory metric through the non-heap memory optimization function according to the main memory data, the main memory data related to the non-heap memory obtained is accurate and effective, ensuring the monitoring value while improving the accuracy of the non-heap memory metric. Finally, the CPU occupancy rate metric, the heap memory metric, and the non-heap memory metric are stored through Skywalking. The more accurate CPU occupancy rate metric, heap memory metric, and non-heap memory metric provide more powerful data support for metric monitoring in the operation and maintenance process. Description of the Drawings

[0038] In order to more clearly illustrate the technical solutions in this application or related technologies, the following will briefly introduce the drawings required for use in the embodiments or related technology descriptions. Obviously, the drawings in the following description are only the embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0039] Figure 1 It is a flowchart of the method for collecting metrics based on Skywalking in the embodiments of this application;

[0040] Figure 2 It is a schematic diagram of the CPU occupancy situation in the embodiments of this application;

[0041] Figure 3 It is a schematic diagram of the JVM memory pool in the embodiments of this application;

[0042] Figure 4Schematic diagram of the index collection device based on Skywalking according to an embodiment of the present application;

[0043] Figure 5 Schematic diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0044] To make the objectives, technical solutions and advantages of the present application clearer and more understandable, the following further describes the present application in detail with reference to specific embodiments and the accompanying drawings.

[0045] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should have the ordinary meanings understood by those of ordinary skill in the field to which the present application belongs. The "first", "second" and similar terms used in the embodiments of the present application do not indicate any order, quantity or importance, but are only used to distinguish different components. The terms such as "including" or "comprising" mean that the elements or objects appearing before this term cover the elements or objects listed after this term and their equivalents, without excluding other elements or objects. The terms such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms such as "upper", "lower", "left" and "right" are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0046] In the related art, generally, the total time difference between two samplings is obtained , and then the time difference of the CPU occupancy rate at the two samplings is obtained , and the CPU occupancy rate index is calculated through . However, the data collected during the sampling process by this method are all 0, and the CPU occupancy rate index cannot be accurately obtained. In addition, for the collection of the heap memory and non-heap memory indexes, the collected values of the non-heap memory indexes are all -1, which has no monitoring value, and the collected heap memory indexes have a large gap with the actual settings. Therefore, the inaccurate CPU occupancy rate indexes, heap memory indexes and non-heap memory indexes will cause certain inconveniences to operation and maintenance analysis and problem location.

[0047] An embodiment of the present application provides a method and related devices for collecting metrics based on Skywalking. The method uses pre-deployed Skywalking probes to collect first-time CPU collection data and second-time CPU collection data related to the CPU occupancy rate metric, heap memory metric association data, and main memory data related to non-heap memory. Then, based on the first-time CPU collection data and the second-time CPU collection data, the CPU occupancy rate metric is calculated using a CPU occupancy rate function. The heap memory metric is calculated using a heap memory function based on the heap memory metric association data, and the non-heap memory metric is calculated using a non-heap memory optimization function based on the main memory data. The CPU occupancy rate metric, heap memory metric, and non-heap memory metric are stored through Skywalking. This makes the obtained CPU occupancy rate metric, heap memory metric, and non-heap memory metric more accurate and effective, providing more powerful data support for metric monitoring during the operation and maintenance process.

[0048] As Figure 1 shown, the method includes:

[0049] Step 101, collect first-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice at the first time through a first total CPU time slice function based on the first-time CPU collection data.

[0050] Specifically, when implemented, the pre-deployed Skywalking (application performance monitoring system) probe uses the oshi-core (information system acquisition) framework to collect first-time CPU collection data related to the CPU occupancy rate metric. The oshi-core framework does not require the installation of any additional native libraries and can retrieve information across platforms or systems, such as the operating system version, processes, memory and CPU usage, disks and partitions, devices, sensors, etc.

[0051] The total CPU time slice at the first time is calculated through a first total CPU time slice function based on the first-time CPU collection data. Here, the time slice is the time allocated by the CPU to each program, and the first-time CPU collection data is corrected in the form of a time slice. The first time is the time when the CPU collection data related to the CPU occupancy rate metric is collected for the first time.

[0052] Step 102, collect second-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice at the second time through a second total CPU time slice function based on the second-time CPU collection data.

[0053] In specific implementation, the pre-deployed Skywalking probe uses the oshi-core (information system acquisition) framework to collect second-time CPU acquisition data related to the CPU occupancy rate indicator. The oshi-core framework does not require the installation of any additional native libraries and can retrieve information across platforms or systems, such as the operating system version, processes, memory and CPU usage, disks and partitions, devices, sensors, etc. Therefore, the oshi-core framework can be compatible with the Windows operating system and the Linux operating system to obtain the first-time CPU acquisition data and the second-time acquisition data.

[0054] The total CPU time slice at the second time is calculated based on the second-time CPU acquisition data through the second total CPU time slice function. Here, the time slice is the time allocated by the CPU to each program, and the second-time CPU acquisition data is corrected in the form of a time slice. The second time is the time when the CPU acquisition data related to the CPU occupancy rate indicator is acquired for the second time.

[0055] Step 103: Calculate the CPU occupancy rate indicator by calculating the total CPU time slice at the first time and the total CPU time slice at the second time through the CPU occupancy rate function.

[0056] In specific implementation, using the valid total CPU time slice at the first time and the total CPU time slice at the second time for calculation through the CPU occupancy rate function can obtain an accurate CPU occupancy rate indicator, which provides more powerful data support for indicator monitoring in the operation and maintenance process.

[0057] Step 104: Collect data related to the heap memory indicator through the pre-deployed Skywalking probe, and calculate the heap memory indicator based on the data related to the heap memory indicator through the heap memory function.

[0058] In specific implementation, accessing the underlying jvm (Java Virtual Machine) memory pool data through the pre-deployed Skywalking probe can accurately obtain the data related to the heap memory indicator. Based on the valid data related to the heap memory indicator, a more accurate heap memory indicator can be calculated through the heap memory function, which provides more powerful data support for indicator monitoring in the operation and maintenance process.

[0059] Step 105: Collect main memory data related to the non-heap memory through the pre-deployed Skywalking probe, and calculate the non-heap memory indicator based on the main memory data through the non-heap memory optimization function.

[0060] In specific implementation, the storage information of the server is obtained through the pre-deployed Skywalking probe, and then the capacity of the effective main memory (i.e., the main memory data) is obtained. According to the capacity of the effective main memory, a more accurate non-heap memory metric is calculated through the non-heap memory optimization function, which can provide more powerful data support for metric monitoring in the operation and maintenance process.

[0061] Among them, the processes of collecting the first-time CPU collection data related to the CPU occupancy rate metric, the second-time CPU collection data related to the CPU occupancy rate metric, the heap memory metric association data, and the main memory data related to the non-heap memory through the pre-deployed Skywalking probe in steps 101 to 105 can be carried out simultaneously.

[0062] Step 106, taking the CPU occupancy rate metric, the heap memory metric, and the non-heap memory metric as the final collection metrics, and storing the final collection metrics through the Skywalking.

[0063] In specific implementation, the more accurate CPU occupancy rate metric, heap memory metric, and non-heap memory metric obtained through Skywalking are stored, which can provide more powerful data support for metric monitoring in the operation and maintenance process.

[0064] Through the above solution, the pre-deployed Skywalking probe uses the oshi-core framework to collect the first-time CPU collection data and the second-time CPU collection data related to the CPU occupancy rate metric. According to the first-time CPU collection data, the total CPU time slice of the first time is calculated through the first total CPU time slice function. According to the second-time CPU collection data, the total CPU time slice of the second time is calculated through the second total CPU time slice function. The first-time CPU collection data and the second-time CPU collection data are corrected in the form of time slices, and then the total CPU time slice of the first time and the total CPU time slice of the second time can obtain an accurate CPU occupancy rate metric through the CPU occupancy rate function, ensuring the monitoring value and providing more powerful data support for metric monitoring in the operation and maintenance process.

[0065] By accessing the underlying jvm memory pool data through the pre-deployed Skywalking probe, the heap memory metric association data can be accurately obtained. Based on the effective heap memory metric association data, a more accurate heap memory metric is calculated through the heap memory function, which can provide more powerful data support for metric monitoring in the operation and maintenance process.

[0066] Obtain the storage information of the server through the pre-deployed Skywalking probes, so as to make the obtained main memory data related to non-heap memory accurate and effective. Calculate more accurate non-heap memory metrics through the non-heap memory optimization function based on the effective main memory data, ensuring the monitoring value while improving the accuracy of non-heap memory metrics, providing more powerful data support for metric monitoring in the operation and maintenance process. Finally, store the CPU occupancy rate metrics, heap memory metrics, and non-heap memory metrics through Skywalking. The more accurate CPU occupancy rate metrics, heap memory metrics, and non-heap memory metrics can provide more powerful data support for metric monitoring in the operation and maintenance process.

[0067] In some embodiments, the first-time CPU collection data includes:

[0068] The number of CPU time slices occupied by the user space at the first time , the number of CPU time slices occupied by the kernel space at the first time , the number of CPU time slices occupied by the processes with changed priorities in the user process space at the first time , the number of idle CPU time slices at the first time , the number of CPU time slices occupied by waiting for input / output at the first time , the number of CPU time slices occupied by hard interrupts at the first time and the number of time slices occupied by soft interrupts at the first time ;

[0069] The specific first total CPU time slice function is:

[0070] .

[0071] In specific implementation, as Figure 2 shown, view the CPU occupancy of a certain process in the operating system (Linux) through the top command (performance analysis tool), where the parameters include:

[0072] The number of CPU time slices occupied by the user space , the number of CPU time slices occupied by the kernel space , the number of CPU time slices occupied by the processes with changed priorities in the user process space , the number of idle CPU time slices , the number of CPU time slices occupied by waiting for input / output , the number of CPU time slices occupied by hard interrupts , the number of CPU time slices occupied by soft interrupts and the total number of CPU time slices .

[0073] The oshi-core framework is compatible with the Windows operating system and operating systems. By using the top command to view the CPU occupancy of a certain process at the first time, the number of CPU time slices occupied by the user space at the first time can be obtained, and then the number of CPU time slices occupied by the kernel space at the first time, the number of CPU time slices occupied by the processes with changed priorities in the user process space at the first time, the number of idle CPU time slices at the first time, the number of CPU time slices occupied by waiting for input / output at the first time, the number of CPU time slices occupied by hard interrupts at the first time, and the number of time slices occupied by soft interrupts at the first time can be obtained. and the number of CPU time slices occupied by the kernel space at the first time 、the number of CPU time slices occupied by the processes with changed priorities in the user process space at the first time 、the number of idle CPU time slices at the first time 、the number of CPU time slices occupied by waiting for input / output at the first time 、the number of CPU time slices occupied by hard interrupts at the first time and the number of time slices occupied by soft interrupts at the first time All the data in are corrected for the CPU data collected at the first time in the form of time slices through the first total CPU time slice function.

[0074] In some embodiments, the second-time CPU collected data includes:

[0075] the number of CPU time slices occupied by the user space at the second time 、the number of CPU time slices occupied by the kernel space at the second time 、the number of CPU time slices occupied by the processes with changed priorities in the user process space at the second time 、the number of idle CPU time slices at the second time 、the number of CPU time slices occupied by waiting for input / output at the second time 、the number of CPU time slices occupied by hard interrupts at the second time and the number of time slices occupied by soft interrupts at the second time ;

[0076] The second total CPU time slice function is specifically:

[0077] .

[0078] Specifically, as shown in Figure 2 , by using the top command (performance analysis tool) to view the CPU occupancy of a certain process in the Linux operating system, the parameters include:

[0079] the number of CPU time slices occupied by the user space 、the number of CPU time slices occupied by the kernel space 、the number of CPU time slices occupied by the processes with changed priorities in the user process space 、the number of idle CPU time slices , the number of CPU time slices occupied by waiting for input / output , the number of CPU time slices occupied by hard interrupts , the number of CPU time slices occupied by soft interrupts and the total CPU time slices .

[0080] The oshi-core framework can be compatible with the Windows operating system and the operating system. Then, use the top command to view the CPU occupancy of a certain process at the second time, and then the number of CPU time slices occupied by the user space at the second time can be obtained. , the number of CPU time slices occupied by the kernel space at the second time , the number of CPU time slices occupied by the processes with changed priorities in the user process space at the second time , the number of idle CPU time slices at the second time , the number of CPU time slices occupied by waiting for input / output at the second time , the number of CPU time slices occupied by hard interrupts at the second time and the number of time slices occupied by soft interrupts at the second time All the data in, the collected data of the CPU at the second time is corrected in the form of time slices through the second total CPU time slice function.

[0081] In some embodiments, the CPU occupancy rate function is specifically:

[0082] .

[0083] In specific implementation, by calculating the total CPU time slices at the accurate and effective first time and the total CPU time slices at the second time through the CPU occupancy rate function, an accurate CPU occupancy rate index can be obtained, which provides more powerful data support for index monitoring in the operation and maintenance process.

[0084] In some embodiments, the heap memory metric associated data includes Eden area data , survivor area data and old generation area data , where the heap memory includes: Eden area, survivor area and old generation area;

[0085] The heap memory function is specifically:

[0086] .

[0087] In specific implementation, such as Figure 3As shown, the JVM memory pool (Java Virtual Machine) includes heap memory and non-heap memory. The heap memory includes the Eden area, the survivor area, and the old generation area. By accessing the underlying JVM memory pool through the pre-deployed Skywalking probe, the data of the Eden area can be accurately obtained. and the data of the survivor area and the data of the old generation area . Based on the valid data of the Eden area , the data of the survivor area and the data of the old generation area , more accurate heap memory metrics can be calculated through heap memory functions, providing more powerful data support for metric monitoring during operation and maintenance.

[0088] In some embodiments, the non-heap memory optimization function is specifically:

[0089] .

[0090] During specific implementation, as Figure 3 shown, the JVM (Java Virtual Machine) memory pool includes heap memory and non-heap memory. The non-heap memory includes the permanent generation area and the metaspace area. In the case where the non-heap memory is not set, the storage information of the server can be obtained through the pre-deployed Skywalking probe, and then the valid main memory data can be obtained. Based on the valid main memory data, more accurate non-heap memory metrics can be obtained by correcting through the non-heap memory optimization function, providing more powerful data support for metric monitoring during operation and maintenance.

[0091] In some embodiments, the time interval between the first time and the second time is 1 second.

[0092] During specific implementation, setting the interval between the time of the first collection of CPU collection data related to the CPU occupancy rate index and the time of the second collection of CPU collection data related to the CPU occupancy rate index to 1s can make the CPU occupancy rate index more accurate, thereby providing effective data support for metric monitoring during the operation and maintenance process.

[0093] It should be noted that the method of the embodiment of the present application can be executed by a single device, such as a computer or a server, etc. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In this distributed scenario, one of these multiple devices can only execute one or more steps of the method of the embodiment of the present application, and these multiple devices will interact with each other to complete the described method.

[0094] It should be noted that some embodiments of the present application are described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the above embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0095] Based on the same inventive concept, corresponding to any of the above-described method embodiments, the present application further provides a Skywalking-based metric collection device.

[0096] Referring to Figure 4 , the Skywalking-based metric collection device includes:

[0097] A first total CPU time slice processing module 401, configured to collect first-time CPU collection data and second-time CPU collection data related to the CPU occupancy rate metric through a pre-deployed Skywalking probe, and calculate the total CPU time slice of the first time through a first total CPU time slice function according to the first-time CPU collection data;

[0098] A second total CPU time slice processing module 402, configured to calculate the total CPU time slice of the second time through a second total CPU time slice function according to the second-time CPU collection data;

[0099] A CPU occupancy rate metric acquisition module 403, configured to calculate the CPU occupancy rate metric by passing the total CPU time slice of the first time and the total CPU time slice of the second time through a CPU occupancy rate function;

[0100] A heap memory metric acquisition module 404, configured to collect heap memory metric correlation data through a pre-deployed Skywalking probe, and calculate the heap memory metric based on the heap memory metric correlation data through a heap memory function;

[0101] A non-heap memory metric acquisition module 405, configured to collect main memory data related to non-heap memory through a pre-deployed Skywalking probe, and calculate the non-heap memory metric according to the main memory data through a non-heap memory optimization function;

[0102] A metric storage module 406, configured to use the CPU occupancy rate metric, the heap memory metric, and the non-heap memory metric as the final collected metrics, and store the final collected metrics through the Skywalking.

[0103] In some embodiments, the CPU data collected at the first time includes:

[0104] The number of CPU time slices occupied by the user space at the first time , the number of CPU time slices occupied by the kernel space at the first time , the number of CPU time slices occupied by the processes whose priorities have been changed in the user process space at the first time , the number of idle CPU time slices at the first time , the number of CPU time slices occupied by waiting for input / output at the first time , the number of CPU time slices occupied by hard interrupts at the first time and the number of time slices occupied by soft interrupts at the first time ;

[0105] The specific function of the total CPU time slices at the first time is:

[0106] .

[0107] In some embodiments, the CPU data collected at the second time includes:

[0108] The number of CPU time slices occupied by the user space at the second time , the number of CPU time slices occupied by the kernel space at the second time , the number of CPU time slices occupied by the processes whose priorities have been changed in the user process space at the second time , the number of idle CPU time slices at the second time , the number of CPU time slices occupied by waiting for input / output at the second time , the number of CPU time slices occupied by hard interrupts at the second time and the number of time slices occupied by soft interrupts at the second time ;

[0109] The specific function of the total CPU time slices at the second time is:

[0110] .

[0111] In some embodiments, the specific function of the CPU occupancy rate is:

[0112] .

[0113] In some embodiments, the data associated with the heap memory metrics includes Eden area data , survivor area data and old generation area data , where the heap memory includes: Eden area, survivor area and old generation area;

[0114] The heap memory function is specifically as follows:

[0115] 。

[0116] In some embodiments, the non-heap memory optimization function is specifically as follows:

[0117] 。

[0118] In some embodiments, the time interval between the first time and the second time is 1 second.

[0119] For convenience of description, when describing the above device, it is divided into various modules according to functions for separate description. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0120] The device in the above embodiment is used to implement the corresponding Skywalking-based metric collection method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.

[0121] Based on the same inventive concept, corresponding to the method in any of the above embodiments, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, it implements the Skywalking-based metric collection method described in any of the above embodiments.

[0122] Figure 5 FIG. shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 501, a memory 502, an input / output interface 503, a communication interface 504, and a bus 505. Among them, the processor 501, the memory 502, the input / output interface 503, and the communication interface 504 are communicatively connected to each other inside the device through the bus 505.

[0123] The processor 501 may be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0124] The memory 502 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 502 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 502 and are called and executed by the processor 501.

[0125] The input / output interface 503 is used to connect to the input / output module to achieve information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Among them, the input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.

[0126] The communication interface 504 is used to connect to a communication module (not shown in the figure) to achieve communication and interaction between this device and other devices. Among them, the communication module can achieve communication through wired means (such as USB, network cable, etc.) or can achieve communication through wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0127] The bus 505 includes a path for transmitting information between various components of the device (such as the processor 501, the memory 502, the input / output interface 503, and the communication interface 504).

[0128] It should be noted that although the above device only shows the processor 501, the memory 502, the input / output interface 503, the communication interface 504, and the bus 505, in the specific implementation process, this device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiments of this specification and does not have to include all the components shown in the figure.

[0129] The electronic device in the above embodiment is used to implement the corresponding Skywalking-based metric collection method in any of the foregoing embodiments and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0130] Based on the same inventive concept, corresponding to the method in any of the above embodiments, the present application also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the Skywalking-based metric collection method as described in any of the foregoing embodiments.

[0131] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0132] The computer instructions stored in the storage medium of the above embodiment are used to cause the computer to execute the Skywalking-based metric collection method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0133] Those of ordinary skill in the art should understand that: the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of brevity.

[0134] In addition, for simplicity of explanation and discussion, and to avoid making the embodiments of the present application difficult to understand, the known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. In addition, the device may be shown in block diagram form to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application will be implemented (i.e., these details should be fully within the understanding of those skilled in the art). In the case where specific details (such as circuits) are set forth to describe the exemplary embodiments of the present application, it will be apparent to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with variations of these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0135] Although the present application has been described in connection with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0136] Embodiments of the present application are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Accordingly, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the embodiments of the present application shall be included within the protection scope of the present application.

Claims

1. A method for collecting metrics based on Skywalking, characterized in that Including: Collecting first-time CPU acquisition data related to the CPU occupancy rate indicator through a pre-deployed Skywalking probe, and calculating the total CPU time slice at the first time through a first total CPU time slice function according to the first-time CPU acquisition data; Collecting second-time CPU acquisition data related to the CPU occupancy rate indicator through a pre-deployed Skywalking probe, and calculating the total CPU time slice at the second time through a second total CPU time slice function according to the second-time CPU acquisition data. Among them, the CPU acquisition data related to the CPU occupancy rate indicator includes: the number of CPU time slices occupied by the user space, the number of CPU time slices occupied by the kernel space, the number of CPU time slices occupied by processes with changed priorities within the user process space, the number of idle CPU time slices, the number of CPU time slices occupied by waiting for input / output, the number of CPU time slices occupied by hard interrupts, and the number of time slices occupied by soft interrupts; Calculating the CPU occupancy rate indicator by passing the total CPU time slice at the first time and the total CPU time slice at the second time through a CPU occupancy rate function; Collect the associated data of the heap memory metrics through the pre-deployed Skywalking probes, and calculate the heap memory metrics through the heap memory function based on the associated data of the heap memory metrics, where the associated data of the heap memory metrics includes Eden area data , survivor area data and old generation area data , where the heap memory includes: Eden area, survivor area and old generation area; The heap memory function is specifically: ; Collecting main memory data related to non-heap memory through a pre-deployed Skywalking probe, and calculating a non-heap memory indicator through a non-heap memory optimization function according to the main memory data. Among them, the non-heap memory optimization function is specifically that the non-heap memory indicator is equal to the main memory data multiplied by 1 / 4; Taking the CPU occupancy rate indicator, the heap memory indicator, and the non-heap memory indicator as the final acquisition indicators, and storing the final acquisition indicators through the Skywalking; 2. The method according to claim 1, wherein The first-time CPU acquisition data includes: The number of CPU time slices occupied by the user space at the first time , the number of CPU time slices occupied by the kernel space at the first time , the number of CPU time slices occupied by the processes with changed priorities in the user process space at the first time , the number of idle CPU time slices at the first time , the number of CPU time slices occupied by waiting for input / output at the first time , the number of CPU time slices occupied by hard interrupts at the first time and the number of time slices occupied by soft interrupts at the first time ; The first total CPU time slice function is specifically: 。 3. The method according to claim 2, characterized in that, The second-time CPU acquisition data includes: The number of CPU time slices occupied by the user space at the second time , the number of CPU time slices occupied by the kernel space at the second time , the number of CPU time slices occupied by the processes with changed priorities in the user process space at the second time , the number of idle CPU time slices at the second time , the number of CPU time slices occupied by waiting for input / output at the second time , the number of CPU time slices occupied by hard interrupts at the second time and the number of time slices occupied by soft interrupts at the second time ; The second total CPU time slice function is specifically: 。 4. The method according to claim 3, characterized in that The CPU occupancy rate function is specifically: 。 5. The method according to claim 1, wherein The time interval between the first time and the second time is 1 second.

6. An index collection device based on Skywalking, characterized in that, Including: A first total CPU time slice processing module, configured to collect first-time CPU acquisition data related to the CPU occupancy rate indicator through a pre-deployed Skywalking probe, and calculate the total CPU time slice at the first time through a first total CPU time slice function according to the first-time CPU acquisition data; The second total CPU time slice processing module is configured to collect second-time CPU collection data related to the CPU occupancy rate index through a pre-deployed Skywalking probe, and calculate the total CPU time slice of the second time through a second total CPU time slice function according to the second-time CPU collection data. Among them, the CPU collection data related to the CPU occupancy rate index includes: the number of CPU time slices occupied by the user space, the number of CPU time slices occupied by the kernel space, the number of CPU time slices occupied by processes with changed priorities in the user process space, the number of idle CPU time slices, the number of CPU time slices occupied by waiting for input and output, the number of CPU time slices occupied by hard interrupts, and the number of time slices occupied by soft interrupts; The CPU occupancy rate index acquisition module is configured to calculate the CPU occupancy rate index by passing the total CPU time slice of the first time and the total CPU time slice of the second time through a CPU occupancy rate function; The heap memory metric acquisition module is configured to collect heap memory metric correlation data through a pre-deployed Skywalking probe, and calculate heap memory metrics through heap memory functions based on the heap memory metric correlation data, wherein the heap memory metric correlation data includes Eden area data , survivor area data and tenured generation area data , wherein the heap memory includes: Eden area, survivor area and tenured generation area; The heap memory function is specifically: ; The non-heap memory index acquisition module is configured to collect main memory data related to the non-heap memory through a pre-deployed Skywalking probe, and calculate the non-heap memory index through a non-heap memory optimization function according to the main memory data. Among them, the non-heap memory optimization function is specifically that the non-heap memory index is equal to the main memory data multiplied by 1 / 4; The index storage module is configured to use the CPU occupancy rate index, the heap memory index, and the non-heap memory index as the final collected indexes, and store the final collected indexes through the Skywalking; 7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method according to any one of claims 1 to 5; 8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Task calculation amount determination method and device and electronic equipment

    CN111427758A

  • Skywalking probe index data acquisition system and method and electronic equipment

    CN114697232A