db.enableFreeMonitoring()
On this page本页内容
db.enableFreeMonitoring()
-
Enables free monitoring for standalones and replica sets and returns the free monitoring status.s允许对单机集和复制副本集进行免费监视,并返回免费监视状态ImportantTo run若要运行db.enableFreeMonitoring()
, you must have specified--enableFreeMonitoring
command-line option orcloud.monitoring.free.state
configuration file set toruntime
.db.enableFreeMonitoring()
,必须指定--enableFreeMonitoring
命令行选项或cloud.monitoring.free.state
配置文件设置为runtime
。Otherwise, you can only enable or disable at startup.否则,您只能在启动时启用或禁用。See有关详细信息,请参阅--enableFreeMonitoring
command-line option orcloud.monitoring.free.state
for details.--enableFreeMonitoring
命令行选项或cloud.monitoring.free.state
。Thedb.enableFreeMonitoring()
method is a wrapper around thesetFreeMonitoring
command.db.enableFreeMonitoring()
方法是setFreeMonitoring
命令的包装器。
Behavior行为
Once enabled, the free monitoring state remains enabled until explicitly disabled. 启用后,空闲监视状态将保持启用状态,直到明确禁用为止。That is, you do not need to re-enable each time you start the server.也就是说,您不需要在每次启动服务器时重新启用。
Once enabled, you are provided with a unique URL where you can access your monitored data.一旦启用,您将获得一个唯一的URL,您可以在其中访问受监控的数据。
When enabled, the monitored data is uploaded periodically. The monitored data expires after 24 hours. 启用后,会定期上传监控数据。监视的数据将在24小时后过期。That is, you can only access monitored data that has been uploaded within the past 24 hours.也就是说,您只能访问在过去24小时内上传的监控数据。
For the frequency with which data is uploaded, see 有关上载数据的频率,请参阅freeMonitoring.retryIntervalSecs
.freeMonitoring.retryIntervalSecs
。
Access Control访问控制
When running with access control, the user must have the 在使用访问控制运行时,用户必须在集群上具有setFreeMonitoring
and checkFreeMonitoringStatus
privilege actions on the cluster. setFreeMonitoring
和checkFreeMonitoringStatus
权限操作。That is, a user must have a role that grants the following privilege:也就是说,用户必须具有授予以下权限的角色:
{ resource: { cluster : true }, actions: [ "setFreeMonitoring" , "checkFreeMonitoringStatus"] }
The built-in role 内置的角色clusterMonitor
role provides this privilege.clusterMonitor
角色提供了此权限。
Example实例
To enable free monitoring, run the following in 要启用免费监控,请在mongosh
:mongosh
中运行以下操作:
db.enableFreeMonitoring()
This starts the registration process for free monitoring. The method returns your free monitoring status:这将启动免费监控的注册过程。该方法返回您的免费监控状态:
{
"state" : "enabled",
"message" : "To see your monitoring data, navigate to the unique URL below.\nAnyone you share the URL with will also be able to view this page.\n\nhttps://cloud.mongodb.com/freemonitoring/mongo/MSBjZTZhNTJmOS0yODg1\n\nYou can disable monitoring at any time by running db.disableFreeMonitoring().",
"url" : "https://cloud.mongodb.com/freemonitoring/mongo/MSBjZTZhNTJmOS0yODg1",
"userReminder" : "",
"ok" : 1
}
You can also use 您也可以随时使用db.getFreeMonitoringStatus()
any time to check your free monitoring status.db.getFreeMonitoringStatus()
来检查您的免费监控状态。