Enable full-text query for logging query text for Mongo Atlas

Yana Lysenkova 20 Reputation points
2023-05-23T11:55:13.8433333+00:00

We are using Mongo DB Atlas. Our apps connect to it via Mongo's connection string.

Is it possible to enable full-text query for logging query text in Application Insights for Mongo DB Atlas queries?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,812 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VasimTamboli 4,415 Reputation points
    2023-05-23T13:13:23.7766667+00:00

    Enabling full-text query logging for MongoDB Atlas queries in Application Insights requires some configuration in both MongoDB Atlas and Application Insights. Here are the general steps to enable this feature:

    Set up Application Insights: a. Create an Application Insights resource in Azure. b. Retrieve the Instrumentation Key for your Application Insights resource.

    Configure MongoDB Atlas: a. Access your MongoDB Atlas project and navigate to the desired cluster. b. Go to the "Database Access" section and create a new database user with appropriate privileges. c. In the "Network Access" section, whitelist the IP addresses or ranges that should be allowed to connect to your MongoDB Atlas cluster.

    Configure your application: a. Modify your application's connection string to include the username, password, and other necessary details for connecting to MongoDB Atlas. b. Update your application code to integrate with Application Insights. This usually involves adding the Application Insights SDK to your application and configuring it with the Instrumentation Key obtained in step 1b.

    Enable query logging in MongoDB Atlas: a. Connect to your MongoDB Atlas cluster using a MongoDB client (e.g., MongoDB Shell, MongoDB Compass). b. Execute the following command to enable query logging:

    shellCopy code
    db.setProfilingLevel(2)
    

    Verify query logging: a. Execute some queries against your MongoDB Atlas cluster. b. Navigate to the "Logs" section in the MongoDB Atlas web interface and verify that the query text is being logged.

    By following these steps, you should be able to enable full-text query logging for MongoDB Atlas queries in Application Insights. Remember to review the MongoDB Atlas and Application Insights documentation for more detailed information on configuring and using these services.

    0 comments No comments