Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
The embodiment of the disclosure provides a monitoring method and a device capable of applying the method. The method comprises the following operations executed by a configuration server: receiving a rule creating request from a user side, wherein the rule creating request comprises alarm rule information and monitoring object information; generating a first alarm rule in a preset format according to the alarm rule information; determining a network address of an alarm server corresponding to the monitored object information; and sending the first alarm rule to the alarm server according to the network address, so that the alarm server monitors the monitored object indicated by the monitored object information according to the first alarm rule.
Performing, by the alert server: performing the following operations by the sidecar program: receiving an alarm rule from a configuration server; acquiring a fourth directory position corresponding to the alarm monitoring program; and writing the alarm rule into the fourth directory location; and executing the following operations by the monitoring program: reading an alarm rule at the fourth directory location; and monitoring the monitored object according to the alarm rule. The alarm server is internally provided with a monitoring program and a sidecar program which is mutually independent from the monitoring program.
Fig. 1 schematically illustrates an exemplary system architecture 100 to which the monitoring method may be applied, according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to the embodiment may include a User end (User)101, a configuration server (configureserver) 102, databases 103, 104, and a monitoring server 105.
The user terminal 101 may send various requests, such as a rule creation request, to the configuration server 102 by using Http request. The parameter of Http requuset includes, for example, ConfigerServerUrl (address of configuration server). The content of the request includes, for example, an alarm rule name (policyName), alarm rule information (policy), alarm rule type (policyType), and cluster information (cluster). Wherein, the alarm rule name is used for distinguishing different operations of different services. The alarm rule information includes specific alarm contrast. The alarm rule type is used to indicate the type of the alarm rule. And the cluster information is used for distinguishing different monitoring objects, such as different machine rooms.
The database 103 may be used to store network addresses of the alarm servers, monitoring object information, and corresponding relationships between the alarm servers and the monitoring objects, and may be a Mysql database, for example.
The database 104 may be used to store alarm rules, and may be, for example, an ETCD database.
The configuration server 102 is used for receiving various requests from the user terminal and performing corresponding operations. For example, the configuration server 102 may receive a rule creation request from a client, generate an alarm rule in a preset format according to the alarm rule information, Read (Read) a network address of an alarm server corresponding to the monitored object information from the database 103, and send the alarm rule to the alarm server 105 according to the network address. Configuration server 102 may also be used to Write (Write) alarm rules to database 103 and/or database 104 for archiving. When the request processing is completed, the configuration server 102 feeds back a notification of Success (Success) to the user terminal 101.
The monitoring server 105 has a monitoring program (e.g., Prometheus) and a SideCar program (e.g., SideCar) installed therein, and the monitoring program and the SideCar program are independent from each other. The cross bucket program can be used for receiving the alarm rule from the configuration server and writing the alarm rule into a directory location (Conf Path) where the alarm rule is stored by the monitoring program. The monitoring program can be used for reading the alarm rule from the directory position to monitor the monitored object. In addition, the monitoring server 105 may further include an alarm module (e.g., alert manager), which may cooperate with the monitoring program, and notify the alarm module when the monitoring program detects that the alarm rule is triggered, so that the alarm module performs an alarm.
Fig. 2 schematically shows a flow chart of a monitoring method performed by a configuration server according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes receiving a rule creation request from a user terminal in operation S210.
According to an embodiment of the present disclosure, the rule creation request may include, for example, alarm rule information and monitoring object information. The rule creation request may also include an alarm rule identification, an alarm rule type, and the like.
According to an embodiment of the present disclosure, the user terminal may send the rule creation request to the configuration server through the HTTP Requset method.
Then, in operation S220, a first alarm rule in a preset format is generated according to the alarm rule information.
According to an embodiment of the present disclosure, the preset format may include, for example, a YAML format. YAML has a profile suffix of. yml.
According to the embodiment of the disclosure, the configuration server may receive a plurality of alarm rule information, generate an alarm rule for each of the alarm rule information, and integrate any plurality of the alarm rule information to generate an alarm rule.
In operation S230, a network address of an alert server corresponding to the monitored object information is determined.
According to the embodiment of the disclosure, the network address of the alarm server, the information of the monitored object, and the corresponding relation between each alarm server and the monitored object are recorded in the database in advance. Based on this, the network address of the alarm server corresponding to the monitored object information can be queried from the database.
In operation S240, the first alarm rule is sent to the alarm server according to the network address, so that the alarm server monitors the monitored object indicated by the monitored object information according to the first alarm rule.
According to the embodiment of the disclosure, the configuration server may directly send the first alarm rule to the alarm server, or may store the first alarm rule in the database and synchronize the first alarm rule with the alarm server via the database.
Fig. 3 schematically shows a flow chart of a monitoring method performed by a configuration server according to another embodiment of the present disclosure.
As shown in fig. 3, the method includes operations S310 to S330 in addition to operations S210 to S240.
In operation S310, a first preset prefix corresponding to the first alarm rule is obtained.
According to the embodiment of the disclosure, the corresponding relation between each alarm rule and the preset prefix can be stored in a cache in advance in a key value pair mode. Based on this, operation S210 may include, for example, reading a preset prefix corresponding to the alarm rule, i.e., a first preset prefix, from the cache according to the alarm rule identifier.
In operation S320, a first directory location of the database is determined according to the first preset prefix and the first alarm rule identifier in the rule creation request.
According to the embodiment of the disclosure, the preset prefix and the alarm rule identifier can be integrated to obtain the file directory name, so as to obtain the corresponding directory location. Exemplarily, in this embodiment, the preset prefix and the alarm rule identifier are character-spliced by using an "AB" format to obtain a file directory name. Wherein, A is a preset prefix, and B is an alarm rule identifier. By integrating the preset prefix and the alarm rule identifier to obtain the file directory name, the failure of the storage rule caused by the directory location name conflict of the database can be avoided.
According to another embodiment of the present disclosure, the rule creation request may further include an alarm rule type, and in the above operation, in addition to the preset prefix and the alarm rule identifier, the alarm rule type may also be integrated into the file directory name.
According to an embodiment of the present disclosure, the database may be, for example, an ETCD database.
In operation S330, a first alert rule is stored to a first directory location.
According to embodiments of the present disclosure, the alarm rule may be written into the cache, and then the alarm rule in the cache may be written into the first directory location. It should be noted that, when a plurality of alarm rules are stored in the cache, the alarm rules may be written into the database in sequence according to the sequence of writing into the cache of the alarm rules.
Fig. 4 schematically shows a flow chart of a monitoring method performed by a configuration server according to another embodiment of the present disclosure.
As shown in fig. 4, the method includes operations S410 to S440 in addition to operations S210 to S240.
In operation S410, a rule query request is received from a user terminal.
For the sake of distinction, the alarm rule identification in the rule query request is referred to as a second alarm rule identification.
According to an embodiment of the present disclosure, the user terminal may send a rule query request to the configuration server through the HTTP Requset method.
In operation S420, it is determined whether a second alarm rule corresponding to the rule query request is stored in the cache. In the case where the second alarm rule is stored in the cache, operation S430 is performed, and in the case where the first alarm rule is not stored in the cache, operation S440 is performed.
According to the embodiment of the disclosure, whether the alarm rule corresponding to the second alarm rule identifier exists, that is, the second alarm rule, can be searched in the cache.
In operation S430, the first alarm rule is read from the cache, and the second alarm rule is sent to the user side.
In operation S440, the first alarm rule is searched in the database, and the searched first alarm rule is sent to the user side.
According to the embodiment of the disclosure, a second preset prefix corresponding to the second alarm rule identifier may be obtained. And then, similarly to the operation of determining the first target position, determining a second target position of the database according to the second preset prefix and the alarm rule identifier in the rule query request. And then searching the first alarm rule at the second target position, and sending the searched first alarm rule to the user side.
Fig. 5 schematically shows a flow chart of a monitoring method performed by a configuration server according to another embodiment of the present disclosure.
As shown in fig. 5, the method includes operations S510 to S540 in addition to operations S210 to S240.
In operation S510, a rule edit request is received from a user side.
According to an embodiment of the present disclosure, the rule edit request may include, for example, a third alarm rule identification and an editing method. Editing methods may include deletion and modification, for example.
According to an embodiment of the present disclosure, the user terminal may send a rule edit request to the configuration server through the HTTP Requset method.
In operation S520, a third preset prefix corresponding to the third alarm rule identifier is obtained.
According to the embodiment of the present disclosure, the preset prefix corresponding to the third warning rule identifier, that is, the third preset prefix, may be read from the cache.
In operation S530, a third directory location is determined according to a third preset prefix and a third alarm rule identifier.
According to the embodiment of the disclosure, the third preset prefix and the third alarm rule identifier may be integrated to obtain a file directory name, so as to obtain a corresponding directory location, that is, a third directory location.
In operation S540, the alert rule at the third directory location is edited.
According to the embodiment of the disclosure, according to the editing method in the rule editing request, the corresponding editing operation is performed on the alarm rule at the third directory location. For example, if the editing method is deleting, the corresponding editing operation will delete the alarm rule at the third directory location.
Fig. 6 schematically shows a flow chart of a monitoring alarm method performed by an alarm server according to an embodiment of the present disclosure.
As shown in fig. 6, the alarm server is installed with a monitoring program and a SideCar program (SideCar) independent of the monitoring program. The method includes operations S610 to S630 performed by the sidecar program, and operations S640 to S650 performed by the monitoring program.
In operation S610, an alarm rule is received from a configuration server.
In operation S620, a fourth directory location corresponding to the monitoring program is acquired.
According to the embodiment of the disclosure, the fourth directory location is a directory location where the alarm rule file is stored by the monitoring program.
In operation S630, the alert rule is written at a fourth directory location.
In operation S640, the alarm rule at the fourth directory location is read.
In operation S650, the monitoring object is monitored according to the alarm rule.
According to an embodiment of the present disclosure, the monitoring program may be, for example, a Prometheus monitoring program.
According to the embodiment of the disclosure, the configuration server receives a rule creation request from a user side, generates an alarm rule according to the rule configuration request, distributes the alarm rule to the corresponding monitoring server, and writes the alarm rule into the directory of the monitoring program storage configuration rule by the sidecar program installed in the monitoring server, so that the alarm rule can be created without logging in the monitoring server.
The method shown in fig. 2 to 6 will be further explained with reference to specific embodiments. Those skilled in the art will appreciate that the following example embodiments are only for the understanding of the present disclosure, and the present disclosure is not limited thereto.
Table 1 schematically shows interface information of the ConfigerServer service. When the user needs to perform operations such as creating, querying, deleting, etc. on the alarm rule, the user may request the Url address in Table 1 in a post or get manner of the Http protocol.
TABLE 1
As shown in table 1, the client application calls the interface of the ConfigerServer service to trigger the create rule operation. The interface calls the following method savealmarmpolicy (http request, http response) to send the request to the configuration server.
The configuration server obtains four parameters, namely an alarm rule name (policyName), alarm rule information (policy), an alarm rule type (policyType) and cluster information (cluster), through the http server. And then, the configuration server acquires the fixed prefix of the alarm rule from the cache and is used for splicing the directory location name of the ETCD database. And after the ETCD directory location names are spliced, calling a saveKeyValue (etcdPath, policy) method in the ETCDVutils class, and storing the created alarm rules in an ETCD database. And then, the configuration server acquires the url address of the corresponding machine for installing the SideCar from the Mysql, and synchronizes the alarm rule to the machine served by the SideCar. The process mainly uses sendPost (url, policy, 3000, 3)) method of Http protocol, wherein the first parameter url is the address of the SideCar obtained from Mysql, the second parameter policy is the content of the alarm rule, the third parameter is the set timeout time, and the fourth parameter is the retry number, i.e. the retry number set for avoiding the request failure due to network and other factors. When the SideCar receives the request, the alarm content is written to the specified directory position in an io input and output stream mode. In this embodiment, Prometheus is also deployed on the same machine on which the siedcar is deployed, and the directory location where the alarm rule is stored by Prometheus is the designated directory location. And the Prometheus can perform alarm detection according to the alarm rule information.
And the user application calls an interface of the ConfigerServer service to trigger the operation of the query rule. The configuration server receives the rule query request, then splices the directory location name of the ETCD in the same way as the rule creating operation, and queries the alarm rule content by calling ETCDVutils.
And the user application calls an interface of the ConfigerServer service to trigger the rule deletion operation. The configuration server receives a rule editing request aiming at deletion operation, splices a directory path of the ETCD in the same way as a rule creating method, and deletes an alarm rule under a corresponding directory of the SideCar machine by calling a sendPost (url, jsonnData, 3000, 3)) method of an Http protocol. It should be noted that the difference between jsonndata and policy is that there is one more key-value pair in jsonndata, namely: "method": "delete".
According to the embodiment of the disclosure, after the creation, query or deletion operation of the alarm rule is completed, whether the checking effect meets the expectation or not can be checked by logging in the correct directory of the corresponding SideCar machine.
Fig. 7 schematically shows a block diagram of a monitoring device applied to a configuration server according to an embodiment of the present disclosure.
As shown in fig. 7, the apparatus 700 includes a receiving module 710, a rule generating module 720, an address determining module 730, and a sending module 740.
The receiving module 710 is configured to receive a rule creating request from a user side, where the rule creating request includes alarm rule information and monitoring object information.
The rule generating module 720 is configured to generate a first alarm rule in a preset format according to the alarm rule information.
And an address determining module 730, configured to determine a network address of the alarm server corresponding to the monitored object information.
The sending module 740 is configured to send the first alarm rule to the alarm server according to the network address, so that the alarm server monitors the monitored object indicated by the monitored object information according to the first alarm rule.
Fig. 8 schematically shows a block diagram of a monitoring device applied to an alert server according to an embodiment of the present disclosure.
As shown in fig. 8, the apparatus 800 includes a monitor module 810 and a sidecar module 820 independent of the monitor.
Wherein, the sidecar program module 820 includes:
the receiving sub-module 821 is used for receiving the alarm rule from the configuration server.
The obtaining submodule 822 is configured to obtain a fourth directory location corresponding to the alarm monitoring program.
The write submodule 823 is configured to write the alarm rule into the fourth directory location.
The monitor module 810 includes:
a reading sub-module 811 for reading the alarm rules at the fourth directory location.
And a monitoring submodule 812, configured to monitor the monitored object according to the alarm rule.
According to the embodiment of the disclosure, the configuration server receives a rule creation request from a user side, generates an alarm rule according to the rule configuration request, distributes the alarm rule to the corresponding monitoring server, and writes the alarm rule into the directory of the monitoring program storage configuration rule by the sidecar program installed in the monitoring server, so that the alarm rule can be created without logging in the monitoring server.
Any number of modules, sub-modules, units, sub-units, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware implementations. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
For example, any number of the receiving module 710, the rule generating module 720, the address determining module 730, the sending module 740, the monitoring program module 810, and the fighting program module 820 may be combined and implemented in one module, or any one of them may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the receiving module 710, the rule generating module 720, the address determining module 730, the sending module 740, the monitoring program module 810, and the sidecar program module 820 may be at least partially implemented as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementations of software, hardware, and firmware, or by a suitable combination of any several of them. Alternatively, at least one of the receiving module 710, the rule generating module 720, the address determining module 730, the sending module 740, the monitoring program module 810, the fighting program module 820 may be at least partially implemented as a computer program module which, when executed, may perform a corresponding function.
FIG. 9 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure. The computer system illustrated in FIG. 9 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 9, a computer system 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the system 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
System 900 may also include an input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The system 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.