Skip to content
Open
3 changes: 3 additions & 0 deletions admin/commands/management/add_mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type AddMongoDBCommand struct {
StatsCollections []string `help:"Collections for collstats & indexstats"`
CollectionsLimit int32 `name:"max-collections-limit" default:"-1" help:"Disable collstats, dbstats, topmetrics and indexstats if there are more than <n> collections. 0: No limit. Default is -1, which let PMM automatically set this value"`
ExposeExporter bool `name:"expose-exporter" help:"Optionally expose the address of the exporter publicly on 0.0.0.0"`
AgentEnvVars map[string]string `name:"agent-env-vars" mapsep:"," help:"Additional environment variables for the exporter, e.g. 'VAR1=value1,VAR2=value2'"`

AddCommonFlags
flags.MetricsModeFlags
Expand Down Expand Up @@ -125,6 +126,7 @@ func (cmd *AddMongoDBCommand) GetCredentials() error {
// RunCmd runs the command for AddMongoDBCommand.
func (cmd *AddMongoDBCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseKeyValuePair(cmd.CustomLabels)
agentVars := commands.ParseKeyValuePair(cmd.AgentEnvVars)

tlsCertificateKey, err := commands.ReadFile(cmd.TLSCertificateKeyFile)
if err != nil {
Expand Down Expand Up @@ -180,6 +182,7 @@ func (cmd *AddMongoDBCommand) RunCmd() (commands.Result, error) {
QANMongodbMongolog: cmd.QuerySource == MongodbQuerySourceMongolog,

CustomLabels: customLabels,
AgentEnvironmentVariables: agentVars,
SkipConnectionCheck: cmd.SkipConnectionCheck,
MaxQueryLength: cmd.MaxQueryLength,
TLS: cmd.TLS,
Expand Down
1 change: 1 addition & 0 deletions agent/agents/mongodb/mongolog/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Params struct {
AgentID string
LogFilePrefix string // for development and testing
MaxQueryLength int32
Env map[string]string
}

// New creates new MongoDB QAN service.
Expand Down
1 change: 1 addition & 0 deletions agent/agents/mongodb/profiler/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Params struct {
DSN string
AgentID string
MaxQueryLength int32
Env map[string]string
}

// New creates new MongoDB QAN service.
Expand Down
2 changes: 2 additions & 0 deletions agent/agents/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ func (s *Supervisor) startBuiltin(agentID string, builtinAgent *agentv1.SetState
DSN: dsn,
AgentID: agentID,
MaxQueryLength: builtinAgent.MaxQueryLength,
Env: builtinAgent.Env,
}
agent, err = mongoprofiler.New(params, l)

Expand All @@ -594,6 +595,7 @@ func (s *Supervisor) startBuiltin(agentID string, builtinAgent *agentv1.SetState
DSN: dsn,
AgentID: agentID,
MaxQueryLength: builtinAgent.MaxQueryLength,
Env: builtinAgent.Env,
}
agent, err = mongolog.New(params, l)

Expand Down
4 changes: 2 additions & 2 deletions api-tests/management/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ func TestAddMongoDB(t *testing.T) {
},
},
}
addProxySQLOK, err := client.Default.ManagementService.AddService(params)
addMongoDBOK, err := client.Default.ManagementService.AddService(params)
pmmapitests.AssertAPIErrorf(t, err, 400, codes.InvalidArgument, "Socket and address cannot be specified together.")
assert.Nil(t, addProxySQLOK)
assert.Nil(t, addMongoDBOK)
})

t.Run("Socket", func(t *testing.T) {
Expand Down
Loading
Loading