getParameter
Definition
getParameter
getParameter
is an administrative command for retrieving the values of parameters. Use thedb.adminCommand( { command } )
method to run thegetParameter
command in theadmin
database.
Compatibility
This command is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Important
This command has limited support in M0, M2, and M5 clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Syntax
The command has the following syntax:
db.adminCommand( { getParameter: <value>, <parameter> : <value>, comment: <any> } )
Command Fields
The command takes the following fields:
Field | Type | Description |
---|---|---|
getParameter | int, string, document | Specify a value of:
|
<parameter> | string | String name of the parameter to retrieve. The value for |
comment | any | Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
A comment can be any valid BSON type (string, integer, object, array, etc). |
Behavior
getParameter
runs on the admin
database only, and returns
an error if run on any other database.
The possible value for <parameter>
may vary depending on what version and
storage engine in use. See Retrieve All Parameters for an
example of listing the available parameters.
Examples
Retrieve Single Parameter
The following operation runs getParameter
on the admin
database using a value of saslHostName
to retrieve the value for
that parameter:
db.adminCommand( { getParameter : 1, "saslHostName" : 1 } )
The command returns the following output:
Note
The output may vary depending on the version and specific configuration of your MongoDB instance.
{ "saslHostName" : "www.example.net:27018", "ok" : 1 }
Retrieve All Parameters
The following operation runs getParameter
with a value of
'*'
to retrieve all parameters:
db.adminCommand( { getParameter : '*' } )
Note
The output may vary depending on the version of MongoDB and the specific configuration of the running MongoDB instance.
Report Details on a Single Parameter
The following example runs getParameter
with
{showDetails: true}
to report details
on saslHostName
.
db.adminCommand( { getParameter : { showDetails: true }, "saslHostName" : 1 } )
Example output:
{ saslHostName: { value: '<hostname>', settableAtRuntime: false, settableAtStartup: true }, ok: 1 }
Note
The output may vary depending on the version and specific configuration of your MongoDB instance.
Report Details for All Parameters
The following example runs getParameter
with
{showDetails: true, allParameters: true}
to report
details on all parameters.
db.adminCommand( { getParameter : { showDetails: true, allParameters: true } } )
Retrieve All Startup Parameters
New in version 8.0.
The following example runs the getParameter
command
to retrieve all startup parameters:
db.adminCommand( { getParameters: { allParameters: true, setAt: "startup" } } )
Retrieve All Runtime Parameters
New in version 8.0.
The following example runs the getParameter
command
to retrieve all runtime parameters:
db.adminCommand( { getParameters: { allParameters: true, setAt: "runtime" } } )