MongoDB Log

Writes log data to a MongoDB collection.

Database · MongoDB

Details

IDMongoDB Log
ProviderMongoDB Inc.
CategoryDatabase
From Version5.0.0
Docker Imagedemisto/py3-tools:1.0.0.114656
Supported ModulesAgentix XSIAM

README

Overview


Writes log data to a MongoDB collection.
This integration was integrated and tested with version v4.2.3 of MongoDB.

The account user must have appropriate permissions - root role to execute the API calls.

Use Cases


  1. Write to MongoDB Log collection.
  2. Read from MongoDB log collection.
  3. Get the number of log entries.

Configure MongoDB Log on Demisto


  1. Navigate to Settings > Integrations > Servers & Services.
  2. Search for MongoDB Log.
  3. Click Add instance to create and configure a new integration instance.
    • Name: a textual name for the integration instance.
    • MongoDB Username
    • URI (mongodb://IP/FQDN:Port Number)
    • Database Name
    • Collection Name
    • Trust any certificate (not secure)
    • Use SSL/TLS secured connection
  4. Click Test to validate the URLs, token, and connection.

Commands


You can execute these commands from the Demisto CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

  1. mongodb-read-log
  2. mongodb-write-log
  3. mongodb-logs-number

1. mongodb-read-log


Returns all log entries.

Base Command

mongodb-read-log

Input
Argument Name Description Required
limit The maximum number of logs to return. Optional
Context Output

There is no context output for this command.

Command Example

!mongodb-read-log limit=5

Human Readable Output

The log documents/records for collection “log”

log
{‘name’: ‘Midhuna’, ‘age’: 23, ‘cars’: [‘BMW 320d’, ‘Audi R8’], ‘place’: ‘Amaravati’},{‘timestamp’: ‘2020-03-22T18:57:33+00:00’, ‘entity’: ‘test’, ‘playbook’: ‘my playbook’, ‘action’: ‘create’, ‘analyst’: ‘admin’},{‘test’: ‘value’},{‘123’: {‘modified’: ‘2020-03-22T19:14:29+00:00’, ‘key’: ‘test’, ‘value’: ‘123’}},{‘timestamp’: ‘2020-03-23T10:45:39+00:00’, ‘entity’: ‘{test: demisto}’, ‘playbook’: ‘mongodb’, ‘action’: ‘create’, ‘analyst’: ‘admin’}

2. mongodb-write-log


Adds a log entry.

Base Command

mongodb-write-log

Input
Argument Name Description Required
playbook The playbook that was used. Optional
user The assigned user. Optional
id Entity to write to the log. Optional
action The actions that were performed. Optional
message Message for the entry. Optional
Context Output
Path Type Description
MongoDB.Entry.Action String The actions that were performed.
MongoDB.Entry.User String Assigned analyst.
MongoDB.Entry.ID String Entity to write to the log.
MongoDB.Entry.EntryID String Entry ID.
MongoDB.Entry.Playbook String The playbook that was used.
MongoDB.Entry.Timestamp Date Entry timestamp.
MongoDB.Entry.Message String The message of the entry.
Command Example

!mongodb-write-log action=create message="This is a test message"

Context Example
{
    "MongoDB.Entry": {
        "Timestamp": "2020-04-12T07:59:43+00:00", 
        "EntryID": "5e92ca6f8f55e45510637880", 
        "Playbook": null, 
        "Action": "create", 
        "Message": "This is a test message", 
        "ID": "6e1807d3-b0ae-40a0-8e82-dad33539c587", 
        "User": null
    }
}
Human Readable Output

MongoDB Log - 1 document/record added

3. mongodb-logs-number


Returns the number of log entries.

Base Command

mongodb-logs-number

Input

There are no input arguments for this command.

Context Output

There is no context output for this command.

Command Example

!mongodb-logs-number

Human Readable Output

The count of log documents/records is 56

Configuration parameters

  • credentials — MongoDB Username (required)
  • uri — URI (mongodb://<IP/FQDN>:<Port Number>) (required)
  • database — Database Name (required)
  • collection — Collection Name (required)
  • insecure — Trust any certificate (not secure)
  • use_ssl — Use SSL/TLS secured connection

Commands (3)

  • mongodb-logs-number

    Returns the number of log entries.

  • mongodb-read-log

    Returns all log entries.

  • mongodb-write-log

    Adds a log entry.

category: Database
provider: MongoDB Inc.
fromversion: 5.0.0
commonfields:
  id: MongoDB Log
  version: -1
configuration:
- display: MongoDB Username
  name: credentials
  required: true
  type: 9
- display: URI (mongodb://<IP/FQDN>:<Port Number>)
  name: uri
  required: true
  type: 0
- display: Database Name
  name: database
  required: true
  type: 0
- defaultvalue: log
  display: Collection Name
  name: collection
  required: true
  type: 0
- display: Trust any certificate (not secure)
  name: insecure
  type: 8
  required: false
- defaultvalue: 'false'
  display: Use SSL/TLS secured connection
  name: use_ssl
  type: 8
  required: false
description: Writes log data to a MongoDB collection.
display: MongoDB Log
name: MongoDB Log
script:
  commands:
  - arguments:
    - defaultValue: '50'
      description: The maximum number of logs to return.
      name: limit
    description: Returns all log entries.
    name: mongodb-read-log
  - arguments:
    - description: The playbook that was used.
      name: playbook
    - description: The assigned user.
      name: user
    - description: Entity to write to the log.
      name: id
    - description: The actions that were performed.
      name: action
    - description: Message for the entry.
      name: message
    description: Adds a log entry.
    name: mongodb-write-log
    outputs:
    - contextPath: MongoDB.Entry.Action
      description: The actions that were performed.
      type: String
    - contextPath: MongoDB.Entry.User
      description: Assigned analyst.
      type: String
    - contextPath: MongoDB.Entry.ID
      description: Entity to write to the log.
      type: String
    - contextPath: MongoDB.Entry.EntryID
      description: Entry ID.
      type: String
    - contextPath: MongoDB.Entry.Playbook
      description: The playbook that was used.
      type: String
    - contextPath: MongoDB.Entry.Timestamp
      description: Entry timestamp.
      type: Date
    - contextPath: MongoDB.Entry.Message
      description: The message of the entry.
      type: String
  - description: Returns the number of log entries.
    name: mongodb-logs-number
  dockerimage: demisto/py3-tools:1.0.0.114656
  runonce: true
  script: '-'
  type: python
  subtype: python3
tests:
- MongoDBLog - Test