i need aggregate result of the below query –
if you see the Json results -
Two from “_id.sourceType”: “F5MgmtTmLtmVirtual”
And one from “_id.sourceType”: “F5MgmtTmLtmPool”
I need total of four records from this.
here we have to Unwind servers as well.
Fields in result :::
"virtual_hostname":"$_id.hostname",
"sourceType":"$_id.sourceType",
"virtual_name":"$name",
"virtual_address":"$address",
"virtual_port":"$port",
"virtual_enabled":"$servers.enabled",
"node_address":"$servers.address",
"node_name":"$servers.nodeName",
"node_port":"$servers.port",
"pool":"$pool",
After aggregation we should have four set of the above fields.
I was trying in https://mongoplayground.net/
`db.getCollection('collection).find({"_id.sourceType":"F5MgmtTmLtmPool","fullPath":"/Common/caremobile_prod_80_pool","_id.hostname":"rflukf502"}) : it gives one result.`
[
{
"_id": {
"hostname": "rflukf502",
"ipAddress": "7.191.12.19",
"name": "caremobile_prod_80_pool",
"fullPath": "/Common/caremobile_prod_80_pool",
"sourceType": "F5MgmtTmLtmPool"
},
"name": "caremobile_prod_80_pool",
"fullPath": "/Common/caremobile_prod_80_pool",
"clientMnemonic": "RFL_UK",
"servers": [
{
"nodeName": "RFLUKSODRP01",
"displayName": "RFLUKSODRP01.rfl_uk.cernuk.com",
"enabled": true,
"up": false,
"address": "104.170.243.75",
"port": "80",
"dnsA": "RFLUKSODRP01.rfl_uk.cernuk.com"
},
{
"nodeName": "RFLUKSODRP02",
"displayName": "RFLUKSODRP02.rfl_uk.cernuk.com",
"enabled": true,
"up": false,
"address": "104.170.243.76",
"port": "80",
"dnsA": "RFLUKSODRP02.rfl_uk.cernuk.com"
}
],
"lastUpdated": ISODate("2023-08-07T09:28:27.171Z"),
"_class": "com.cerner.cts.oss.nethawk.engine.business.f5VipStatus.F5ConfigPool"
},
db.getCollection('collection').find({"_id.sourceType":"F5MgmtTmLtmVirtual","_id.hostname":"rflukf502","pool":"/Common/caremobile_prod_80_pool"}) : it gives two results
{
"_id": {
"hostname": "rflukf502",
"ipAddress": "7.191.12.19",
"name": "caremobile_prod_80_vs",
"pool": "/Common/caremobile_prod_80_pool",
"sourceType": "F5MgmtTmLtmVirtual"
},
"name": "caremobile_prod_80_vs",
"address": "104.170.243.112",
"port": "80",
"pool": "/Common/caremobile_prod_80_pool",
"clientMnemonic": "RFL_UK",
"deviceGroup": [],
"policiesNames": [],
"isInternetVip": false,
"lastUpdated": ISODate("2023-08-08T09:57:07.844Z"),
"_class": "com.cerner.cts.oss.nethawk.engine.business.f5VipStatus.F5ConfigVirtual"
},
{
"_id": {
"hostname": "rflukf502",
"ipAddress": "7.191.12.19",
"name": "caremobile_prod_443_vs",
"pool": "/Common/caremobile_prod_80_pool",
"sourceType": "F5MgmtTmLtmVirtual"
},
"name": "caremobile_prod_443_vs",
"address": "104.170.243.112",
"port": "443",
"pool": "/Common/caremobile_prod_80_pool",
"clientMnemonic": "RFL_UK",
"deviceGroup": [],
"policiesNames": [],
"isInternetVip": false,
"lastUpdated": ISODate("2023-08-08T09:57:07.844Z"),
"_class": "com.cerner.cts.oss.nethawk.engine.business.f5VipStatus.F5ConfigVirtual"
}
]
Note : both the results are from same collection.