I want all unique “Metric” for given “Service_host” in particular “Metric_Time” range

{
	"_id" : ObjectId("6294b9d51093daae951e1803"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "builtin:service.waitTime",
	"Metric_Time" : 1653913980000,
	"Metric_Value" : 2358371,
	"Time" : ISODate("2022-05-30T18:03:00.000+05:30")
},

/* 4 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e1802"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "builtin:service.waitTime",
	"Metric_Time" : 1653913920000,
	"Metric_Value" : 1024414,
	"Time" : ISODate("2022-05-30T18:02:00.000+05:30")
},

/* 5 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e1801"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "builtin:service.waitTime",
	"Metric_Time" : 1653913860000,
	"Metric_Value" : 711079,
	"Time" : ISODate("2022-05-30T18:01:00.000+05:30")
},

/* 6 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e1800"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "builtin:service.waitTime",
	"Metric_Time" : 1653913800000,
	"Metric_Value" : 1427719,
	"Time" : ISODate("2022-05-30T18:00:00.000+05:30")
},

/* 7 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e17ff"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "iowaitTime",
	"Metric_Time" : 1653913740000,
	"Metric_Value" : 568758,
	"Time" : ISODate("2022-05-30T17:59:00.000+05:30")
},

/* 8 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e17fe"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "memory",
	"Metric_Time" : 1653913680000,
	"Metric_Value" : 809901,
	"Time" : ISODate("2022-05-30T17:58:00.000+05:30")
},

/* 9 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e17fd"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "network",
	"Metric_Time" : 1653913620000,
	"Metric_Value" : 1128014,
	"Time" : ISODate("2022-05-30T17:57:00.000+05:30")
},

/* 10 createdAt:30/05/2022, 18:04:29*/
{
	"_id" : ObjectId("6294b9d51093daae951e17fc"),
	"Source" : "Dynatrace",
	"Service_Host" : "SERVICE-4796458781",
	"Metric" : "waitTime",
	"Metric_Time" : 1653913560000,
	"Metric_Value" : 1580566,
	"Time" : ISODate("2022-05-30T17:56:00.000+05:30")
}

sir/mam

i want all unique “Metric” for given “Service_host” in particular “Metric_Time” range
can i get query for that

please send solution if possible

Hi @Pramod_Bhat1 - Welcome to the community.

i want all unique “Metric” for given “Service_host” in particular “Metric_Time” range

I’m not entirely sure this will get you the desired output but based off the above, you can possibly think about using the following in an aggregation pipeline:

  1. $match for the "Service_host" and range for "Metric_Time"
  2. $group for unique "Metric"

If you require further assistance, can you provide the following information.

  1. MongoDB version in use
  2. The expected / desired output

Regards,
Jason