Data query method and device of cmdb and electronic equipment
Patent Information
- Application Number
- CN202311633785.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-30
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-11-30
AI Technical Summary
[0005]有鉴于此,本申请提供一种CMDB的数据查询方法、装置及电子设备,用以解决在CMDB中进行配置项查询的查询效率较低的技术问题,如下:
[0062]从上述技术方案可以看出,本申请公开的一种CMDB的数据查询方法、装置及电子设备中,在获得查询请求之后,先根据查询请求,在基于CMDB中的配置项的属性信息和配置项之间的配置关系所得到的待选路径获得至少一条目标路径,待选路径至少两个配置项类型节点,且相邻两个配置项类型节点之间对应有类型关联关系,由此,在至少根据目标路径中所包含的目标类型节点构建查询语句之后,可以直接在CMDB中执行查询语句,以得到查询结果,查询结果中包括目标类型节点对应的目标配置项的属性信息以及目标配置项之间的配置关系。可见,本实施例中基于CMDB中的配置项的属性信息及其之间的配置关系构建路径集合,然后按照查询请求路径集合中对应的目标路径来构建查询语句,进而在CMDB中按照目标路径中的配置项类型节点进行配置项的属性信息和配置关系的查询,无需使用查询请求直接在CMDB中查询配置项,从而通过配置项所形成的路径查询来减少查询数据量,从而提高查询效率。
Smart Images

Figure CN117633002B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data query method, apparatus and electronic device for CMDB. Background Technology
[0002] CMDB stands for Configuration Management Database. It contains information about the entire lifecycle of configuration items and the relationships between them, such as physical relationships, real-time communication relationships, non-real-time communication relationships, and dependencies.
[0003] Currently, when querying a CMDB, the query is usually performed on each detailed data entry in the CMDB. This requires comparing each detailed data entry of a configuration item in the CMDB with the configuration item attribute information, type information, and other information in the query request. This results in a huge amount of data to be compared, leading to low query efficiency.
[0004] Therefore, there is an urgent need for a technical solution that can improve the efficiency of CMDB queries. Summary of the Invention
[0005] In view of this, this application provides a data query method, apparatus, and electronic device for CMDB to solve the technical problem of low query efficiency in CMDB configuration item queries, as follows:
[0006] A data query method for CMDB, the method comprising:
[0007] Obtain the query request;
[0008] Based on the query request, at least one target path is obtained from the path set, which includes multiple candidate paths. Each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items.
[0009] Construct a query statement based at least on the target type nodes contained in the target path;
[0010] The query statement is executed in the CMDB to obtain the query results, which include the attribute information of the target configuration items corresponding to the target type node and the configuration relationships between the target configuration items.
[0011] Preferably, in the above method, the query request includes at least the attribute information of the first configuration item, and the query request further includes at least one of the following: the configuration item type of the second configuration item, hop count information, and the attribute information of the second configuration item; the hop count information represents the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item.
[0012] Specifically, obtaining at least one target path from the path set according to the query request includes:
[0013] Based on the query request, query parameters are obtained. The query parameters include at least: a first type of the first configuration item, and the query parameters also include: a second type of the second configuration item, or a target hop count for the configuration item type, wherein the target hop count corresponds to the hop count information.
[0014] According to the first type and the second type, at least one target path is obtained in the path set; or, according to the first type and the target hop count, at least one target path is obtained in the path set.
[0015] Wherein, the configuration item type of the source node in the target path is consistent with the first type, the configuration item type of the destination node in the target path is consistent with the second type, and the number of configuration item type nodes in the target path matches the target hop count.
[0016] Preferably, the path set is obtained through the following method:
[0017] Read the attribute information of configuration items and the configuration relationships between configuration items from the CMDB;
[0018] Based on the attribute information of the configuration items and the configuration relationships between the configuration items, a configuration item triplet is obtained. The configuration item triplet includes: a source configuration item, a destination configuration item, and the configuration relationship between the source configuration item and the destination configuration item.
[0019] Based on the configuration item triples, a configuration item type graph database is constructed; the configuration item type graph database contains multiple configuration item type nodes, and each configuration item type node has a type association relationship with at least one other configuration item type node;
[0020] Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple candidate paths are obtained;
[0021] Add the candidate path to the path set.
[0022] The above method, preferably, involves constructing a configuration item type graph database based on the configuration item triples, including:
[0023] Initialize the configuration item type graph database;
[0024] Obtain one of the configuration item triples as the current triple;
[0025] Based on the current triplet, a type triplet is obtained, which includes the source type of the source configuration item, the destination type of the destination configuration item, and the type association between the source type and the destination type;
[0026] The search results are obtained by checking whether there is a first type node that matches the source type, a second type node that matches the destination type, and the type association between the first type node and the second type node matches the type association between the source type and the destination type in the configuration item type graph database.
[0027] Based on the search results, add configuration item type nodes and / or type associations to the configuration item type graph database;
[0028] Obtain another configuration item triplet as the new current triplet, and perform the following: based on the current triplet, obtain the type triplet, until all the configuration item triplets have been processed once.
[0029] The above method, preferably, involves adding configuration item type nodes and / or type associations to the configuration item type graph database based on the search results, including:
[0030] If the search results indicate that no first type node matches the source type and no second type node matches the destination type, add a first type node that matches the source type and a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship to the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0031] If the search results indicate that there are first type nodes that match the source type, and second type nodes that match the destination type, and the first type nodes and second type nodes do not have a type association relationship that matches the type association relationship between the source type and the destination type, then add a type association relationship that matches the type association relationship between the source type and the destination type to the first type nodes and second type nodes in the configuration item type graph database.
[0032] If the search results indicate that there are first type nodes that match the source type and no second type nodes that match the destination type, add a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0033] If the search results indicate that there is no first type node that matches the source type but there is a second type node that matches the destination type, add a first type node that matches the source type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0034] The above method, preferably, obtains multiple candidate paths based on the configuration item type nodes in the configuration item type graph database and the type association relationships, including:
[0035] Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple configuration item type paths are constructed; each configuration item type path includes a path source node and a path destination node, and the connection between the path source node and the path destination node represents the type association relationship between the configuration item type node corresponding to the path source node and the configuration item type node corresponding to the path destination node;
[0036] The configuration item type path is integrated according to the path source node and the path destination node contained therein to obtain multiple candidate paths.
[0037] The above method, preferably, involves integrating the configuration item type paths according to the included path source nodes and path destination nodes to obtain multiple candidate paths, including:
[0038] Among the multiple configuration item type paths, one configuration item type path is selected as the first type path;
[0039] Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as the second type path;
[0040] Compare the source node of the first type of path with the destination node of the second type of path;
[0041] If the destination node of the first type of path is the same as the source node of the second type of path, the destination node of the first type of path and the source node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a third type of path. The source node of the third type of path is the source node of the first type of path, the destination node of the third type of path is the destination node of the second type of path, and the destination node of the first type of path and the source node of the second type of path are intermediate nodes in the third type of path.
[0042] The third type of path will be used as the new configuration item type path;
[0043] Compare the source node of the first type of path with the destination node of the second type of path;
[0044] If the source node of the first type of path is the same as the destination node of the second type of path, the source node of the first type of path and the destination node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a fourth type of path. The source node of the fourth type of path is the source node of the second type of path, the destination node of the fourth type of path is the destination node of the first type of path, and the source node of the first type of path and the destination node of the second type of path are intermediate nodes in the fourth type of path.
[0045] The fourth type of path will be used as the new configuration item type path;
[0046] Among the multiple configuration item type paths, another configuration item type that is different from the second type path is obtained as a new second type path, and the following is performed: comparing the path source node of the first type path with the path destination node of the second type path, until all configuration item type paths in the multiple configuration item type paths have been compared with other configuration item type paths as second type paths;
[0047] Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a new first type path. Then, the following is executed: among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a second type path, until all configuration item type paths among the multiple configuration item type paths have been compared with other configuration item type paths as first type paths.
[0048] Preferably, before adding the candidate path to the path set, the method further includes:
[0049] The candidate paths are filtered so that the candidate paths added to the path set meet the filtering conditions.
[0050] The filtering criteria include at least one of the following:
[0051] The candidate paths are matched with the business scenarios corresponding to the query requests;
[0052] There must be at least one different configuration item type node or at least one different type association relationship between any two of the candidate paths;
[0053] The number of hops between nodes of the configuration item type in the candidate path is less than or equal to the hop count threshold.
[0054] A data query device for a CMDB, the device comprising:
[0055] The request retrieval unit is used to retrieve query requests;
[0056] The path query unit is used to obtain at least one target path from the path set according to the query request. The path set includes multiple candidate paths, and each candidate path includes at least two configuration item type nodes. There is a type association relationship between two adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationship between configuration items.
[0057] A statement construction unit is used to construct a query statement based at least on the target type nodes contained in the target path;
[0058] The statement execution unit is used to execute the query statement in the CMDB to obtain query results, which include attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items.
[0059] An electronic device, comprising:
[0060] A memory used to store computer programs and the data generated by the execution of said computer programs;
[0061] A processor is configured to execute the computer program to: obtain a query request; obtain at least one target path from a path set according to the query request, the path set including multiple candidate paths, each candidate path including at least two configuration item type nodes, with a type association relationship between adjacent configuration item type nodes; the candidate paths are obtained based on the attribute information of configuration items in a CMDB and the configuration relationships between configuration items; construct a query statement based at least on the target type nodes contained in the target path; execute the query statement in the CMDB to obtain query results, the query results including the attribute information of the target configuration items corresponding to the target type nodes and the configuration relationships between the target configuration items.
[0062] As can be seen from the above technical solutions, in the CMDB data query method, apparatus, and electronic device disclosed in this application, after obtaining a query request, at least one target path is obtained from the candidate paths obtained based on the attribute information of configuration items and the configuration relationships between configuration items in the CMDB. The candidate path has at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. Therefore, after constructing a query statement based at least on the target type nodes contained in the target path, the query statement can be directly executed in the CMDB to obtain the query result. The query result includes the attribute information of the target configuration item corresponding to the target type node and the configuration relationship between the target configuration items. It can be seen that in this embodiment, a path set is constructed based on the attribute information of configuration items in the CMDB and the configuration relationships between them. Then, a query statement is constructed according to the target path corresponding to the query request path set. Then, the attribute information and configuration relationships of configuration items are queried in the CMDB according to the configuration item type nodes in the target path. There is no need to use a query request to directly query configuration items in the CMDB. Thus, the amount of query data is reduced by querying through the path formed by configuration items, thereby improving query efficiency. Attached Figure Description
[0063] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0064] Figure 1 A flowchart illustrating a CMDB data query method provided in Embodiment 1 of this application;
[0065] Figures 2-5 These are partial flowcharts of a CMDB data query method provided in Embodiment 1 of this application;
[0066] Figure 6 This is a schematic diagram of the structure of a CMDB data query device provided in Embodiment 2 of this application;
[0067] Figure 7 This is another structural schematic diagram of a CMDB data query device provided in Embodiment 2 of this application;
[0068] Figure 8 This is a flowchart illustrating the method for generating CMDB configuration item type path data based on original CMDB detail diagram data in this application.
[0069] Figure 9 A schematic diagram illustrating the generation of CMDB configuration item type path data for the CMDB detailed data graph database in this application;
[0070] Figure 10 This is a schematic diagram illustrating the method for accelerating fuzzy querying of original CMDB detail map data based on CMDB configuration type path data in this application;
[0071] Figure 11 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. Detailed Implementation
[0072] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0073] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0074] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0075] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0076] refer to Figure 1 The diagram shown is a flowchart of a data query method for CMDB provided in Embodiment 1 of this application. This method can be applied to electronic devices capable of data processing, such as computers or servers. The method in this embodiment is mainly used to improve the query efficiency of configuration item queries in CMDB.
[0077] Specifically, the method in this embodiment may include the following steps:
[0078] Step 101: Obtain the query request.
[0079] The query request includes at least the attribute information of the first configuration item, and also includes at least one of the following: the configuration item type of the second configuration item, the hop count information, and the attribute information of the second configuration item; the hop count information represents the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item.
[0080] In one scenario, the query request includes attribute information for a first configuration item and configuration item type for a second configuration item. This query request instructs the CMDB to retrieve attribute information for all configuration items that match the attribute information of the first configuration item and the configuration item type of the second configuration item, as well as the configuration relationships between these configuration items.
[0081] In another scenario, the query request includes attribute information and hop count information for the first configuration item; the query request is used to instruct: query the CMDB for the attribute information of all configuration items that match the attribute information of the first configuration item and the configuration items that satisfy the hop count information from the first configuration item, as well as the configuration relationships between these configuration items.
[0082] In another scenario, the query request includes attribute information for both the first and second configuration items. This query request instructs the CMDB to retrieve the attribute information of all configuration items that match the attribute information of the first and second configuration items, and the configuration relationships between these items.
[0083] It's important to note that a configuration item can be understood as an object being configured. Taking a shopping application X as an example, configuring the shopping application X to be deployed on server Y, server Y is also a configuration item. The configuration relationships between configuration items are the association relationships between the objects being configured; for example, the shopping application X and server Y have a deployment relationship.
[0084] The attribute information of the first configuration item in the query request may include: the name, ID, and type of the first configuration item, and the attribute information of the second configuration item may include: the name, ID, and type of the second configuration item. For example, the attribute information of shopping application X includes the name "X", ID "TB2003", and type "software", while the attribute information of server Y includes the name "Y", ID "FWQ2023", and type "server". The hop count information can be represented numerically. There may be no other configuration items between the first and second configuration items, in which case the hop count information is 1. There may also be one or more intermediate configuration items between the second configuration items. From the first configuration item to an intermediate configuration item and then to the second configuration item, any two adjacent configuration items have a configuration relationship; in this case, the hop count information is the number of configuration items between the second configuration items plus 1.
[0085] Step 102: Based on the query request, obtain at least one target path from the path set.
[0086] The path set includes multiple candidate paths, each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes; the candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items.
[0087] The path set can be implemented using a table, where each row represents a candidate path. Each candidate path must include at least a configuration item type node serving as the source node and a configuration item type node serving as the destination node. Furthermore, each candidate path may also include configuration item type nodes that serve as intermediate nodes between the source and destination nodes.
[0088] For example, the candidate path includes three nodes: a "software" type node as the source node, a "server" type node as an intermediate node, and a "cluster" type node as the destination node. Among them, there is a deployment relationship between the "software" type and the "server" type, and a membership relationship between the "server" type and the "cluster" type.
[0089] Specifically, the candidate path can be obtained by extracting the attribute information of the configuration items in the CMDB to obtain the configuration item type, and then obtaining the type association relationship between the configuration item types based on the configuration relationship between the configuration items. Then, the node is transformed according to the configuration item type and the type association relationship between them, and then the path is constructed on the node to obtain the candidate path.
[0090] Step 103: Construct a query statement based at least on the target type nodes contained in the target path.
[0091] The target path contains two or more configuration item type nodes, i.e., target type nodes. These target type nodes include source type nodes and destination type nodes, and may also contain intermediate type nodes. Based on this, this embodiment generates one or more corresponding query statements according to the information carried in the query request and the configuration item type nodes contained in the target path.
[0092] For example, if the query request contains the name of the first configuration item as "X" and the hop count as "2", the query statement constructed by the target path obtained from the query will use the following as the query keywords: the name of the configuration item as the source type node is "X" and the configuration item type is "software", the configuration item as the intermediate node is "server", and the configuration item type corresponding to the destination type node is "cluster".
[0093] For example, if the query request contains the name "X" of the first configuration item and the configuration item type of the second configuration item is "server", the query statement constructed by the target path obtained by querying uses the following as the query keywords: the name of the configuration item as the source type node is "X" and the configuration item type is "software", and the configuration item type as the destination type node is "server".
[0094] Step 104: Execute a query statement in the CMDB to obtain the query results. The query results include the attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items.
[0095] Specifically, in this embodiment, each query statement is executed in the CMDB, and then the initial results corresponding to each query statement are merged to obtain the final query result.
[0096] The query results include: attribute information of the configuration item corresponding to each configuration item type node in the target path, and the configuration relationship between the configuration items corresponding to two adjacent configuration item type nodes. This configuration relationship corresponds to the type association relationship between the corresponding configuration item type nodes.
[0097] As can be seen from the above technical solution, in the CMDB data query method provided in Embodiment 1 of this application, after obtaining a query request, at least one target path is obtained based on the candidate paths obtained from the attribute information of configuration items and the configuration relationships between configuration items in the CMDB. The candidate path has at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. Therefore, after constructing a query statement based at least on the target type nodes contained in the target path, the query statement can be directly executed in the CMDB to obtain the query result. The query result includes the attribute information of the target configuration item corresponding to the target type node and the configuration relationship between the target configuration items. It can be seen that in this embodiment, a path set is constructed based on the attribute information of configuration items in the CMDB and the configuration relationships between them. Then, a query statement is constructed according to the target path corresponding to the query request path set. Then, the attribute information and configuration relationships of configuration items are queried in the CMDB according to the configuration item type nodes in the target path. There is no need to use a query request to directly query configuration items in the CMDB. Thus, the query is performed through the path formed by configuration items to reduce the amount of query data and improve query efficiency.
[0098] In one implementation, step 102, when obtaining at least one target path from the path set based on the query request, can be achieved in the following way:
[0099] First, based on the query request, query parameters are obtained. These parameters include at least: the first type of the first configuration item, which can be obtained by extracting the type from the attribute information of the first configuration item; and the second type of the second configuration item or the target hop count for the configuration item type, which can be obtained by extracting the type from the attribute information of the second configuration item. The target hop count corresponds to the hop count information, representing the number of configuration item types corresponding to the configuration items between the first and second types.
[0100] For example, a target hop count of 1 indicates that there is a type association relationship between the first type and the second type. This type association relationship corresponds to the configuration relationship between the first configuration item and the second configuration item. There are no other configuration item types between the first type and the second type.
[0101] For example, if the target hop count is 2, it indicates that there is another configuration item type between the first type and the second type. There is a type association relationship between the first type and this configuration item type, which corresponds to the configuration relationship between the first type and this configuration item type. There is also a type association relationship between this configuration item type and the second type, which corresponds to the configuration relationship between this configuration item type and the second type.
[0102] Then, based on the content contained in the query parameters, the target path is obtained in the following way:
[0103] In one implementation, if the query parameters include a first type and a second type, at least one target path is obtained from the path set according to the first type and the second type.
[0104] For example, in this embodiment, the configuration item type node that serves as the source node in each candidate path in the path set can be compared with the first type to obtain at least one initial path. The configuration item type node that serves as the source node in the initial path matches the first type. Then, in these initial paths, the configuration item type node that serves as the destination node in each initial path can be compared with the second type to filter out at least one target path. The configuration item type node that serves as the destination node in the target path matches the second type.
[0105] For example, in this embodiment, the configuration item type node that serves as the destination node in each candidate path in the path set can be compared with the second type to obtain at least one initial path. The configuration item type node that serves as the destination node in the initial path matches the second type. Then, in these initial paths, the configuration item type node that serves as the source node in each initial path is compared with the first type to filter out at least one target path. The configuration item type node that serves as the source node in the target path matches the first type.
[0106] In another implementation, if the query parameters include a first type and a target hop count, at least one target path is obtained from the path set according to the first type and the target hop count.
[0107] For example, in this embodiment, the configuration item type node that serves as the source node in each candidate path in the path set can be compared with the first type to obtain at least one initial path. The configuration item type node that serves as the source node in the initial path matches the first type. Then, in these initial paths, the initial path that has the same number of hops between the configuration item type node that serves as the source node and the configuration item type node that serves as the destination node is selected, which is the target path.
[0108] For example, in this embodiment, we can first select candidate paths from the candidate paths where the number of hops between the configuration item type nodes as source nodes and the configuration item type nodes as destination nodes is consistent with the target number of hops. These are the initial paths. Then, we compare the configuration item type nodes as source nodes in each initial path with the first type to obtain the target path. The configuration item type nodes as source nodes in the target path match the first type, and the number of hops in the target path is the target number of hops.
[0109] In one implementation, the path set can be implemented in the following ways, such as... Figure 2 As shown:
[0110] Step 201: Read the attribute information of the configuration items and the configuration relationships between the configuration items from the CMDB.
[0111] Specifically, in this embodiment, detailed data of the CMDB stored in the relational database, such as the attribute information of configuration items, can be placed in the same data table. This data table contains at least the attribute information such as the type, ID, and name of the configuration items. The configuration relationship between the configuration items is placed in another data table. This data table contains the ID of the configuration item as the source node and the ID of the configuration item as the destination node, which respectively represent that there is a configuration relationship between the two configuration items. In addition, the optional fields in this data table can be filled with the type of configuration relationship.
[0112] Step 202: Obtain the configuration item triplet based on the attribute information of the configuration items and the configuration relationships between the configuration items.
[0113] The configuration item triple includes: source configuration item, destination configuration item, and the configuration relationship between the source and destination configuration items.
[0114] Specifically, in this embodiment, the attribute information of the configuration items and the configuration relationships between the configuration items can be converted into data formats to obtain configuration item triples.
[0115] Step 203: Construct a configuration item type graph database based on the configuration item triples.
[0116] The configuration item type graph database contains multiple configuration item type nodes, and each configuration item type node has a type association relationship with at least one other configuration item type node.
[0117] Among them, the configuration item type node is established based on the configuration item type of the source configuration item and the configuration item type of the destination configuration item in the configuration item triplet, and the type association relationship between configuration item type nodes is established based on the configuration relationship between the source configuration item and the destination configuration item in the configuration item triplet.
[0118] Step 204: Based on the configuration item type nodes and type associations in the configuration item type graph database, obtain multiple candidate paths.
[0119] Specifically, in this embodiment, the configuration item type node is used as the path node, and the connection relationship between the path nodes is established according to the type association relationship, thereby obtaining multiple candidate paths.
[0120] Step 205: Add the candidate paths to the path set.
[0121] In this embodiment, before step 205, the candidate paths can be filtered first so that the candidate paths added to the path set in step 205 meet the filtering conditions.
[0122] Specifically, the filtering criteria may include at least one of the following:
[0123] The candidate paths match the business scenario corresponding to the query request;
[0124] There must be at least one different configuration item type node or at least one different type association relationship between any two candidate paths;
[0125] The number of hops between nodes of the configuration item type in the candidate path is less than or equal to the hop count threshold.
[0126] For example, in this embodiment, candidate paths that do not match the business scenario corresponding to the query request, such as an aviation simulation scenario, will be deleted, redundant paths in the candidate paths will be deleted, and candidate paths with a node hop count exceeding a hop count threshold, such as 8, will be eliminated.
[0127] Redundant paths refer to candidate paths that have the exact same type association relationship with a candidate path in terms of configuration item type nodes and adjacent configuration item type nodes.
[0128] In specific implementation, when constructing the configuration item type graph database based on the configuration item triplet in step 203, it can be achieved in the following way, such as... Figure 3 As shown:
[0129] Step 301: Initialize the configuration item type graph database.
[0130] In the initial state, the configuration item type graph database is empty.
[0131] Step 302: Obtain a configuration item triplet as the current triplet.
[0132] The configuration item triple includes: source configuration item, destination configuration item, and the configuration relationship between the source and destination configuration items.
[0133] Step 303: Based on the current triple, obtain the type triple. The type triple includes the source type of the source configuration item, the destination type of the destination configuration item, and the type association between the source type and the destination type.
[0134] Among them, the source type of the source configuration item is determined based on the attribute information of the source configuration item in the configuration item triplet, the destination type of the destination configuration item is determined based on the attribute information of the destination configuration item in the configuration item triplet, and the type association relationship between the source type and the destination type is determined based on the configuration relationship between the source configuration item and the destination configuration item in the configuration item triplet. Thus, the source type, destination type and the type association relationship between them are obtained in the type triplet based on the source configuration item, the destination configuration item and the configuration relationship between them in the configuration item triplet.
[0135] Step 304: Search the configuration item type graph database for whether there is a first type node that matches the source type, a second type node that matches the destination type, and the type association between the first type node and the second type node that matches the type association between the source type and the destination type, so as to obtain the search results.
[0136] Step 305: Based on the search results, add configuration item type nodes and / or type associations to the configuration item type graph database.
[0137] Specifically, step 305 includes at least one of the following:
[0138] If the search results indicate that there is no first type node that matches the source type and no second type node that matches the destination type, then step 305 adds a first type node that matches the source type and a second type node that matches the destination type to the configuration item type graph database, and also adds a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0139] If the search results indicate that there are first-type nodes that match the source type and second-type nodes that match the destination type, but the first-type nodes and second-type nodes do not have a type association relationship consistent with the type association relationship between the source type and the destination type, then in step 305, a type association relationship consistent with the type association relationship between the source type and the destination type is added to the first-type nodes and second-type nodes in the configuration item type graph database.
[0140] If the search results indicate that there are first type nodes that match the source type but no second type nodes that match the destination type, then step 305 adds a second type node that matches the destination type to the configuration item type graph database, and adds a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0141] If the search results indicate that there is no first type node that matches the source type but there is a second type node that matches the destination type, then step 305 adds a first type node that matches the source type to the configuration item type graph database, and adds a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0142] Step 306: Obtain another configuration item triplet as the new current triplet, and execute step 303 until all configuration item triplets have been processed once.
[0143] In specific implementation, when obtaining multiple candidate paths in step 204 based on the configuration item type nodes and type associations in the configuration item type graph database, it can be achieved in the following way: Figure 4 As shown:
[0144] Step 401: Based on the configuration item type nodes and type associations in the configuration item type graph database, construct multiple configuration item type paths.
[0145] Each configuration item type path includes a path source node and a path destination node. The connection between the path source node and the path destination node represents the type association relationship between the configuration item type node corresponding to the path source node and the configuration item type node corresponding to the path destination node.
[0146] For example, configuration item type nodes in the configuration item type graph database can be used as path nodes. Connections between path nodes can be established according to the type associations between configuration item type nodes. The connections between path nodes represent the type associations between the corresponding configuration item type nodes.
[0147] Therefore, each configuration item type path is a 1-hop path.
[0148] Step 402: Integrate the configuration item type paths according to the included path source nodes and path destination nodes to obtain multiple candidate paths.
[0149] Specifically, in step 402, the source and destination nodes of any two configuration item type paths can be compared among multiple configuration item type paths, and then the configuration item type paths can be integrated according to the comparison results, such as... Figure 5 As shown:
[0150] Step 501: Among multiple configuration item type paths, obtain one configuration item type as the first type path.
[0151] For example, you can first choose the path A->B as the first type of path, or choose the path A->B->C as the first type of path.
[0152] Step 502: Among the multiple configuration item type paths, obtain another configuration item type that is different from the first type path as the second type path.
[0153] For example, choose the path A->C as the second type of path, or choose the path B->C as the second type of path, or choose the path D->A as the second type of path, or choose the path C->D as the second type of path.
[0154] Step 503: Compare the source node of the first type of path with the destination node of the second type of path. If the destination node of the first type of path matches the source node of the second type of path, proceed to step 504. If they do not match, proceed to step 506.
[0155] Step 504: Merge the destination node of the first type of path and the source node of the second type of path into one node, so that the first type of path and the second type of path are integrated into the third type of path.
[0156] In this system, the source node of the third type of path is the source node of the first type of path, the destination node of the third type of path is the destination node of the second type of path, and the destination node of the first type of path and the source node of the second type of path are intermediate nodes in the third type of path.
[0157] For example, if the destination node in the path A->B is the same as the source node in the path B->C, then A->B and B->C are combined into the path A->B->C, which is considered a third type of path.
[0158] For example, if the path destination node C->D in the path A->B->C has the same path source node, then A->B->C and C->D can be integrated into A->B->C->D, which is considered a third type of path.
[0159] Step 505: Set the third type path as the new configuration item type path.
[0160] Step 506: Compare the source node of the first type of path and the destination node of the second type of path; if the source node of the first type of path and the destination node of the second type of path are the same, proceed to step 507; if they are not the same, proceed to step 509.
[0161] Step 507: Merge the source node of the first type of path and the destination node of the second type of path into one node, so that the first type of path and the second type of path are integrated into the fourth type of path.
[0162] In this context, the source node of the fourth type of path is the source node of the second type of path, the destination node of the fourth type of path is the destination node of the first type of path, and the source node of the first type of path and the destination node of the second type of path are intermediate nodes in the fourth type of path.
[0163] For example, if the source node of the path A->B is the same as the destination node of the path D->A, then A->B and D->A are integrated into the path D->A->B, which is the fourth type of path.
[0164] Step 508: Use the fourth type of path as the new configuration item type path.
[0165] Among them, the new configuration item type path can be used as a new first type path and a new second type path in the comparison of path source node and path destination node.
[0166] Step 509: Among the multiple configuration item type paths, obtain another configuration item type that is different from the second type path as the new second type path, and execute step 503 until all configuration item type paths in the multiple configuration item type paths have been compared with other configuration item type paths as second type paths, and then execute step 510.
[0167] Step 510: Among the multiple configuration item type paths, obtain another configuration item type that is different from the first type path as the new first type path, and execute 502 until all configuration item type paths in the multiple configuration item type paths have been compared with other configuration item type paths as the first type path.
[0168] Therefore, the final integrated configuration item type paths are the candidate paths, and any two of these candidate paths no longer need to be integrated. Based on this, after filtering according to the selection criteria, the resulting candidate paths are added to the path set.
[0169] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0170] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0171] Although the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous.
[0172] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0173] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0174] refer to Figure 6This is a schematic diagram of a data query device for a CMDB provided in Embodiment 2 of this application. The device can be configured in an electronic device capable of data processing, such as a computer or server. The method in this embodiment is mainly used to improve the query efficiency of configuration item queries in the CMDB.
[0175] Specifically, the apparatus in this embodiment may include the following units:
[0176] Request retrieval unit 601 is used to obtain query requests;
[0177] The path query unit 602 is used to obtain at least one target path from the path set according to the query request. The path set includes multiple candidate paths, and each candidate path includes at least two configuration item type nodes. There is a type association relationship between two adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationship between configuration items.
[0178] The statement construction unit 603 is used to construct a query statement based at least on the target type nodes contained in the target path;
[0179] The statement execution unit 604 is used to execute the query statement in the CMDB to obtain query results. The query results include attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items.
[0180] As can be seen from the above technical solution, in the CMDB data query device provided in Embodiment 2 of this application, after obtaining a query request, at least one target path is obtained based on the candidate paths obtained from the attribute information of configuration items and the configuration relationships between configuration items in the CMDB. The candidate path has at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. Therefore, after constructing a query statement based at least on the target type nodes contained in the target path, the query statement can be directly executed in the CMDB to obtain the query result. The query result includes the attribute information of the target configuration item corresponding to the target type node and the configuration relationship between the target configuration items. It can be seen that in this embodiment, a path set is constructed based on the attribute information of configuration items in the CMDB and the configuration relationships between them. Then, a query statement is constructed according to the target path corresponding to the query request path set. Then, the attribute information and configuration relationships of configuration items are queried in the CMDB according to the configuration item type nodes in the target path. There is no need to use a query request to directly query configuration items in the CMDB. Thus, the amount of query data is reduced by querying through the path formed by configuration items, thereby improving query efficiency.
[0181] In one implementation, the query request includes at least attribute information of a first configuration item, and the query request further includes at least one of the following: configuration item type of a second configuration item, hop count information, and attribute information of the second configuration item; the hop count information represents the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item.
[0182] Specifically, the path query unit 602 is used to: obtain query parameters according to the query request, the query parameters including at least: a first type of the first configuration item, the query parameters further including: a second type of the second configuration item, or a target hop count of the configuration item type, the target hop count corresponding to the hop count information; obtain at least one target path in the path set according to the first type and the second type; or, obtain at least one target path in the path set according to the first type and the target hop count; wherein the configuration item type of the source node in the target path is consistent with the first type, the configuration item type of the destination node in the target path is consistent with the second type, and the number of configuration item type nodes in the target path matches the target hop count.
[0183] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 7 As shown:
[0184] The path acquisition unit 605 obtains the path set in the following manner:
[0185] From the CMDB, read the attribute information of configuration items and the configuration relationships between them; based on the attribute information and the configuration relationships, obtain configuration item triples, each triple including: a source configuration item, a destination configuration item, and the configuration relationship between the source and destination configuration items; construct a configuration item type graph database based on the configuration item triples; the configuration item type graph database contains multiple configuration item type nodes, and each configuration item type node has a type association relationship with at least one other configuration item type node; based on the configuration item type nodes in the configuration item type graph database and the type association relationships, obtain multiple candidate paths; add the candidate paths to a path set.
[0186] Specifically, when constructing a configuration item type graph database based on the configuration item triplet, the path acquisition unit 605 is specifically used for: initializing the configuration item type graph database; obtaining one of the configuration item triplets as the current triplet; obtaining a type triplet based on the current triplet, wherein the type triplet includes the source type of the source configuration item, the destination type of the destination configuration item, and the type association relationship between the source type and the destination type; searching in the configuration item type graph database for whether there is a first type node consistent with the source type, a second type node consistent with the destination type, and the type association relationship between the first type node and the second type node consistent with the type association relationship between the source type and the destination type, to obtain a search result; adding configuration item type nodes and / or type association relationships to the configuration item type graph database based on the search result; obtaining another configuration item triplet as a new current triplet, and performing the step of: obtaining a type triplet based on the current triplet, until all the configuration item triplets have been processed once.
[0187] Specifically, when the path acquisition unit 605 adds configuration item type nodes and / or type associations to the configuration item type graph database based on the search results, it is used for:
[0188] If the search results indicate that no first type node matches the source type and no second type node matches the destination type, add a first type node that matches the source type and a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship to the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0189] If the search results indicate that there are first type nodes that match the source type, and second type nodes that match the destination type, and the first type nodes and second type nodes do not have a type association relationship that matches the type association relationship between the source type and the destination type, then add a type association relationship that matches the type association relationship between the source type and the destination type to the first type nodes and second type nodes in the configuration item type graph database.
[0190] If the search results indicate that there are first type nodes that match the source type and no second type nodes that match the destination type, add a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0191] If the search results indicate that there is no first type node that matches the source type but there is a second type node that matches the destination type, add a first type node that matches the source type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
[0192] In one implementation, when the path acquisition unit 605 obtains multiple candidate paths based on the configuration item type nodes in the configuration item type graph database and the type association relationships, it can do so in the following way:
[0193] Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple configuration item type paths are constructed. Each configuration item type path includes a path source node and a path destination node. The connection between the path source node and the path destination node represents the type association relationship between the configuration item type node corresponding to the path source node and the configuration item type node corresponding to the path destination node. The configuration item type paths are integrated according to the included path source node and path destination node to obtain multiple candidate paths.
[0194] In one implementation, when the path acquisition unit 605 integrates the configuration item type paths according to the included path source nodes and path destination nodes to obtain multiple candidate paths, it is specifically used for:
[0195] Among the multiple configuration item type paths, one configuration item type path is selected as the first type path;
[0196] Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as the second type path;
[0197] Compare the source node of the first type of path with the destination node of the second type of path;
[0198] If the destination node of the first type of path is the same as the source node of the second type of path, the destination node of the first type of path and the source node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a third type of path. The source node of the third type of path is the source node of the first type of path, the destination node of the third type of path is the destination node of the second type of path, and the destination node of the first type of path and the source node of the second type of path are intermediate nodes in the third type of path.
[0199] The third type of path will be used as the new configuration item type path;
[0200] Compare the source node of the first type of path with the destination node of the second type of path;
[0201] If the source node of the first type of path is the same as the destination node of the second type of path, the source node of the first type of path and the destination node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a fourth type of path. The source node of the fourth type of path is the source node of the second type of path, the destination node of the fourth type of path is the destination node of the first type of path, and the source node of the first type of path and the destination node of the second type of path are intermediate nodes in the fourth type of path.
[0202] The fourth type of path will be used as the new configuration item type path;
[0203] Among the multiple configuration item type paths, another configuration item type that is different from the second type path is obtained as a new second type path, and the following is performed: comparing the path source node of the first type path with the path destination node of the second type path, until all configuration item type paths in the multiple configuration item type paths have been compared with other configuration item type paths as second type paths;
[0204] Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a new first type path. Then, the following is executed: among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a second type path, until all configuration item type paths among the multiple configuration item type paths have been compared with other configuration item type paths as first type paths.
[0205] In one implementation, before the path acquisition unit 605 adds the candidate paths to the path set, it is further configured to: filter the candidate paths so that the candidate paths added to the path set meet the filtering conditions; wherein the filtering conditions include at least one of the following:
[0206] The candidate paths are matched with the business scenarios corresponding to the query requests;
[0207] There must be at least one different configuration item type node or at least one different type association relationship between any two of the candidate paths;
[0208] The number of hops between nodes of the configuration item type in the candidate path is less than or equal to the hop count threshold.
[0209] It should be noted that the specific implementation of each unit in this embodiment can be referred to the corresponding description above, and will not be detailed here.
[0210] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules do not necessarily limit the specific unit; for example, an analysis module can also be described as a "statistical analysis module".
[0211] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0212] Taking the CMDB deployed by an aviation company as an example, the data query scheme of the CMDB implemented by the technical solution of this application is illustrated as follows:
[0213] First, the technical solution of this application mainly consists of two aspects. On the one hand, it provides a solution for generating CMDB configuration item type path data based on the original CMDB graph data. On the other hand, it provides a solution for accelerating fuzzy query of CMDB detail graph data based on CMDB configuration item type path data.
[0214] The details of the scheme for generating CMDB configuration item type path data based on the original CMDB graph data are as follows:
[0215] 1. Import CMDB data into the graph database to form a CMDB detailed data graph database;
[0216] 2. Traverse all triples in the CMDB detailed data graph database, add the configuration item type corresponding to the triple and the relationship between the configuration item types to the CMDB configuration item type and relationship graph database. The same configuration item type node has only one node in the CMDB configuration item type and relationship graph database.
[0217] 3. Based on the CMDB configuration item types and relationship graph database generated in step 2, obtain the one-hop CMDB path data between CMDB configuration item types, i.e., the configuration item type path;
[0218] 4. Method for obtaining all N+1 hop paths: Based on all N-hop paths, for each path, traverse the head node or tail node and add a hop to the CMDB data relationship list. Find the relationships that can match the head node (path source node) or tail node (path destination node) of the path, and concatenate them to form an N+1 hop path. Then, check in the CMDB detailed data graph database whether the path has a node with data (configuration relationship). If it exists, keep the path; otherwise, do not keep it.
[0219] For example, if there is an original two-hop path A->B->C, and we need to add a three-hop path, and the list of one-hop paths is [D->E, C->E, A->B, F->A], then we can add the head node of the two-hop path to form the three-hop path F->A->B->C, and add the tail node of the two-hop path to form the three-hop path A->B->C->E.
[0220] 5. Repeat step 4 above until there are no more one-hop relationships to add or the path reaches the maximum number of hops. This will give you the original CMDB path data.
[0221] 6. Filter out the data that does not meet the requirements from the original CMDB path data to obtain the final path data, that is, the filtered candidate paths;
[0222] 7. Import the final path data obtained in step 6 into a relational database.
[0223] The details of the solution for accelerating fuzzy queries of CMDB data based on CMDB configuration item type path data are as follows:
[0224] 1. For fuzzy query scenarios involving CMDB graph data, there are mainly three situations:
[0225] a. Given detailed attribute information of the source node and type information of the target node, query the data that meets the conditions and the connection relationships between them;
[0226] b. Given detailed attribute information and hop count information of the source node, query the data that meets the conditions and the connection relationships between them;
[0227] c. Given detailed attribute information of the source node and detailed attribute information of the target node, query whether there is a relationship between them.
[0228] 2. For the fuzzy query scenario given in step 1, retrieve the configuration item type information of the source node and the target node;
[0229] 3. Based on the source node type + target node type or source node type + hop count information, query the configuration item type path database to obtain relevant path information;
[0230] 4. Based on the detailed attribute information of the source or target node in step 1, and combined with the path information obtained in step 3, generate a graph query statement containing detailed path information through intermediate node types.
[0231] 5. Use the graph query statement generated in step 4 to query the CMDB detailed data graph database and obtain the final query results.
[0232] The following examples, in conjunction with the accompanying drawings, illustrate the scheme of this application:
[0233] refer to Figure 8 The flowchart for generating CMDB configuration item type path data based on the original CMDB detail diagram data is as follows:
[0234] 1. Store detailed CMDB data node information stored in the relational database in the same table. This table should at least contain the node (configuration item) type, unique ID, and name attribute. Store relational data in another table. This table should at least contain the source node unique ID and the destination node unique ID. Optional fields include the relationship type, etc.
[0235] 2. Import CMDB data from the relational database into the graph database to form a graph database of CMDB detailed data;
[0236] 3. Traverse all triples (i.e., source node, target node, relation) in the CMDB detailed data graph database, and query the types of the source and target nodes in the triple. Determine whether these two configuration item types and their relationship exist in the configuration item type graph database. Take different operations for the following different cases:
[0237] (1) If the two configuration item type nodes and their relationship already exist in the configuration item type graph database, then ignore the triplet.
[0238] (2) If neither of these two configuration item types nor their relationship exists in the configuration item type graph database, then add the corresponding configuration item type nodes and their relationship to the configuration item type graph database.
[0239] (3) If two configuration item types already exist in the configuration item type graph database but the relationship between them does not exist, then find the nodes of the two configuration item types in the configuration item type graph database and add the relationship between them;
[0240] (4) If the source configuration item type node already exists in the configuration item type graph database, but the target configuration item type node does not exist, then add the target configuration item type node in the configuration item type graph database and add the relationship between the source configuration item type node and the target configuration item type node.
[0241] (5) If the target configuration item type node already exists in the configuration item type graph database, but the source configuration item type node does not exist, then add the source configuration item type node in the configuration item type graph database and add the relationship between the source configuration item type node and the target configuration item type node.
[0242] 4. Repeat step 3, traverse all triples in the CMDB detailed data graph database, obtain the relationships between configuration item types, generate CMDB configuration item types and relationship data, and store them in the configuration item type graph database;
[0243] 5. Based on the CMDB configuration item types and relationship graph database generated in step 4, generate path data for all one-hop CMDB configuration item types;
[0244] 6. To obtain all N+1 hop paths, based on all N-hop paths, iterate through all one-hop CMDB configuration item type path data, select one-hop path data that can match the head node or tail node, concatenate them into an N+1 hop path, and verify whether the path exists in the CMDB detailed data graph database. If it exists, keep the path; otherwise, do not keep it.
[0245] 7. Repeat step 6 above until there are no more relationships to add or the path reaches the maximum number of hops. This will give you the original CMDB configuration item type path data.
[0246] 8. Filter the obtained raw CMDB configuration item type path data, and the filtering rules are as follows:
[0247] (1) Delete paths that exceed the hop limit;
[0248] (2) Delete duplicate paths;
[0249] (3) Delete unnecessary paths in the business.
[0250] 9. Based on step 8, this application obtains the final CMDB configuration item type path data, stores the data in a relational database, and creates an index. The storage structure in the relational database is shown in Table 1 below.
[0251] Table 1 Storage Structure
[0252] A E A->B->C->D->E 4
[0253] A diagram illustrating the generation of CMDB configuration item type path data from the CMDB detailed data graph database is shown below. Figure 9 As shown in the image.
[0254] refer to Figure 10 This is a schematic diagram illustrating a method for accelerating fuzzy querying of original CMDB detail map data based on CMDB configuration type path data.
[0255] 1. For fuzzy query scenarios involving CMDB graph data, there are mainly the following three:
[0256] a. Given detailed attribute information of the source node and type information of the target node, query the data that meets the conditions and the connection relationships between them;
[0257] b. Given detailed attribute information and hop count information of the source node, query the data that meets the conditions and the connection relationships between them;
[0258] c. Given detailed attribute information of the source node and detailed attribute information of the target node, query whether there is a relationship between them.
[0259] 2. For the fuzzy query scenario given in 1, retrieve the configuration item types of the source node and the target node;
[0260] 3. Based on the source node type + target node type or source node type + hop count information, query relevant path information in the CMDB path database;
[0261] 4. Based on the detailed attribute information of the source node or target node in step 1, and combined with the path information obtained in step 3, generate multiple graph query statements with detailed path information of intermediate node types.
[0262] 5. Using the graph query statements generated in step 4, query the CMDB detailed data graph database multiple times, merge the results of multiple query statements, and obtain the final result.
[0263] In summary, this application provides a solution for automatically generating configuration item type path data based on detailed CMDB data from a graph database. Furthermore, it provides a method for accelerating fuzzy queries of CMDB data structures using configuration item type path data. This provides assistance in fault location, fault impact analysis, and deployment structure optimization during operation and maintenance. This method offers several advantages over using graph database queries alone:
[0264] 1. Significantly increased the speed of querying CMDB detailed data;
[0265] 2. The query process can display path information between configuration item types, a feature not supported in graph databases;
[0266] 3. The final returned results can be filtered based on the path information between configuration item types, reducing the impact of unnecessary data.
[0267] The following is for reference. Figure 11 It shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. Figure 11 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0268] like Figure 11 As shown, the electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage device 1108 into a random access memory (RAM) 1103. The RAM 1103 also stores various programs and data required for the operation of the electronic device. The processor 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0269] Typically, the following devices can be connected to I / O interface 1105: input devices 1106 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1107 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1108 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1109. Communication device 1109 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 11 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have instead.
[0270] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1109, or installed from storage device 1108, or installed from ROM 1102. When the computer program is executed by processor 1101, it performs the functions defined in the methods of embodiments of this disclosure:
[0271] Obtain the query request;
[0272] Based on the query request, at least one target path is obtained from the path set, which includes multiple candidate paths. Each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items.
[0273] Construct a query statement based at least on the target type nodes contained in the target path;
[0274] The query statement is executed in the CMDB to obtain the query results, which include the attribute information of the target configuration items corresponding to the target type node and the configuration relationships between the target configuration items.
[0275] This invention also claims a computer storage medium for storing computer software instructions for use in the aforementioned electronic device, comprising programs designed to perform the aforementioned aspects.
[0276] The aforementioned computer-readable medium carries one or more programs that, when executed by an electronic device, cause the electronic device to:
[0277] Obtain the query request;
[0278] Based on the query request, at least one target path is obtained from the path set, which includes multiple candidate paths. Each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items.
[0279] Construct a query statement based at least on the target type nodes contained in the target path;
[0280] The query statement is executed in the CMDB to obtain the query results, which include the attribute information of the target configuration items corresponding to the target type node and the configuration relationships between the target configuration items.
[0281] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. It should be noted that the computer-readable medium described above in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0282] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0283] According to one or more embodiments of this disclosure, Figure 1The illustrated embodiment provides a CMDB data query method, including:
[0284] Obtain the query request;
[0285] Based on the query request, at least one target path is obtained from the path set, which includes multiple candidate paths. Each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items.
[0286] Construct a query statement based at least on the target type nodes contained in the target path;
[0287] The query statement is executed in the CMDB to obtain the query results, which include the attribute information of the target configuration items corresponding to the target type node and the configuration relationships between the target configuration items.
[0288] According to one or more embodiments of this disclosure, Figure 6 A data query device for a CMDB is provided, the device comprising:
[0289] The request retrieval unit is used to retrieve query requests;
[0290] The path query unit is used to obtain at least one target path from the path set according to the query request. The path set includes multiple candidate paths, and each candidate path includes at least two configuration item type nodes. There is a type association relationship between two adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationship between configuration items.
[0291] A statement construction unit is used to construct a query statement based at least on the target type nodes contained in the target path;
[0292] The statement execution unit is used to execute the query statement in the CMDB to obtain query results, which include attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items.
[0293] According to one or more embodiments of this disclosure, Figure 11 An electronic device is provided, comprising:
[0294] Memory, such as ROM1102, RAM1103 and storage device 1108, is used to store computer programs and data generated by the execution of said computer programs;
[0295] A processor is configured to execute the computer program to: obtain a query request; obtain at least one target path from a path set according to the query request, the path set including multiple candidate paths, each candidate path including at least two configuration item type nodes, with a type association relationship between adjacent configuration item type nodes; the candidate paths are obtained based on the attribute information of configuration items in a CMDB and the configuration relationships between configuration items; construct a query statement based at least on the target type nodes contained in the target path; execute the query statement in the CMDB to obtain query results, the query results including the attribute information of the target configuration items corresponding to the target type nodes and the configuration relationships between the target configuration items.
[0296] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
[0297] While several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0298] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
Claims
1. A data query method for a CMDB, characterized in that, The method includes: A query request is obtained, the query request including at least the attribute information of the first configuration item, and the query request also includes at least one of the following: the configuration item type of the second configuration item, hop count information, and the attribute information of the second configuration item; the hop count information represents the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item. Based on the query request, at least one target path is obtained from the path set, which includes multiple candidate paths. Each candidate path includes at least two configuration item type nodes, and there is a type association relationship between adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationships between configuration items. Construct a query statement based at least on the target type nodes contained in the target path; Execute the query statement in the CMDB to obtain the query results, which include the attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items; Specifically, obtaining at least one target path from the path set according to the query request includes: Based on the query request, query parameters are obtained. The query parameters include at least: a first type of the first configuration item, and the query parameters also include: a second type of the second configuration item, or a target hop count for the configuration item type, wherein the target hop count corresponds to the hop count information. According to the first type and the second type, at least one target path is obtained in the path set; or, according to the first type and the target hop count, at least one target path is obtained in the path set. Wherein, the configuration item type of the source node in the target path is consistent with the first type, the configuration item type of the destination node in the target path is consistent with the second type, and the number of configuration item type nodes in the target path matches the target hop count.
2. The method according to claim 1, characterized in that, The set of paths is obtained in the following way: Read the attribute information of configuration items and the configuration relationships between configuration items from the CMDB; Based on the attribute information of the configuration items and the configuration relationships between the configuration items, a configuration item triplet is obtained. The configuration item triplet includes: a source configuration item, a destination configuration item, and the configuration relationship between the source configuration item and the destination configuration item. Based on the configuration item triples, a configuration item type graph database is constructed; the configuration item type graph database contains multiple configuration item type nodes, and each configuration item type node has a type association relationship with at least one other configuration item type node; Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple candidate paths are obtained; Add the candidate path to the path set.
3. The method according to claim 2, characterized in that, Based on the configuration item triples, construct a configuration item type graph database, including: Initialize the configuration item type graph database; Obtain one of the configuration item triples as the current triple; Based on the current triplet, a type triplet is obtained, which includes the source type of the source configuration item, the destination type of the destination configuration item, and the type association between the source type and the destination type; The search results are obtained by checking whether there is a first type node that matches the source type, a second type node that matches the destination type, and the type association between the first type node and the second type node matches the type association between the source type and the destination type in the configuration item type graph database. Based on the search results, add configuration item type nodes and / or type associations to the configuration item type graph database; Obtain another configuration item triplet as the new current triplet, and perform the following: based on the current triplet, obtain the type triplet, until all the configuration item triplets have been processed once.
4. The method according to claim 3, characterized in that, Based on the search results, add configuration item type nodes and / or type associations to the configuration item type graph database, including: If the search results indicate that no first type node matches the source type and no second type node matches the destination type, add a first type node that matches the source type and a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship to the first type node and the second type node that matches the type association relationship between the source type and the destination type. If the search results indicate that there are first type nodes that match the source type, and second type nodes that match the destination type, and the first type nodes and second type nodes do not have a type association relationship that matches the type association relationship between the source type and the destination type, then add a type association relationship that matches the type association relationship between the source type and the destination type to the first type nodes and second type nodes in the configuration item type graph database. If the search results indicate that there are first type nodes that match the source type and no second type nodes that match the destination type, add a second type node that matches the destination type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type. If the search results indicate that there is no first type node that matches the source type but there is a second type node that matches the destination type, add a first type node that matches the source type to the configuration item type graph database, and add a type association relationship between the first type node and the second type node that matches the type association relationship between the source type and the destination type.
5. The method according to claim 3, characterized in that, Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple candidate paths are obtained, including: Based on the configuration item type nodes in the configuration item type graph database and the type association relationships, multiple configuration item type paths are constructed; each configuration item type path includes a path source node and a path destination node, and the connection between the path source node and the path destination node represents the type association relationship between the configuration item type node corresponding to the path source node and the configuration item type node corresponding to the path destination node; The configuration item type path is integrated according to the path source node and the path destination node contained therein to obtain multiple candidate paths.
6. The method according to claim 5, characterized in that, The configuration item type paths are integrated according to the included path source nodes and path destination nodes to obtain multiple candidate paths, including: Among the multiple configuration item type paths, one configuration item type path is selected as the first type path; Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as the second type path; Compare the source node of the first type of path with the destination node of the second type of path; If the destination node of the first type of path is the same as the source node of the second type of path, the destination node of the first type of path and the source node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a third type of path. The source node of the third type of path is the source node of the first type of path, the destination node of the third type of path is the destination node of the second type of path, and the destination node of the first type of path and the source node of the second type of path are intermediate nodes in the third type of path. The third type of path will be used as the new configuration item type path; Compare the source node of the first type of path with the destination node of the second type of path; If the source node of the first type of path is the same as the destination node of the second type of path, the source node of the first type of path and the destination node of the second type of path are merged into one node, so that the first type of path and the second type of path are integrated into a fourth type of path. The source node of the fourth type of path is the source node of the second type of path, the destination node of the fourth type of path is the destination node of the first type of path, and the source node of the first type of path and the destination node of the second type of path are intermediate nodes in the fourth type of path. The fourth type of path will be used as the new configuration item type path; Among the multiple configuration item type paths, another configuration item type that is different from the second type path is obtained as a new second type path, and the following is performed: comparing the path source node of the first type path with the path destination node of the second type path, until all configuration item type paths in the multiple configuration item type paths have been compared with other configuration item type paths as second type paths; Among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a new first type path. Then, the following is executed: among the multiple configuration item type paths, another configuration item type that is different from the first type path is obtained as a second type path, until all configuration item type paths among the multiple configuration item type paths have been compared with other configuration item type paths as first type paths.
7. The method according to claim 2, characterized in that, Before adding the candidate paths to the path set, the method further includes: The candidate paths are filtered so that the candidate paths added to the path set meet the filtering conditions. The filtering criteria include at least one of the following: The candidate paths are matched with the business scenarios corresponding to the query requests; There must be at least one different configuration item type node or at least one different type association relationship between any two of the candidate paths; The number of hops between nodes of the configuration item type in the candidate path is less than or equal to the hop count threshold.
8. A data query device for a CMDB, characterized in that, The device includes: A request obtaining unit is used to obtain a query request, wherein the query request includes at least attribute information of a first configuration item, and the query request further includes at least one of the following: configuration item type of a second configuration item, hop count information, and attribute information of the second configuration item; wherein the hop count information represents the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item. The path query unit is used to obtain at least one target path from the path set according to the query request. The path set includes multiple candidate paths, and each candidate path includes at least two configuration item type nodes. There is a type association relationship between two adjacent configuration item type nodes. The candidate paths are obtained based on the attribute information of configuration items in the CMDB and the configuration relationship between configuration items. A statement construction unit is used to construct a query statement based at least on the target type nodes contained in the target path; The statement execution unit is used to execute the query statement in the CMDB to obtain query results, which include attribute information of the target configuration items corresponding to the target type node and the configuration relationship between the target configuration items. The path query unit is specifically used for: obtaining query parameters according to the query request, the query parameters including at least: a first type of the first configuration item, the query parameters further including: a second type of the second configuration item, or a target hop count of the configuration item type, the target hop count corresponding to the hop count information; obtaining at least one target path in the path set according to the first type and the second type; or, obtaining at least one target path in the path set according to the first type and the target hop count; wherein the configuration item type of the source node in the target path is consistent with the first type, the configuration item type of the destination node in the target path is consistent with the second type, and the number of configuration item type nodes in the target path matches the target hop count.
9. An electronic device, characterized in that, include: A memory used to store computer programs and the data generated by the execution of said computer programs; A processor is configured to execute the computer program to: obtain a query request, the query request including at least attribute information of a first configuration item, the query request further including at least one of: configuration item type of a second configuration item, hop count information, and attribute information of the second configuration item; the hop count information representing the number of configuration items that have a sequential configuration relationship between the first configuration item and the second configuration item; obtain at least one target path in a path set according to the query request, the path set including multiple candidate paths, each candidate path including at least two configuration item type nodes, with a type association relationship between adjacent configuration item type nodes; the candidate paths are obtained based on the attribute information of configuration items and the configuration relationships between configuration items in a CMDB; construct a query statement based at least on the target type nodes contained in the target path; execute the query statement in the CMDB to obtain query results, the query results including the... The document describes the attribute information of the target configuration items corresponding to the target type nodes and the configuration relationships between the target configuration items; wherein, according to the query request, obtaining at least one target path in the path set includes: obtaining query parameters according to the query request, the query parameters including at least: a first type of the first configuration item, the query parameters further including: a second type of the second configuration item, or a target hop count of the configuration item type, the target hop count corresponding to the hop count information; obtaining at least one target path in the path set according to the first type and the second type; or, obtaining at least one target path in the path set according to the first type and the target hop count; wherein, the configuration item type of the source node in the target path is consistent with the first type, the configuration item type of the destination node in the target path is consistent with the second type, and the number of configuration item type nodes in the target path matches the target hop count.
Citation Information
Patent Citations
Information query method and device, electronic equipment and storage medium
CN111552792A
Configuration item relation visualization method, system and equipment based on Qunee and medium
CN114817379A