# Run the monitoring agent in DataRobot
URL: https://docs.datarobot.com/en/docs/classic-ui/mlops/mlops-preview/monitoring-agent-in-dr.html

> Run the monitoring agent within the DataRobot platform, one instance per prediction environment.

# Run the monitoring agent in DataRobot

> [!NOTE] Preview
> The monitoring agent in DataRobot is a preview feature, on by default.
> 
> Feature flag: Disable the Monitoring Agent in DataRobot

The [monitoring agent](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/index.html) typically runs outside of DataRobot, reporting metrics from a [configured spooler](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/spooler.html) populated by calls to the DataRobot MLOps library in the external model's code. Now available for preview, you can run the monitoring agent inside DataRobot by creating an [external prediction environment](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/ext-model-prep/ext-pred-env.html) with an external spooler's credentials and configuration details.

To create a prediction environment associated with an external spooler:

1. ClickDeployments > Prediction Environmentsand then clickAdd prediction environment.
2. In theAdd prediction environmentdialog box, complete the following fields: FieldDescriptionNameEnter a descriptive prediction environment name.Description(Optional) Enter a description of the external prediction environment.PlatformSelect the external platform on which the model is running and making predictions.
3. UnderSupported model formats, select one or more formats to control which models can be deployed to the prediction environment, either manually or using the management agent. The available model formats areDataRobotorDataRobot Scoring Code only,External Model, andCustom Model. ImportantYou cannot select bothDataRobotandDataRobot Scoring Code only.
4. UnderManaged by, selectManaged by DataRobot. The following options are provided: OptionDescriptionSelf-managedManually manage models on your infrastructure and report data manually to DataRobot.Managed by Management AgentManage models with theManagement Agenton your own infrastructure.Managed by DataRobotManage models with theManagement Agentinside DataRobot. This option is only available if thePlatformselected isAzure,Amazon Web Services (AWS), orSnowflake.
5. UnderSettings, select aQueue: Amazon SQSGoogle Pub/SubAzure Event HubsSelect theAWS S3 Credentialsfor your Amazon SQS spooler and configure the following Amazon SQS fields:FieldDescriptionRegionSelect the AWS region used for the queue.SQS Queue URLSelect the URL of the SQS queue used for the spooler.Visibility timeout(Optional) Thevisibility timeoutbefore the message is deleted from the queue. This is an Amazon SQS configuration not specific to the monitoring agent.After you configure theQueuesettings you can provide anyEnvironment variablesaccepted by the Amazon SQS spooler. For more information, see theAmazon SQS spooler reference.Select theGCP Credentialsfor your Google Pub/Sub spooler and configure the following Google Pub/Sub fields:FieldDescriptionPub/Sub projectSelect the Pub/Sub project used by the spooler.Pub/Sub topicSelect the Pub/Sub topic used by the spooler; this should be the topic name within the project, not the fully qualified topic name path that includes the project ID.Pub/Sub subscriptionSelect the Pub/Sub subscription name of the subscription used by the spooler.Pub/Sub acknowledgment deadline(Optional) Enter the amount of time (in seconds) for subscribers to process and acknowledge messages in the queue.After you configure theQueuesettings you can provide anyEnvironment variablesaccepted by the Google Pub/Sub spooler. For more information, see theGoogle Cloud Pub/Sub spooler reference.Select the Azure Service PrincipalCredentialsfor your Azure Event Hubs spooler and configure theAzure SubscriptionandAzure Resource Groupfields accessible using the providedCredentials:Azure Service Principal credentials requiredDataRobot management of Scoring Code in AzureML requires existing Azure Service PrincipalCredentials. If you don't have existing credentials, theAzure Service Principal credentials requiredalert appears, directing you toGo to Credentialstocreate Azure Service Principal credentials.To create the required credentials, forCredential type, selectAzure Service Principal. Then, enter aClient ID,Client Secret,Azure Tenant ID, and aDisplay name. To validate and save the credentials, clickSave and sign in.You can find these IDs and the display name on Azure'sApp registrations > Overviewtab (1). You can generate secrets on theApp registration > Certificates and secretstab(2):Next, configure the following Azure Event Hubs fields:FieldDescriptionEvent Hubs NamespaceSelect a validEvent Hubs namespaceretrieved from the Azure Subscription ID.Event Hub InstanceSelect anEvent Hubs instancewithin your namespace for monitoring data.After you configure theQueuesettings, you can provide anyEnvironment variablesaccepted by the Azure Event Hubs spooler. For more information, see theAzure Event Hubs spooler reference.
6. Once you configure the environment settings, clickAdd environment. The environment is now available from thePrediction Environmentspage.

## Manage an agent-monitored prediction environment

When you add a prediction environment with monitoring settings configured, you can view the health and status of that prediction environment, edit the queue settings, and stop or start the agent. On the Deployments > Prediction Environments tab, locate the agent-monitored and managed environment. From the prediction environment inventory, you can view the Name, Platform, Added On date, Created By date, and Health. You can also edit, share, and delete prediction environments. For more information, see the [Manage prediction environments](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/prediction-env/pred-env-manage.html) documentation.

> [!TIP] Copy prediction environment ID
> From the upper-left corner of either tab in a prediction environment, you can click the copy icon () to copy the Prediction Environment ID.

From the Details tab, you can edit the prediction environment Name, Description, Platform, Supported model formats, Managed by setting, and associated Service Account. In the Usages section, you can view and access deployments associated with the environment:

> [!NOTE] Deployment links
> Deployment links are only provided for deployments you have access to.

From the Monitoring tab, you can edit the Settings configured when creating the environment to modify the connection between the monitoring agent and the spooler. The agent Status must be inactive to edit these settings:

From the Monitoring Agent section, you can view agent status information, enable or disable the agent, view prediction records, and view or download logs:

---
