MongoDB Atlas JSON file import not providing an index

15 views Asked by At

I am trying to import this JSON file into a existing MongoDB Atlas collection:

{
    "hostname1": {
        "Port 80": {
            "Protocol": "tcp",
            "State": "",
            "Service": "open"
        },
        "Port 443": {
            "Protocol": "tcp",
            "State": "open",
            "Service": ""
        }
    },
    "hostname2": {
        "Port 80": {
            "Protocol": "tcp",
            "State": "",
            "Service": "open"
        },
        "Port 443": {
            "Protocol": "tcp",
            "State": "open",
            "Service": ""
        }
    },
    "hostname3": {
        "Port 80": {
            "Protocol": "tcp",
            "State": "",
            "Service": "open"
        },
        "Port 443": {
            "Protocol": "tcp",
            "State": "open",
            "Service": ""
        }
    },
    "hostname4": {
        "Port 80": {
            "Protocol": "tcp",
            "State": "",
            "Service": "open"
        },
        "Port 443": {
            "Protocol": "tcp",
            "State": "open",
            "Service": ""
        }
    }
}

The file gets imported, but for some reason without the hostnames. Here is what the structure of the collection looks like:

{
  "_id": {
    "$oid": "64345263495f463da1b28bbe"
  },
  "Port 80": {
    "Protocol": "tcp",
    "State": "",
    "Service": "open"
  },
  "Port 443": {
    "Protocol": "tcp",
    "State": "open",
    "Service": ""
  }
},
{
  "_id": {
    "$oid": "64345263495f463da1b28bbd"
  },
  "Port 80": {
    "Protocol": "tcp",
    "State": "",
    "Service": "open"
  },
  "Port 443": {
    "Protocol": "tcp",
    "State": "open",
    "Service": ""
  }
}

I am hoping for it to have the hostname where the id field is placed.

I have tried changing the structure to the JSON file. I have also tried making the nmap output as a CSV file, and nothing works as close as this format/structure does.

0

There are 0 answers