CN113626402A - Log data acquisition method and device, electronic equipment and storage medium - Google Patents

Log data acquisition method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113626402A
CN113626402A CN202111027773.5A CN202111027773A CN113626402A CN 113626402 A CN113626402 A CN 113626402A CN 202111027773 A CN202111027773 A CN 202111027773A CN 113626402 A CN113626402 A CN 113626402A
Authority
CN
China
Prior art keywords
data
feedback data
target
determining
preset
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
CN202111027773.5A
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.)
Weimin Insurance Agency Co Ltd
Original Assignee
Weimin Insurance Agency 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 Weimin Insurance Agency Co Ltd filed Critical Weimin Insurance Agency Co Ltd
Priority to CN202111027773.5A priority Critical patent/CN113626402A/en
Publication of CN113626402A publication Critical patent/CN113626402A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application provides a method and a device for acquiring log data, electronic equipment and a storage medium, wherein the method comprises the following steps: under the condition that a command that a target terminal sends a request log data to a target container is received, acquiring script information of a front-end display page; determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page; determining the sending range of initial feedback data according to the data cursor position and the preset step length; and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page. Through the method and the device, the problems that when the log output quantity of the container terminal is large in the related art, the front-end data is refreshed too frequently, a user cannot see specific output contents clearly, and the experience is poor are solved.

Description

Log data acquisition method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for acquiring log data, an electronic device, and a storage medium.
Background
At present, when container terminal logs are managed and checked, a docker container is generally managed and debugged, detailed contents and process details of a file system in the container can be checked only by entering the container, then a query command is executed on a host, the command is that a docker client is connected with a docker container engine to simulate a shell pseudo terminal, and an http polling mechanism is used for regularly requesting a server interface to achieve the purpose of acquiring data in real time.
However, the http polling mechanism is used to regularly request the server interface to acquire data, and when the output quantity of the container terminal log is large, the front end displays "screen refreshing", that is, the data refreshing frequency is too high, so that a user cannot see specific output content clearly, and the use experience is affected.
Therefore, in the related art, when the output quantity of the container terminal log is large, the front-end data is refreshed too frequently, so that a user cannot see specific output contents, and the experience is poor.
Disclosure of Invention
The application provides a method and a device for acquiring log data, electronic equipment and a storage medium, which are used for at least solving the problems that in the related art, when the output quantity of a container terminal log is large, the refreshing of front-end data is too frequent, a user cannot see specific output contents, and the experience is poor.
According to an aspect of an embodiment of the present application, there is provided a method for acquiring log data, including: under the condition that a command that a target terminal sends a request log data to a target container is received, acquiring script information of a front-end display page, wherein the target container is used for storing log data generated under each service;
determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by the target container according to the log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of the data transmission window;
and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page.
According to another aspect of the embodiments of the present application, there is also provided an apparatus for acquiring log data, where the apparatus includes:
the system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring script information of a front-end display page under the condition that a target terminal sends a log data request instruction to a target container, and the target container is used for storing log data generated under each service;
the first determining unit is used for determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
a second determining unit, configured to determine a sending range of initial feedback data according to the data cursor position and a preset step size, where the initial feedback data is log data generated by the target container according to the request log data instruction, and a value of the preset step size is the same as the total number of window units of the data transmission window;
and the second obtaining unit is used for selecting the initial feedback data according to the sending range and obtaining target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display a page.
According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used for storing the computer program; a processor for performing the method steps in any of the above embodiments by running the computer program stored on the memory.
According to a further aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to perform the method steps of any of the above embodiments when the computer program is executed.
According to yet another aspect of an embodiment of the present application, there is also provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium; the processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method steps of any of the above embodiments.
In the embodiment of the application, a sliding window is adopted to control log data acquisition, and the script information of a front-end display page is acquired under the condition that a command of sending a request log data to a target container by a target terminal is received, wherein the target container is used for storing log data generated under each service; determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page; determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by a target container according to a log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of a data transmission window; and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page. According to the embodiment of the application, the sending range of initial feedback data (namely log data) is determined according to the data cursor position and the preset step length, then the initial feedback data is selected according to the sending range, the target feedback data is obtained, and therefore when the data needs to be displayed at the front end, the range of the displayed data is limited, flow control is achieved, even if the output rate of log data inside a container is high, a user can clearly see the current output content, and the problems that in the related technology, when the output quantity of the log at the container terminal is large, the refreshing of the front end data is too frequent, the user cannot see the specific output content, and the experience is poor are solved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a diagram of a hardware environment for an alternative log data acquisition method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an alternative log data obtaining method according to an embodiment of the present disclosure;
FIG. 3a is a schematic diagram of a data transmission window sliding according to an embodiment of the present application;
FIG. 3b is a schematic diagram of another data transmission window sliding according to an embodiment of the present application;
FIG. 4 is an overall architecture diagram according to an embodiment of the present application;
FIG. 5 is a display of a target terminal according to an embodiment of the present application;
FIG. 6 is a diagram illustrating a target terminal resolution self-adjustment according to an embodiment of the present application;
FIG. 7 is a flow chart illustrating adjusting display content during data transmission according to an embodiment of the present disclosure;
FIG. 8 is a schematic diagram of display contents after resolution adjustment of a target terminal according to an embodiment of the present application;
fig. 9 is a block diagram of an alternative apparatus for acquiring log data according to an embodiment of the present application;
fig. 10 is a block diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
When the existing server acquires terminal log data, a polling mechanism is used for requesting a server to receive the terminal log data regularly to acquire the log data, but when the output quantity of the container terminal log is large, the front end displays screen refreshing, namely the data refreshing frequency is too high, so that a user cannot see specific output content clearly. In order to solve the above problem, according to an aspect of an embodiment of the present application, a method for acquiring log data is provided. Optionally, in this embodiment, the log data obtaining method may be applied to a hardware environment as shown in fig. 1. As shown in fig. 1, the terminal 102 may include a memory 104, a processor 106, and a display 108 (optional components). The terminal 102 may be communicatively coupled to a server 112 via a network 110, the server 112 may be configured to provide services (e.g., gaming services, application services, etc.) to the terminal or to clients installed on the terminal, and a database 114 may be provided on the server 112 or separate from the server 112 to provide data storage services to the server 112. Additionally, a processing engine 116 may be run in the server 112, and the processing engine 116 may be used to perform the steps performed by the server 112.
Alternatively, the terminal 102 may be, but is not limited to, a terminal capable of calculating data, such as a mobile terminal (e.g., a mobile phone, a tablet Computer), a notebook Computer, a PC (Personal Computer) Computer, and the like, and the network may include, but is not limited to, a wireless network or a wired network. Wherein, this wireless network includes: bluetooth, WIFI (Wireless Fidelity), and other networks that enable Wireless communication. Such wired networks may include, but are not limited to: wide area networks, metropolitan area networks, and local area networks. The server 112 may include, but is not limited to, any hardware device capable of performing computations.
In addition, in this embodiment, the log data obtaining method may also be applied to, but not limited to, an independent processing device with a relatively high processing capability without data interaction. For example, the processing device may be, but is not limited to, a terminal device with a relatively high processing capability, that is, each operation in the log data obtaining method may be integrated into a single processing device. The above is merely an example, and this is not limited in this embodiment.
Optionally, in this embodiment, the method for acquiring log data may be executed by the server 112, the terminal 102, or both the server 112 and the terminal 102. The terminal 102 may execute the method for acquiring log data according to the embodiment of the present application, or execute the method by a client installed thereon.
Taking an operation in a server as an example, fig. 2 is a schematic flowchart of an optional log data obtaining method according to an embodiment of the present application, and as shown in fig. 2, the method may include the following steps:
step S201, when receiving a command that a target terminal sends a request log data to a target container, acquiring script information of a front-end display page, where the target container is used to store log data generated in each service.
Optionally, in this embodiment of the present application, the server may be a server disposed in a management platform, where the management platform is configured to process log data acquired from the target container. Further, when receiving an instruction of a target terminal for requesting log data in the target container, the server acquires script information of a web front-end display page connected with the management platform.
The target terminal may be a terminal device used by any user, such as a PC, a mobile phone, a tablet computer, and the like, and the target container may be a docker container in charge of scheduling management, where the docker container is an open-source application container engine and may store log data generated under each service. For example, a user starts a virtual terminal through a remote login function, the virtual terminal can help developers to seamlessly transition to a container working environment, real-time interaction with a shell command inside a target container is achieved, static output is checked, dynamic output of logs can be tracked in real time, and checking of container logs is a daily high-frequency operation and maintenance requirement.
Step S202, determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page.
Optionally, the web front end and the management platform make an agreement with a data transmission window of a fixed size, when data of the web front end is displayed in a rolling manner from screen to screen, corresponding script information is obtained, then a final position of the data displayed on a web front end page can be obtained, the final position is updated in real time and synchronized to the management platform server, and then the management platform server can find a data cursor position of the corresponding data transmission window based on the latest final position of the data, which can be specifically referred to the schematic diagram shown in fig. 3 a.
As can be seen from fig. 3a, the data cursor position is used to indicate a corresponding position of a last window unit of a data transmission window corresponding to the current web front-end display page, in fig. 3a, the data displayed on the current web front-end display page is data corresponding to the data transmission windows 2, 3, and 4, the corresponding position of the last window unit of the data transmission window is a position corresponding to the window 4, and the position of the window 4 is the current data cursor position.
Step S203, determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by the target container according to the log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of the data transmission window.
Optionally, in the embodiment of the present application, a preset step size needs to be set, where the preset step size is actually the window size of the data transmission window, as can be seen from fig. 3a, the preset step size may be set to 3 units, that is, three window units, i.e., window 2, window 3, and window 4 in fig. 3a are corresponding to the preset step size.
When the data in the web front-end display page is displayed in a rolling mode screen by screen, the data cursor position is updated in real time and is synchronized to the server, the server sends new data to the web front-end for display according to the latest data cursor position, and therefore the simplified sliding window function is achieved. As the position of the data cursor changes from fig. 3a to fig. 3b, the latest data displayed in the front end of the web is the data corresponding to window 3, window 4, and window 5. Therefore, according to the data cursor position and the preset step length, the sending range of the initial feedback data generated by the target container according to the log data request instruction can be determined.
And step S204, selecting the initial feedback data according to the sending range, and acquiring target feedback data, wherein the target feedback data is data which is sent to the front end and is used for page display of the front end.
Optionally, all the initial feedback data generated by the target container are selected (or intercepted) according to the obtained sending range, so that the selected target feedback data is obtained. It will be appreciated that the target feedback data must be a subset of the initial feedback data. The obtained target feedback data is data used for sending to the web front end so that the web front end can perform page display.
In fig. 3a, the initial feedback data is all the data corresponding to the window 1 to the window 10, and the target feedback data is all the data corresponding to the window 2 to the window 4; in fig. 3b, the initial feedback data is all the data corresponding to the windows 1 to 10, and the target feedback data is all the data corresponding to the windows 3 to 5.
In the embodiment of the application, a sliding window is adopted to control log data acquisition, and the script information of a front-end display page is acquired under the condition that a command of sending a request log data to a target container by a target terminal is received, wherein the target container is used for storing log data generated under each service; determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page; determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by a target container according to a log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of a data transmission window; and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page. According to the embodiment of the application, the sending range of initial feedback data (namely log data) is determined according to the data cursor position and the preset step length, then the initial feedback data is selected according to the sending range, the target feedback data is obtained, and therefore when the data needs to be displayed at the front end, the range of the displayed data is limited, flow control is achieved, even if the output rate of log data inside a container is high, a user can clearly see the current output content, and the problems that in the related technology, when the output quantity of the log at the container terminal is large, the refreshing of the front end data is too frequent, the user cannot see the specific output content, and the experience is poor are solved.
As an alternative embodiment, after obtaining the target feedback data, the method further comprises:
acquiring the stepping speed of the data vernier, wherein the stepping speed is used for representing the moving speed of the data vernier;
determining the quantity of target feedback data acquired by a target terminal within a preset time length;
and adjusting the stepping speed according to the comparison result of the number of the target feedback data and a preset threshold value.
Optionally, the embodiment of the present application may further acquire a step speed of the data cursor, where the step speed is a moving speed of the data cursor, and may also represent transmission data of the data, for example, a step speed of the data cursor is 2 data/s, which is definitely faster than a step speed of the data cursor is 1 data/s.
Then, the number of target feedback data acquired by the target terminal within a preset time duration is determined, where the preset time duration may be a short time duration, such as 5 s. And then determining a preset threshold value which is compared with the amount of the target feedback data, wherein the preset threshold value can be any set numerical value, the preset threshold value is a conventional amount of the target feedback data acquired within a preset time length, for example, the amount of data normally received by the target terminal within 5s is 10 data, and at this time, 10 is determined as the preset threshold value. And comparing the magnitude of the numerical value of the preset threshold value with the quantity of the target feedback data, and further adjusting the stepping speed according to the comparison result.
If the user of the target terminal needs to receive data quickly, the determined amount of the target feedback data is larger than the preset threshold, so that in order to obtain the amount of the target feedback data needing to be obtained within 5s, the requirement of receiving more data within a short time can be met by increasing the stepping speed.
Of course, if the user of the target terminal needs to receive data slowly, the determined amount of the target feedback data is smaller than the preset threshold, so that in order to obtain the amount of the target feedback data to be obtained within 5s, the step speed can be reduced to meet the requirement of receiving less data in a short time.
In the embodiment of the application, the mode that the back-end service actively pushes data is converted into passive pushing, the stepping speed of the data cursor is controlled according to the actual data receiving requirement of a user, the data transmission speed is further controlled, and the diversity of the transmitted data is realized.
As an alternative embodiment, after generating the target feedback data according to the transmission range, the method further comprises:
and transmitting the target feedback data to the front end in a preset transmission format, wherein the preset transmission format is used for indicating at least one transmission mode of the target feedback data, and the target feedback data is transmitted to the front end according to the preset transmission format under the condition that the preset transmission format is determined to be a continuous streaming transmission mode.
Alternatively, the prior art scheme uses an http polling mechanism to periodically request the server interface to obtain data, usually once in 1 second, which means that all the output data has a delay of at least 1 second to the web front-end presentation.
When the target feedback data is transmitted to the web front end, the target feedback data can be transmitted to the web front end in a preset transmission format, where the preset transmission format is at least one data transmission mode.
When the preset transmission format is a continuous streaming transmission mode, continuous and uninterrupted data transmission can be realized.
In the embodiment of the application, the data transmission mode adopts streaming transmission, so that the effect of continuous data transmission can be realized, and the problem of data delay in the prior art when an http polling mechanism is used for regularly requesting the server-side interface to acquire data is solved.
As an alternative embodiment, transmitting the target feedback data to the front end in the preset transmission format includes:
establishing a long connection with a front end by utilizing a full duplex communication protocol;
and transmitting the target feedback data to the front end in a long connection mode in the process of transmitting the target feedback data in a preset transmission format.
Optionally, in this embodiment of the present application, when the target feedback data is transmitted to the front end in the preset transmission format, a long connection between the target feedback data and the front end is established by using a full duplex communication protocol, and the target feedback data is transmitted to the front end in a long connection manner.
In addition, when the web front end requests to acquire the log data in the target container, the request data is transmitted by a long connection method. Specifically, as shown in fig. 4, fig. 4 is an overall architecture diagram according to an embodiment of the present application, where k8s is kubernets, which is referred to as an open source container scheduling engine, and a docker container is a target container and is responsible for scheduling management of log data, where an arrow indicates an actual data flow direction.
The data transmission part in fig. 4 includes interaction between the management platform server and k8s, and data interaction between the management platform server and the web front end, where the web front end and the management background server establish a long connection through webSocket technology, the web front end sends the input of the terminal to the server in real time, and the server forwards the data to the apiserver cluster of k8s, and then transfers the data to the target container; and simultaneously, outputting the log data in the target container in the opposite direction, and sending the log data to the web front end in real time for displaying.
Interaction between the management platform server and the k8s is realized by means of an open-source k8s client, the client can establish connection with the apiserver cluster, transmit instructions and data for upper-layer application, can realize access and management of cluster resources, and has the function of remotely connecting a container. The specific implementation details are as follows:
the method comprises the following steps that 1, a web front end initiates an http request to establish connection with a management platform server, and the http request is converted into a websocket connection after handshaking;
2. the management platform server establishes connection with the apiserver cluster through a k8s client, wherein the connection is PSOT STREAM type connection and is used for transmitting streaming data;
and 3, establishing a streaming transmission channel by the apiserver through a kubel process on the host and the docker container, and opening the whole bottom layer data transmission channel.
As an alternative embodiment, after establishing the long connection with the front end using the protocol for full duplex communication, the method further comprises:
receiving a resolution parameter of a target terminal, wherein the resolution parameter comprises the length of a display device of the target terminal;
and determining target feedback data according to the current sending turn corresponding to the resolution parameter, wherein the target feedback data is matched with the display device.
Optionally, various display devices are available on the market, the display devices generally refer to display screens, different display devices have different display resolutions, and since the resolutions and screen sizes of terminal devices used by staff in various departments during work are not uniform, in order to enable output log data to be suitable for all display devices to complete data display, in the embodiments of the present application, a server is used to receive resolution parameters of a target terminal that sends a log data request, where the resolution parameters include length parameters of the display device of the target terminal and width parameters of the display device, as shown in fig. 5, the length and width of the display device of the target terminal are shown in fig. 5.
After the web terminal is connected with the server, the server calculates target feedback data according to the received resolution parameters and the sent current turn, so that the target feedback data displayed by the web front end is matched with the display device, and the target feedback data can be displayed completely and clearly.
In the embodiment of the application, the display content of the display device of the target terminal can be adaptively adjusted according to the current resolution, so that a user can clearly see the current output content even if the output rate of the log in the container is high, and the log data transmitted from the target container can be normally displayed in any scene.
As an optional embodiment, determining the target feedback data according to the current transmission turn corresponding to the resolution parameter includes:
under the condition that the current sending turn is the first turn, obtaining a first character number which can be contained in each row of the display device according to the length of the display device and a preset coefficient, wherein the preset coefficient is a parameter for calculating the first character number;
determining the position of a first definition line changing symbol according to the first character number;
acquiring an initial line feed character contained in the initial feedback data to obtain the position of the initial line feed character;
and determining all initial feedback data before the position of the first defined line break or the position of the initial line break as target feedback data.
Optionally, when the resolution parameter of the current target terminal is sent to the server for the first time, the server obtains total characters that can be accommodated in each row of the display device, that is, a first character number maxRowChars, according to the obtained length of the display device, the width of the display device, the front end, and a fixed preset coefficient agreed by the server. The formula for obtaining the first character number is as follows: maxRowChars ═ the length of the display device × preset coefficients.
And determining the position of the first defined line break automatically inserted by the server according to the first number of characters capable of being accommodated in each line, wherein the server can judge that after a plurality of x, the line break needs to be inserted to complete the subsequent character display, and the first "/n" in fig. 5 is the first defined line break which is also the line break automatically calculated and added by the server. At the same time, it can also be seen from fig. 5 that the third row c, the last "/n", is also the line break that the server automatically calculates to add.
When the server acquires the initial feedback data, the initial line break character originally contained in the initial feedback data is selected, and the position of the initial line break character is obtained, wherein the last "/n" of the second line x, the last "/n" of a plurality of d in the fifth line and a plurality of e in the sixth line in fig. 5 are the initial line break characters of the original log data.
In order to adapt to the screen size of the existing display device, all initial feedback data before the position of the first defined line break or the position of the initial line break are displayed line by line, and target feedback data of each line are displayed in sequence.
As an optional embodiment, determining the target feedback data according to the current transmission turn corresponding to the resolution parameter includes:
starting a monitoring mode under the condition that the current sending turn is a non-first turn, wherein the monitoring mode is used for monitoring a change event of a resolution parameter;
under the condition that the resolution parameter is monitored to be changed, the changed resolution parameter is obtained;
determining a second character number according to the changed resolution parameter and the preset coefficient;
determining the position of a second line feed character according to the second character number;
and determining target feedback data by using the position of the second defined line break and the position of the initial line break.
Optionally, in a case that the turn of the currently transmitted resolution parameter received by the server is a non-first turn, as shown in fig. 6, the monitoring mode is started, and a change event of the resolution parameter is monitored. And when the resolution parameter is changed, the front end sends the changed resolution parameter to the server in real time, and the server receives the changed resolution parameter and adjusts the returned target feedback data in real time to realize the resolution self-adaptive function.
Further, according to the changed resolution parameter and the preset coefficient, determining a second character number maxRowChars, wherein the calculation formula is as follows: maxRowChars is the length of the display device after the change × a preset coefficient. And then determining the position of a second defined line break according to the second character number, and displaying all initial feedback data before the position of the second defined line break and before the position of the initial line break line by line, and sequentially displaying target feedback data of each line.
As shown in fig. 7, fig. 7 is a flowchart of adjusting display content in a data transmission process according to an embodiment of the present application, and the specific steps are as follows:
creating a line cache in a server;
reading a character;
judging whether the character is a line feed character: if so, writing the line break into the line cache, and sending all data before the line break; if not, judging whether the line cache is equal to maxRowChars (namely the maximum total character number which can be accommodated by each line) -1: if so, writing the line break into the line cache, and sending all data before the line break; if not, the current character is proved to be a common character, the character is written into a line cache, and then whether the line cache character written into the character is equal to maxRowChars-1 is judged: if so, writing the line break into the line cache, and sending all data before the line break; if not, continuing to read one character.
Fig. 8 shows contents displayed in the terminal after the browser is resized. Therefore, the display content in the terminal can be adaptively adjusted and displayed according to the current resolution, and the terminal has an automatic line-changing function.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, an optical disk) and includes several instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the methods of the embodiments of the present application.
According to another aspect of the embodiment of the present application, there is also provided an apparatus for acquiring log data, which is used for implementing the method for acquiring log data. Fig. 9 is a schematic diagram of an alternative log data obtaining apparatus according to an embodiment of the present application, and as shown in fig. 9, the apparatus may include: a first obtaining unit 901, configured to obtain script information of a front-end display page when receiving a log data request instruction sent by a target terminal to a target container, where the target container is used to store log data generated in each service; a first determining unit 902, connected to the first determining unit 901, configured to determine a data cursor position corresponding to the script information, where the data cursor position is used to indicate a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page; a second determining unit 903, connected to the first determining unit 902, configured to determine a sending range of initial feedback data according to the data cursor position and a preset step size, where the initial feedback data is log data generated by the target container according to the log data request instruction, and a value of the preset step size is the same as the total number of window units of the data transmission window; and a second obtaining unit 904, connected to the second determining unit 903, configured to select the initial feedback data according to the sending range, and obtain target feedback data, where the target feedback data is data sent to the front end and used for page display at the front end.
It should be noted that the first obtaining unit 901 in this embodiment may be configured to execute the step S201, the first determining unit 902 in this embodiment may be configured to execute the step S202, the second determining unit 903 in this embodiment may be configured to execute the step S203, and the second obtaining unit 904 in this embodiment may be configured to execute the step S204.
Through the module, the problems that when the log output quantity of the container terminal is large, the front-end data is refreshed too frequently, a user cannot see specific output contents, and the experience is poor in the related art are solved.
As an alternative embodiment, the apparatus further comprises: the third acquisition unit is used for acquiring the stepping speed of the data cursor after the target feedback data is acquired, wherein the stepping speed is used for representing the moving speed of the data cursor; the third determining unit is used for determining the quantity of the target feedback data acquired by the target terminal within the preset time length; and the adjusting unit is used for adjusting the stepping speed according to the comparison result of the number of the target feedback data and the preset threshold value.
As an alternative embodiment, the apparatus further comprises: and the transmission unit is used for transmitting the target feedback data to the front end in a preset transmission format after generating the target feedback data according to the sending range, wherein the preset transmission format is used for indicating at least one transmission mode of the target feedback data.
As an alternative embodiment, the transmission unit comprises: and the first transmission module is used for transmitting the target feedback data to the front end according to the preset transmission format under the condition that the preset transmission format is determined to be a continuous streaming transmission mode.
As an alternative embodiment, the transmission unit comprises: the connection module is used for establishing long connection with the front end by utilizing a full duplex communication protocol; and the second transmission module is used for transmitting the target feedback data to the front end in a long connection mode in the process of transmitting the target feedback data in the preset transmission format.
As an alternative embodiment, the apparatus further comprises: a receiving unit, configured to receive a resolution parameter of a target terminal after establishing a long connection with a front end using a protocol of full duplex communication, wherein the resolution parameter includes a length of a display device of the target terminal; and the fourth determining unit is used for determining target feedback data according to the current sending turn corresponding to the resolution parameter, wherein the target feedback data is matched with the display device.
As an alternative embodiment, the fourth determination unit includes: the first obtaining module is used for obtaining a first number of characters which can be contained in each row of the display device according to the length of the display device and a preset coefficient under the condition that the current sending turn is the first turn, wherein the preset coefficient is a parameter for calculating the first number of characters; the first determining module is used for determining the position of the first definition line changing character according to the first character number; a second obtaining module, configured to obtain an initial line break character included in the initial feedback data, and obtain a position of the initial line break character; and the second determining module is used for determining all initial feedback data before the position of the first defined line break character or the position of the initial line break character as target feedback data.
As an alternative embodiment, the fourth determination unit includes: the system comprises a starting module, a monitoring module and a processing module, wherein the starting module is used for starting a monitoring mode under the condition that the current sending turn is a non-first turn, and the monitoring mode is used for monitoring a change event of a resolution parameter; the acquisition module is used for acquiring the changed resolution parameters under the condition that the resolution parameters are monitored to be changed; the third determining module is used for determining a second character number according to the changed resolution parameter and the preset coefficient; the fourth determining module is used for determining the position of the second line feed character according to the second character number; and the fifth determining module is used for determining the target feedback data by utilizing the position of the second defined line break and the position of the initial line break.
It should be noted here that the modules described above are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above embodiments. It should be noted that the modules described above as a part of the apparatus may be operated in a hardware environment as shown in fig. 1, and may be implemented by software, or may be implemented by hardware, where the hardware environment includes a network environment.
According to another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above method for acquiring log data, where the electronic device may be a server, a terminal, or a combination thereof.
Fig. 10 is a block diagram of an alternative electronic device according to an embodiment of the present application, and as shown in fig. 10, the electronic device includes a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004, where the processor 1001, the communication interface 1002, and the memory 1003 complete communication with each other through the communication bus 1004, where,
a memory 1003 for storing a computer program;
the processor 1001 is configured to implement the following steps when executing the computer program stored in the memory 1003:
under the condition that a command that a target terminal sends a request log data to a target container is received, acquiring script information of a front-end display page, wherein the target container is used for storing log data generated under each service;
determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by a target container according to a log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of a data transmission window;
and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page.
Alternatively, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 10, but this is not intended to represent only one bus or type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The memory may include RAM, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
As an example, as shown in fig. 10, the memory 1003 may include, but is not limited to, a first acquiring unit 901, a first determining unit 902, a second determining unit 903, and a second acquiring unit 904 in the acquiring apparatus of the log data. In addition, the device may further include, but is not limited to, other module units in the above log data obtaining apparatus, which is not described in detail in this example.
The processor may be a general-purpose processor, and may include but is not limited to: a CPU (Central Processing Unit), an NP (Network Processor), and the like; but also a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
In addition, the electronic device further includes: and the display is used for displaying the acquisition result of the log data.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment is not described herein again.
It can be understood by those skilled in the art that the structure shown in fig. 10 is only an illustration, and the device implementing the log data obtaining method may be a terminal device, and the terminal device may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 10 is a diagram illustrating a structure of the electronic device. For example, the terminal device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 10, or have a different configuration than shown in FIG. 10.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disk, ROM, RAM, magnetic or optical disk, and the like.
According to still another aspect of an embodiment of the present application, there is also provided a storage medium. Alternatively, in this embodiment, the storage medium may be a program code for executing the log data acquisition method.
Optionally, in this embodiment, the storage medium may be located on at least one of a plurality of network devices in a network shown in the above embodiment.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
under the condition that a command that a target terminal sends a request log data to a target container is received, acquiring script information of a front-end display page, wherein the target container is used for storing log data generated under each service;
determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by a target container according to a log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of a data transmission window;
and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page.
Optionally, the specific example in this embodiment may refer to the example described in the above embodiment, which is not described again in this embodiment.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a U disk, a ROM, a RAM, a removable hard disk, a magnetic disk, or an optical disk.
According to yet another aspect of an embodiment of the present application, there is also provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium; the processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the steps of the log data acquisition method in any one of the embodiments.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions used to enable one or more computer devices (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the log data obtaining method of the embodiments of the present application.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is merely a division of a logic function, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, and may also be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (11)

1. A method for acquiring log data is characterized by comprising the following steps:
under the condition that a command that a target terminal sends a request log data to a target container is received, acquiring script information of a front-end display page, wherein the target container is used for storing log data generated under each service;
determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
determining a sending range of initial feedback data according to the data cursor position and a preset step length, wherein the initial feedback data is log data generated by the target container according to the log data request instruction, and the numerical value of the preset step length is the same as the total number of window units of the data transmission window;
and selecting the initial feedback data according to the sending range to obtain target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display the page.
2. The method of claim 1, wherein after obtaining target feedback data, the method further comprises:
acquiring the stepping speed of the data cursor, wherein the stepping speed is used for representing the moving speed of the data cursor;
determining the quantity of the target feedback data acquired by the target terminal within a preset time length;
and adjusting the stepping speed according to the comparison result of the number of the target feedback data and a preset threshold value.
3. The method of claim 1, wherein after the generating target feedback data according to the transmission range, the method further comprises:
and transmitting the target feedback data to the front end in a preset transmission format, wherein the preset transmission format is used for indicating at least one transmission mode of the target feedback data.
4. The method of claim 3, wherein transmitting the target feedback data to the front end in a predetermined transmission format comprises:
and transmitting the target feedback data to the front end according to the preset transmission format under the condition that the preset transmission format is determined to be a continuous streaming transmission mode.
5. The method of claim 3, wherein transmitting the target feedback data to the front end in a predetermined transmission format comprises:
establishing a long connection with the front end using a protocol for full duplex communication;
and transmitting the target feedback data to the front end in the long connection mode in the process of transmitting the target feedback data in a preset transmission format.
6. The method of claim 5, wherein after the protocol utilizing full duplex communication establishes the long connection with the front end, the method further comprises:
receiving a resolution parameter of the target terminal, wherein the resolution parameter comprises a length of a display device of the target terminal;
and determining the target feedback data according to the current sending turn corresponding to the resolution parameter, wherein the target feedback data is adapted to the display device.
7. The method of claim 6, wherein the determining the target feedback data according to the current transmission turn corresponding to the resolution parameter comprises:
under the condition that the current sending turn is the first turn, obtaining a first character number which can be contained in each row of the display device according to the length of the display device and a preset coefficient, wherein the preset coefficient is a parameter for calculating the first character number;
determining the position of a first definition line changing symbol according to the first character number;
acquiring an initial line feed character contained in the initial feedback data to obtain the position of the initial line feed character;
and determining all the initial feedback data at the position of the first defined line break or before the position of the initial line break as the target feedback data.
8. The method of claim 7, wherein the determining the target feedback data according to the current transmission turn corresponding to the resolution parameter comprises:
starting a monitoring mode under the condition that the current sending turn is a non-first turn, wherein the monitoring mode is used for monitoring a change event of the resolution parameter;
under the condition that the resolution parameter is monitored to be changed, the changed resolution parameter is obtained;
determining a second character number according to the changed resolution parameter and the preset coefficient;
determining the position of a second line feed character according to the second character number;
and determining the target feedback data by using the position of the second defined line break and the position of the initial line break.
9. An apparatus for acquiring log data, the apparatus comprising:
the system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring script information of a front-end display page under the condition that a target terminal sends a log data request instruction to a target container, and the target container is used for storing log data generated under each service;
the first determining unit is used for determining a data cursor position corresponding to the script information, wherein the data cursor position is used for indicating a corresponding position of a last window unit of a data transmission window corresponding to a current front-end display page;
a second determining unit, configured to determine a sending range of initial feedback data according to the data cursor position and a preset step size, where the initial feedback data is log data generated by the target container according to the request log data instruction, and a value of the preset step size is the same as the total number of window units of the data transmission window;
and the second obtaining unit is used for selecting the initial feedback data according to the sending range and obtaining target feedback data, wherein the target feedback data is data which is sent to the front end and used for the front end to display a page.
10. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein said processor, said communication interface and said memory communicate with each other via said communication bus,
the memory for storing a computer program;
the processor for performing the method steps of any one of claims 1 to 8 by running the computer program stored on the memory.
11. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method steps of any one of claims 1 to 8 when executed.
CN202111027773.5A 2021-09-02 2021-09-02 Log data acquisition method and device, electronic equipment and storage medium Pending CN113626402A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111027773.5A CN113626402A (en) 2021-09-02 2021-09-02 Log data acquisition method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111027773.5A CN113626402A (en) 2021-09-02 2021-09-02 Log data acquisition method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113626402A true CN113626402A (en) 2021-11-09

Family

ID=78389028

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111027773.5A Pending CN113626402A (en) 2021-09-02 2021-09-02 Log data acquisition method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113626402A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115645905A (en) * 2022-10-21 2023-01-31 圣名科技(广州)有限责任公司 Method and device for cursor display, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115645905A (en) * 2022-10-21 2023-01-31 圣名科技(广州)有限责任公司 Method and device for cursor display, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106657197B (en) File uploading method and device
US20150227496A1 (en) Method and system for microblog resource sharing
CN109729386B (en) Video file playing starting method and system, electronic equipment and storage medium
CN111177617A (en) Web direct operation and maintenance method and device based on operation and maintenance management system and electronic equipment
US20220147697A1 (en) Adaptive content delivery
EP3241119B1 (en) Methods and apparatus for adaptive bandwidth-based communication management
CN107315729B (en) Data processing method, medium, device and computing equipment for chart
US10241982B2 (en) Modifying web pages based upon importance ratings and bandwidth
CN109862100B (en) Method and device for pushing information
CN108334516B (en) Information pushing method and device
CN113411404A (en) File downloading method, device, server and storage medium
US20140278766A1 (en) Methods and apparatus for providing application provisioning
US10157588B2 (en) Systems and methods for image optimization
CN109194706B (en) Network resource dial testing method and terminal
CN113626402A (en) Log data acquisition method and device, electronic equipment and storage medium
US10432490B2 (en) Monitoring single content page application transitions
CN104796929B (en) Network debugging method and device
CN111783010B (en) Webpage blank page monitoring method, device, terminal and storage medium
CN115086194B (en) Cloud application data transmission method, computing device and computer storage medium
CN115134274A (en) Network speed measuring method and device, electronic equipment and storage medium
CN114449026A (en) Method for recording online learning duration and related equipment
CN114237926A (en) Multi-platform interaction method, device, equipment, storage medium and computer program product
CN107451260A (en) A kind of network access information sharing method and system
CN110324366B (en) Data processing method, device and system
CN112269942A (en) Method, device and system for recommending object and electronic equipment

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