MongoDB agent

Prerequisites

  • For prerequisite checks for agent installation, see Prerequisite checks for agent installation.
  • URL/IP of the SixthSense collector (your tenant URL, which will be provided by Customer Support).
  • Access token from the SixthSense portal. For accessing the token, see Accessing your Access Token under Getting started with the Observability Portal.
  • MongoDB agent version "latest".
  • Package token to download agent (provided by the onboarding team).
  • For information about supported agent versions and framework, see Supported agents.

Downloading the agent version 4.4.0 (latest)

For Windows and Linux based servers, use the following link.

curl --header "PRIVATE-TOKEN:<TOKEN>" --output meter-agent.zip "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/32/packages/generic/Meter-Agent/v4.4.0/meter-agent.zip"

Configuring the MongoDB agent

Create a config.yaml file in the same directory.

sixthsense-mongodb-agent can be configured via yaml or environment variables. Following is the yaml file for configuring.

note

Environment variables are given higher priority over yaml file

# Following are the environment variables that can be set:
# ENV VARIABLE CORRESPONDS TO
# SS_SERVICE_NAME service_name
# SS_AUTHENTICATION authentication
# SS_BACKEND sixthsense_backend
# SS_LOGGING logging
# SS_SECURE secure
sixthsense:
service_name: <service_name>
# Login to Sixthsense UI --> Go to Settings on Side Navbar --> Copy Access Token
authentication: <auth_token>
# debug|error|info
logging: debug
sixthsense_backend: <collector_url>
# SSL connection with backend true|false
secure: true
# MY | ES | MS | CB | OR
type: MG
database: admin
mongoDB:
uri: mongodb://localhost:3000
queryLimit: 25 #no of queries
queryThresholdTime: 200 #millisecond
queryTimeOut: 10 #seconds
# log file path
# logPath: logs/logs.log

Use the following command to start Log operation for storing slow queries in “system.profile” with threshold time 0 =>

db.setProfilingLevel(2, { slowms: 0 });

System.Profile:

The system.profile collection is used to log detailed information about database operations, including their execution time, query patterns, and resource usage. It is primarily used for performance monitoring and debugging.

Profiling Levels:

MongoDB provides three profiling levels that determine what kind of operations are logged in the system.profile collection: 0 (Off): Profiling is disabled (default setting). No operations are logged. 1 (Slow Operations): Only operations that take longer than a specified threshold (in milliseconds) are logged. The threshold is set using the slowms parameter. 2 (All Operations): All operations are logged, regardless of their execution time.

Running the agent

For Linux:

Use the following command to run the agent.

./meter-agent ss-mongodb-config.yaml
ss-mongodb-config1.yaml...

Checking the Checksum of Build

  1. Create sha256 on windows agent shasum -a 256 meter-agent.zip

Result: "a681f82afc748e87638189389d59249880faffd31c962543855ebaddff60d38b meter-agent.zip"

  1. Add into file to compare later echo "a681f82afc748e87638189389d59249880faffd31c962543855ebaddff60d38b meter-agent.zip" > meter-agent.zip.sha256

Result: file will be added meter-agent.zip.sha256

  1. Match agent file checksum shasum -a 256 -c meter-agent.zip.sha256

Result: meter-agent.zip: OK

For Windows:

  1. Extract meter-agent.zip file and edit the configuration in the yaml file with cluster information.

  2. Open the command prompt with run as Administrator and enter the following command:

    nssm.exe install “Service_Name”

  3. In the NSSM service installer screen, the Application tab is selected by default.

  4. Enter the following details:

  • Path: meter-agent.exe full path
  • Startup directory: folder path
  • Arguments: yaml full name
  1. Click the Details tab.
  2. Enter the following details:
  • Display name: service display name
  • Description: service description
  • Setup type: select type for setup such as automatic.
  1. Click the Log on tab.
  2. Select Local System account radio button.
  3. Select Allow service to interact with desktop check box.
  4. Click Install service.