Grafana function control method and device, electronic equipment and medium

文档序号:7450 发布日期:2021-09-17 浏览:17次 中文

1. A Grafana function control method is characterized by comprising the following steps:

when login information is received, the login information is sent to a Grafana platform, so that the Grafana platform verifies the login information, and response information is returned after the verification is passed;

and assembling Cookie data by using the response information, and sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returns Grafana functional data corresponding to the user after the verification is passed.

2. The method according to claim 1, wherein the sending the Cookie data to the Grafana platform comprises:

determining a sub domain name corresponding to the Grafana platform by using a preset parent domain name;

and jumping to the sub-domain name, and writing the Cookie data into the sub-domain name, so that the Grafana platform acquires the Cookie data through the sub-domain name.

3. The method according to claim 2, wherein the jumping to the sub-domain name includes:

setting the page corresponding to the sub-domain name as a nested page, and jumping to the sub-domain name.

4. The method according to claim 1, further comprising, after assembling Cookie data using the response information:

and when an exit event is detected, calling a logout interface of the Grafana platform to set the Cookie data to be invalid.

5. The method according to claim 1, wherein the sending the login information to a Grafana platform includes:

and sending the login information to the Grafana platform through a login interface of the Grafana platform.

6. The method according to claim 1, further comprising, before receiving the login information:

and when registration information is received, sending the registration information to the Grafana platform so that the Grafana platform generates user information by using the registration information.

7. The method according to claim 6, wherein after the Grafana platform generates user information using the registration information, the method further comprises:

and when user change information is received, sending the user change information to the Grafana platform so that the Grafana platform updates corresponding user information by using the user change information.

8. The utility model provides a Grafana function management and control device which characterized in that includes:

the login module is used for sending login information to the Grafana platform when the login information is received, so that the Grafana platform verifies the login information, and returns response information after the verification is passed;

and the Grafana activation module is used for assembling Cookie data by using the response information, sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returning Grafana functional data corresponding to the user after the verification is passed.

9. An electronic device, comprising:

a memory for storing a computer program;

a processor for implementing the Grafana function management method according to any one of claims 1 to 7 when executing the computer program.

10. A storage medium having stored thereon computer-executable instructions that, when loaded and executed by a processor, implement the method for Grafana function governance of any one of claims 1 to 7.

Background

Grafana is a data visualization platform used for data monitoring and data statistics. In the related art, a developer may embed the Grafana platform into an own platform to use the functions provided by Grafana, but at this time, the Grafana platform can only provide public functions for the own platform, and it is difficult to provide a private service for each user in the own platform, which affects the control of the Grafana platform on the functions.

Disclosure of Invention

The invention aims to provide a method and a device for controlling Grafana functions, electronic equipment and a storage medium, which can provide corresponding functions for users of own platforms by using a user information management mechanism of the Grafana platforms, further ensure that the Grafana platforms can provide special functions for the users of the own platforms, and improve the control capability of the own platforms on the related functions.

In order to solve the above technical problem, the present invention provides a method for controlling a Grafana function, comprising:

when login information is received, the login information is sent to a Grafana platform, so that the Grafana platform verifies the login information, and response information is returned after the verification is passed;

and assembling Cookie data by using the response information, and sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returns Grafana functional data corresponding to the user after the verification is passed.

Optionally, the sending the Cookie data to the Grafana platform includes:

determining a sub domain name corresponding to the Grafana platform by using a preset parent domain name;

and jumping to the sub-domain name, and writing the Cookie data into the sub-domain name, so that the Grafana platform acquires the Cookie data through the sub-domain name.

Optionally, the jumping to the sub-domain name includes:

setting the page corresponding to the sub-domain name as a nested page, and jumping to the sub-domain name.

Optionally, after assembling Cookie data by using the response information, the method further includes:

and when an exit event is detected, calling a logout interface of the Grafana platform to set the Cookie data to be invalid.

Optionally, the sending the login information to the Grafana platform includes:

and sending the login information to the Grafana platform through a login interface of the Grafana platform.

Optionally, before receiving the login information, the method further includes:

and when registration information is received, sending the registration information to the Grafana platform so that the Grafana platform generates user information by using the registration information.

Optionally, after the Grafana platform generates user information by using the registration information, the method further includes:

and when user change information is received, sending the user change information to the Grafana platform so that the Grafana platform updates corresponding user information by using the user change information.

The invention also provides a Grafana function control device, which comprises:

the login module is used for sending login information to the Grafana platform when the login information is received, so that the Grafana platform verifies the login information, and returns response information after the verification is passed;

and the Grafana activation module is used for assembling Cookie data by using the response information, sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returning Grafana functional data corresponding to the user after the verification is passed.

The present invention also provides an electronic device comprising:

a memory for storing a computer program;

and the processor is used for realizing the Grafana function control method when executing the computer program.

The invention further provides a storage medium, wherein the storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the method for managing and controlling the Grafana function is realized.

The invention provides a Grafana function control method, which comprises the following steps: when login information is received, the login information is sent to a Grafana platform, so that the Grafana platform verifies the login information, and response information is returned after the verification is passed; and assembling Cookie data by using the response information, and sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returns Grafana functional data corresponding to the user after the verification is passed.

Therefore, when login information is received, the login information is sent to the Grafana platform for verification, and Cookie data are assembled by using response information returned by the Grafana platform, so that the Grafana platform provides corresponding functional services by using the Cookie data; meanwhile, in order to avoid the situation that the user needs to log in again when using the Grafana service in the own platform, the Cookie data can be sent to the platform when the Grafana platform is determined to be activated. The Cookie data is assembled from the response information and contains necessary information for user verification, so that the Grafana platform can be ensured to perform efficient verification by using the Cookie data, the problem that the user logs in again is avoided, and the efficiency of the Grafana platform for providing Grafana service for the self platform is effectively improved. The invention also provides a Grafana function control device, electronic equipment and a storage medium, and has the beneficial effects.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a flowchart of a method for controlling Grafana functions according to an embodiment of the present invention;

fig. 2 is a block diagram of a grapana function control apparatus according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

In the related art, a developer may embed the Grafana platform into an own platform to use the functions provided by Grafana, but at this time, the Grafana platform can only provide public functions for the own platform, and it is difficult to provide a private service for each user in the own platform, which affects the control of the Grafana platform on the functions. In view of this, the present invention provides a method for controlling a Grafana function, which can provide a corresponding function for a user of an own platform by using a user information management mechanism of a Grafana platform, thereby ensuring that the Grafana platform can provide a dedicated function for the user of the own platform, and improving the control capability of the own platform on the related function. Referring to fig. 1, fig. 1 is a flowchart of a method for controlling Grafana functions according to an embodiment of the present invention, where the method includes:

and S101, when the login information is received, sending the login information to the Grafana platform so that the Grafana platform verifies the login information, and returning response information after the verification is passed.

It should be noted that the execution subject of the method provided by the present invention is a self-owned platform, wherein the self-owned platform refers to a platform developed by a developer according to the application requirement. The embodiment of the invention does not limit the development framework of the own platform, and can be selected according to the actual application requirements, for example, in a possible situation, the development framework of the own platform can be a flash framework, wherein the flash is a network application framework developed based on Python language.

In the related art, in order to embed the Grafana platform into the self-owned platform, a developer usually sets the login mode of the Grafana to anonymous login, so that the Grafana platform provides common services for all users in the self-owned platform. However, in this case, each user can access the function of the Grafana platform and the data managed by the function, which makes it difficult for the administrator to manage not only the authority of the Grafana platform but also the user data, and thus makes it difficult for the self-owned platform to effectively manage and control the function provided by the Grafana. In the invention, a user information management mechanism built in the Grafana is adopted to provide corresponding functions for the user of the self-owned platform, in other words, the invention makes the self-owned platform and the user information management mechanism of the Grafana open, and ensures that the Grafana platform can also provide special services according to the user information of the self-owned platform. Further, in the invention, when the self-owned platform receives the login information, the information is sent to the Grafana platform for verification, so that the user is ensured to log in the Grafana platform while logging in the self-owned platform.

It should be noted that, the embodiment of the present invention does not limit the specific content included in the login information, for example, the specific content may be a user name, a password, and the like, and the specific content may be set according to the actual application requirement. The invention also does not limit how to send the login information to the Grafana platform, for example, the login information is packaged according to a preset format, and the packaged login information is sent to the Grafana platform, so that the Grafana platform analyzes and verifies the login information according to the preset format; certainly, the self-owned platform can also send the login information as a parameter to the Grafana platform by calling the login interface provided by the Grafana platform. In consideration of the functional interface provided by the login interface for the primitive of the Grafana, the data transmission by using the interface can effectively avoid the redevelopment, so in the embodiment of the invention, the login information can be sent to the Grafana platform through the login interface (specifically/logic) of the Grafana platform. It should be noted that, the embodiment of the present invention does not limit the specific form of the login interface, nor the specific manner of invoking the login interface, and reference may be made to Grafana related technology.

In one possible scenario, sending login information to the Grafana platform includes:

step 11: and sending the login information to the Grafana platform through a login interface of the Grafana platform.

Further, it can be understood that, in order to provide a dedicated Grafana service for a user by using a user information management mechanism of the Grafana platform, when the user is registered, registration information of the user also needs to be sent to the Grafana platform, so that the Grafana platform creates corresponding user information by using the registration information, and thus, when the self platform sends login information to the Grafana platform, the Grafana platform can verify the login information by using the created user information.

In a possible case, before receiving the login information, the method further includes:

step 21: and when the registration information is received, sending the registration information to the Grafana platform so that the Grafana platform generates user information by using the registration information.

It should be noted that the description of how the self-owned platform sends the registration information to the Grafana platform is consistent with the limited description of how the self-owned platform sends the registration information to the Grafana platform, and details are not repeated here. In one possible scenario, the registration information may be sent to the Grafana platform through a registration interface of the Grafana platform (specifically, the interface is/api/admin/user). The embodiment of the present invention also does not limit the content specifically contained in the registration information, for example, the content may include a user name, a password, a mailbox, a name, and the like, and the content may be set according to the actual application requirements.

Further, it can be understood that, when the user information changes, the own platform should also send the user change information to the Grafana platform to perform a corresponding update operation.

In a possible case, after the Grafana platform generates the user information using the registration information, the method further includes:

step 31: and when receiving the user change information, sending the user change information to the Grafana platform so that the Grafana platform updates the corresponding user information by using the user change information.

It should be noted that, the embodiment of the present invention does not limit the content included in the user change information, for example, the content may be a user name, a password, a name, a mailbox, and the like, and the content may be set according to the actual application requirement.

Furthermore, the embodiment of the present invention does not limit whether the self-owned platform can be provided with an individual user information management mechanism, which provides functions of user login verification, user registration and user information change, but before sending the login information, the registration information and the user change information to the Grafana platform, the self-owned platform needs to perform corresponding operations using the independent user information management mechanism, such as verifying the login information, generating user information using the registration information, and updating the corresponding user information using the user change information, and only after the user information management mechanism of the self-owned platform completes corresponding operations, the information is sent to the Grafana platform, so that the Grafana platform further completes corresponding operations using the information. When the user information management mechanism provided by the Grafana platform can meet the application requirement of the self-owned platform, the self-owned platform does not need to independently set the user information management mechanism; when the user information management mechanism is expanded by the self-owned platform, or other functions are arranged in the self-owned platform, and not all users need to use the functions of the Grafana platform, the self-owned platform can also be provided with an independent user information management mechanism.

Further, it can be understood that, after the Grafana platform determines that the login information passes the verification, a response message is returned to the self platform, where the response message is a response message corresponding to the login information passing the verification. The embodiment of the present invention does not limit the specific content in the response information, and reference may be made to the Grafana related technology. Of course, if the Grafana platform returns response information even when it is determined that the login information is not verified, the self-owned platform may determine the login status (login success, login failure) according to the specific content of the response information, assemble Cookie data using the response information when the login status is login success, and output a prompt message or perform no operation when the login status is login failure.

And S102, assembling Cookie data by using the response information, sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returning Grafana functional data corresponding to the user after the verification is passed.

A Cookie is data stored on a user's local terminal for distinguishing the identity of the user. Because the Cookie data contains key data for identifying the identity of the user, the Cookie data can be utilized to maintain the login state of the user in the Grafana platform in the embodiment of the invention, and the problem that the user needs to log in the Grafana platform again in the own platform is avoided. It can be understood that, because the Cookie data exists in the web application, in the present invention, both the self-owned platform and the Grafana platform are web applications and both have front-end pages.

It should be noted that the embodiment of the present invention does not limit which data in the response information is used to assemble Cookie data, and may specifically perform setting according to the type of information required by the grapana for Cookie verification, for example, the grapana _ member memory data, the grapana _ session data, and the grapana _ user data in the visible response information are assembled into Cookie data. The invention also does not limit the concrete mode of assembling Cookie data, and can refer to the related technology of Cookie. It will be appreciated that the native platform may also store the Cookie data after completion of its assembly.

Further, it is understood that the front end page of the own platform is provided with a domain name. The embodiment of the invention does not limit how the self-owned platform sends the Cookie data to the Grafana platform, for example, the complete function of the Grafana platform can be transplanted to the self-owned platform, and the Grafana platform is directly accessed by using the domain name of the front-end page of the self-owned platform (instead of accessing the Grafana platform by using page jump or page embedding mode), at the moment, the Cookie data can be set under the domain name by the self-owned platform, and the Grafana platform can acquire the Cookie data by using the domain name; or the self-owned platform sets the domain name of the front-end page as a father domain name and sets a son domain name for the Grafana platform based on the father domain name, at the moment, the self-owned platform can store the Cookie data into the son domain name, and the Grafana platform can acquire the Cookie data through the son domain name. In order to reduce development work brought by transplantation, in the embodiment of the invention, a sub domain name can be set for the Grafana platform based on a parent domain name of a free platform, and Cookie data is stored in the sub domain name, so that the Grafana platform can obtain the Cookie data through the sub domain name.

In one possible scenario, sending Cookie data to a Grafana platform includes:

step 41: determining a sub domain name corresponding to the Grafana platform by using a preset parent domain name;

step 42: jumping to the sub-domain name, and writing the Cookie data into the sub-domain name, so that the Grafana platform obtains the Cookie data through the sub-domain name.

It should be noted that the embodiment of the present invention does not limit the specific way in which Grafana obtains Cookie data through a sub-domain name, and may refer to the related technology of HTTP hypertext transfer protocol; the embodiment of the invention also does not limit the specific forms of the preset father domain name and the son domain name, and can be set by referring to the related technology of the domain names. Com, where the parent domain name of the own platform is qc, the child domain name may be set for the Grafana platform: grafana. qc.test.com.

Further, the embodiment of the present invention does not limit the specific way of domain name skipping, which is related to the specific development framework of the own platform, and can be selected according to the specific situation, for example, when the development framework of the own platform is flash, a redirect module of flash can be used to skip. The self-contained platform of the embodiment of the invention adopts a direct jump mode to carry out page jump or adopts a jump mode in a nested page to carry out page jump. When the function of the Grafana platform is the function mainly displayed by the self platform, page skipping can be carried out in a direct skipping mode; when other functions are arranged on the platform and need to be displayed, jumping can be carried out in the nested page. Considering that the self-owned platform may provide other functions, if the page corresponding to the sub-domain name is jumped in the nested page, other functions can be displayed in the front-end page of the self-owned platform, so in the embodiment of the present invention, the page corresponding to the sub-domain name can be set as the nested page, and further, the jump can be performed in the nested page. The embodiment of the present invention does not limit the manner in which the page corresponding to the sub-domain name is set as the nested page, and may refer to the related technology of HTML (HyperText Markup Language), for example, an iframe > tag may be used to set the page corresponding to the sub-domain name as the nested page, where the iframe > is an HTML tag used to set the nested page.

In one possible scenario, jumping to a sub-domain name comprises:

step 51: setting the page corresponding to the sub-domain name as a nested page, and jumping to the sub-domain name.

Further, the embodiment of the present invention does not limit the manner of detecting whether the Grafana platform is activated, for example, the activation of the Grafana platform may be automatically determined after the user completes login, a corresponding menu may also be set for the Grafana platform, and the activation of the Grafana platform is determined when the user clicks the menu. Considering that the Grafana platform has many functions, in order to improve the user experience, a corresponding menu (specifically, the menu may be/Grafana menu) may be set for the Grafana platform, and when it is detected that the user clicks the menu, the Grafana platform is determined to be activated.

Finally, it can be understood that when the user logs out of the own platform, the Cookie data needs to be set to be invalid, so as to eliminate the login state of the user on the Grafana platform; meanwhile, because the Cookie data contains the key data of the Grafana for confirming the login state of the user, the key data should be set to be invalid by using a login-out interface (specifically, the interface may be/logout) of the Grafana platform, and further, the Cookie data should be set to be invalid.

In one possible case, after assembling Cookie data by using the response information, the method further includes:

step 61: and when an exit event is detected, calling a logout interface of the Grafana platform to disable the Cookie data setting.

Based on the embodiment, when login information is received, the login information is sent to the Grafana platform for verification, and Cookie data is assembled by using response information returned by the platform, so that the Grafana platform provides corresponding functional services by using the Cookie data; meanwhile, in order to avoid the situation that the user needs to log in again when using the Grafana service in the own platform, the Cookie data can be sent to the platform when the Grafana platform is determined to be activated. The Cookie data is assembled from the response information and contains necessary information for user verification, so that the Grafana platform can be ensured to perform efficient verification by using the Cookie data, the problem that the user logs in again is avoided, and the efficiency of the Grafana platform for providing Grafana service for the self platform is effectively improved.

In the following, the Grafana function management and control apparatus, the electronic device, and the storage medium according to the embodiments of the present invention are introduced, and the Grafana function management and control apparatus, the electronic device, and the storage medium described below may be referred to the Grafana function management and control method described above.

Referring to fig. 2, fig. 2 is a block diagram illustrating a Grafana function control apparatus according to an embodiment of the present invention, where the apparatus includes:

the login module 201 is configured to send login information to the Grafana platform when the login information is received, so that the Grafana platform verifies the login information, and returns response information after the verification is passed;

and the Grafana activation module 202 is used for assembling Cookie data by using the response information, sending the Cookie data to the Grafana platform when the activation of the Grafana platform is detected, so that the Grafana platform verifies the Cookie data, and returning Grafana functional data corresponding to the user after the verification is passed.

Optionally, the Grafana activation module 202 may include:

the domain name determining submodule is used for determining a sub domain name corresponding to the Grafana platform by utilizing a preset father domain name;

and the jumping submodule is used for jumping to the sub-domain name and writing the Cookie data into the sub-domain name so that the Grafana platform acquires the Cookie data through the sub-domain name.

Optionally, the skip sub-module may include:

and the jumping unit is used for setting the page corresponding to the sub-domain name as a nested page and jumping to the sub-domain name.

Optionally, the apparatus may further include:

and the quit module is used for calling a logout interface of the Grafana platform to disable the Cookie data setting when a quit event is detected.

Optionally, the login module 201 may include:

and the login submodule is used for sending login information to the Grafana platform through a login interface of the Grafana platform.

Optionally, the apparatus may further include:

and the registration module is used for sending the registration information to the Grafana platform when the registration information is received, so that the Grafana platform generates the user information by using the registration information.

Optionally, the apparatus may further include:

and the information change module is used for sending the user change information to the Grafana platform when the user change information is received, so that the Grafana platform updates the corresponding user information by using the user change information.

An embodiment of the present invention further provides an electronic device, including:

a memory for storing a computer program;

a processor for implementing the steps of the data writing method when executing the computer program.

Since the embodiment of the electronic device portion corresponds to the embodiment of the Grafana function control method portion, reference is made to the description of the embodiment of the Grafana function control method portion for the embodiment of the electronic device portion, and details are not repeated here.

The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for controlling a Grafana function according to any of the above embodiments are implemented.

Since the embodiment of the computer-readable storage medium portion corresponds to the embodiment of the Grafana function control method portion, for the embodiment of the computer-readable storage medium portion, reference is made to the description of the embodiment of the Grafana function control method portion, which is not repeated herein.

The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.

Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

The method, the device, the electronic device and the storage medium for controlling the Grafana function provided by the invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种接口测试方法以及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!