0

I'm trying to

  1. Calculate sum of 'timeTakenUsecs' value group by 'jobName'
  2. then return the jobName with the lowest 'sum of timeTakenUsecs value' => trying to keep this as variable

I tried so many methods using selectattr and json_query and many others but seems no luck...

below is the json data

{
    "changed": false,
    "cluster": {
        "protection": {
            "runs": [
                {
                    "backupRun": {
                        "environment": "kVMware",
                        "jobRunId": 615326,
                        "metadataDeleted": false,
                        "quiesced": false,
                        "runType": "kRegular",
                        "slaViolated": false,
                        "snapshotsDeleted": false,
                        "sourceBackupStatus": [
                            {
                                "attemptNum": 1,
                                "currentSnapshotInfo": {
                                    "environment": "kVMware",
                                    "relativeSnapshotDirectory": "vCenter-20E09E1A-40EB-4F8B-9A86-81D9272526B6/vm-502a4fcb-50c7-8e2e-67f5-92375074fd8c/470137-615326-1",
                                    "rootPath": "/SD_T01_DKDC3_EIT_DD_CY_FT2D2N_EC42/magneto_4862007320680876_1629474475873_470137/fs",
                                    "totalBytesReadFromSource": 380370944,
                                    "totalBytesToReadFromSource": 380370944,
                                    "totalPrimaryPhysicalSizeBytes": 90194313216,
                                    "viewName": "magneto_4862007320680876_1629474475873_470137"
                                },
                                "isFullBackup": false,
                                "numRestarts": 0,
                                "parentSourceId": 218,
                                "progressMonitorTaskPath": "backup_615326_1/task_615327",
                                "quiesced": false,
                                "slaViolated": false,
                                "source": {
                                    "environment": "kVMware",
                                    "id": 1740,
                                    "name": "OSI9552",
                                    "parentId": 218,
                                    "vmWareProtectionSource": {
                                        "connectionState": "kConnected",
                                        "hostType": "kLinux",
                                        "id": {
                                            "morItem": "vm-82133",
                                            "morType": "VirtualMachine",
                                            "uuid": "502a4fcb-50c7-8e2e-67f5-92375074fd8c"
                                        },
                                        "name": "OSI9552",
                                        "toolsRunningStatus": "kGuestToolsRunning",
                                        "type": "kVirtualMachine",
                                        "version": "vmx-15",
                                        "virtualDisks": [
                                            {
                                                "busNumber": 0,
                                                "controllerType": "SCSI",
                                                "filename": "[T1_T_CLU_DCE4_VSAN_01] 52da0964-5eff-10e5-c450-00451d690956/OSI9552.vmdk",
                                                "logicalSizeBytes": 68719476736,
                                                "unitNumber": 0
                                            },
                                            {
                                                "busNumber": 0,
                                                "controllerType": "SCSI",
                                                "filename": "[T1_T_CLU_DCE4_VSAN_01] 52da0964-5eff-10e5-c450-00451d690956/OSI9552_1.vmdk",
                                                "logicalSizeBytes": 21474836480,
                                                "unitNumber": 1
                                            }
                                        ]
                                    }
                                },
                                "stats": {
                                    "QueueDurationUsecs": 3000761,
                                    "admittedTimeUsecs": 1684267200340407,
                                    "permitGrantTimeUsecs": 1684267203341168,
                                    "timeTakenUsecs": 45008942,
                                    "totalBytesReadFromSource": 380370944,
                                    "totalBytesToReadFromSource": 380370944,
                                    "totalLogicalBackupSizeBytes": 90194313216,
                                    "totalPhysicalBackupSizeBytes": 41092470,
                                    "totalSourceSizeBytes": 90194313216
                                },
                                "status": "kSuccess"
                            }
                        ],
                        "stats": {
                            "QueueDurationUsecs": null,
                            "endTimeUsecs": 1684267245349349,
                            "numCanceledTasks": 0,
                            "numCancelledAppObjects": 0,
                            "numFailedAppObjects": 0,
                            "numFailedTasks": 0,
                            "numSuccessfulAppObjects": 0,
                            "numSuccessfulTasks": 1,
                            "startTimeUsecs": 1684267200340407,
                            "totalBytesReadFromSource": 380370944,
                            "totalLogicalBackupSizeBytes": 90194313216,
                            "totalPhysicalBackupSizeBytes": 41092470,
                            "totalSourceSizeBytes": 90194313216
                        },
                        "status": "kSuccess",
                        "wormRetentionType": "kNone"
                    },
                    "copyRun": [
                        {
                            "expiryTimeUsecs": 1686686446349453,
                            "runStartTimeUsecs": 1684267200340407,
                            "status": "kSuccess",
                            "target": {
                                "type": "kLocal"
                            },
                            "taskUid": {
                                "clusterId": 4862007320680876,
                                "clusterIncarnationId": 1629474475873,
                                "id": 5710863302
                            }
                        }
                    ],
                    "jobId": 470137,
                    "jobName": "JT_EIT_N_DL_DCE3_LNX-VM-T_CLU_DCE4_VSAN_01_B_REOK_WSBW-01",
                    "jobUid": {
                        "clusterId": 4862007320680876,
                        "clusterIncarnationId": 1629474475873,
                        "id": 470137
                    },
                    "viewBoxId": 27
                },
                {
                    "backupRun": {
                        "environment": "kAzureNative",
                        "jobRunId": 615346,
                        "metadataDeleted": false,
                        "quiesced": false,
                        "runType": "kRegular",
                        "slaViolated": false,
                        "snapshotsDeleted": false,
                        "sourceBackupStatus": [
                            {
                                "attemptNum": 1,
                                "currentSnapshotInfo": {
                                    "environment": "kAzureNative",
                                    "relativeSnapshotDirectory": "azure-c2ade422-2012-487c-afb4-98187adf047a/vm-weu-7322bf2e1b8b8190b30a433be54bcbc0-test-rg01-OSI9565/454541-615346-1",
                                    "rootPath": "/SD_T01_DKDC3_EIT_DD_CY_FT2D2N_EC42/magneto_4862007320680876_1629474475873_454541/fs",
                                    "totalBytesReadFromSource": 2871414784,
                                    "totalBytesToReadFromSource": 2871414784,
                                    "totalPrimaryPhysicalSizeBytes": 243741491200,
                                    "viewName": "magneto_4862007320680876_1629474475873_454541"
                                },
                                "isFullBackup": false,
                                "numRestarts": 0,
                                "parentSourceId": 958,
                                "progressMonitorTaskPath": "backup_615346_1/task_615349",
                                "quiesced": false,
                                "slaViolated": false,
                                "source": {
                                    "azureProtectionSource": {
                                        "hostType": "kWindows",
                                        "ipAddresses": [
                                            "10.56.20.5"
                                        ],
                                        "isManagedVm": true,
                                        "physicalSourceId": 957,
                                        "resourceId": "/subscriptions/c2ade422-2012-487c-afb4-98187adf047a/resourceGroups/weu-7322bf2e1b8b8190b30a433be54bcbc0-test-rg01/providers/Microsoft.Compute/virtualMachines/OSI95654147f87e-89f7-4ba7-a932-4b52ab21ebde",
                                        "tagAttributes": [
                                            {
                                                "id": 963,
                                                "name": "App-ID#~#11913",
                                                "uuid": "App-ID#~#11913"
                                            },
                                            {
                                                "id": 964,
                                                "name": "applName#~#Cohesity Backup CDM EIT TEST",
                                                "uuid": "applName#~#Cohesity Backup CDM EIT TEST"
                                            }
                                        ],
                                        "type": "kVirtualMachine"
                                    },
                                    "environment": "kAzure",
                                    "id": 966,
                                    "name": "OSI9565",
                                    "parentId": 958
                                },
                                "stats": {
                                    "QueueDurationUsecs": 3000608,
                                    "admittedTimeUsecs": 1684270800918354,
                                    "endTimeUsecs": 1684271043958028,
                                    "permitGrantTimeUsecs": 1684270803918962,
                                    "startTimeUsecs": 1684270800918354,
                                    "timeTakenUsecs": 243039674,
                                    "totalBytesReadFromSource": 2871414784,
                                    "totalBytesToReadFromSource": 2871414784,
                                    "totalLogicalBackupSizeBytes": 243741491200,
                                    "totalPhysicalBackupSizeBytes": 698935065,
                                    "totalSourceSizeBytes": 243739394048
                                },
                                "status": "kSuccess"
                            }
                        ],
                        "stats": {
                            "QueueDurationUsecs": null,
                            "endTimeUsecs": 1684271043958028,
                            "numCanceledTasks": 0,
                            "numCancelledAppObjects": 0,
                            "numFailedAppObjects": 0,
                            "numFailedTasks": 0,
                            "numSuccessfulAppObjects": 0,
                            "numSuccessfulTasks": 1,
                            "startTimeUsecs": 1684270800918354,
                            "totalBytesReadFromSource": 2871414784,
                            "totalLogicalBackupSizeBytes": 243741491200,
                            "totalPhysicalBackupSizeBytes": 698935065,
                            "totalSourceSizeBytes": 243739394048
                        },
                        "status": "kSuccess",
                        "wormRetentionType": "kNone"
                    },
                    "copyRun": [
                        {
                            "expiryTimeUsecs": 1686690246958153,
                            "runStartTimeUsecs": 1684270800918354,
                            "status": "kSuccess",
                            "target": {
                                "type": "kLocal"
                            },
                            "taskUid": {
                                "clusterId": 4862007320680876,
                                "clusterIncarnationId": 1629474475873,
                                "id": 5710886000
                            }
                        }
                    ],
                    "jobId": 454541,
                    "jobName": "JT_EIT_N_AZ-WIN_VM_NATIVE_OSI9565_B_REOK_WSBW-01",
                    "jobUid": {
                        "clusterId": 4862007320680876,
                        "clusterIncarnationId": 1629474475873,
                        "id": 454541
                    },
                    "viewBoxId": 27
                },

Can you guide me from scratch?

  • 2
    Please read [ask] and pay attention to the [mre] section. More specifically, [edit] your question and add the example code you've tried as well as the result you got and explain how it differs from what is expected. Also please make sure your example data is valid, complete and teared down to the minimum to understand your problem. Good luck – Zeitounator May 22 '23 at 05:16

0 Answers0