Reputation: 4941
I have a search expression that looks like this:
stats = cloudwatch.get_metric_data(
MetricDataQueries=[
{
"Id":'m1',
'Expression': "SEARCH('{ABC/HEARTBEAT,Client_Email, Clinic_Id, NodeName} MetricName=\"PING_PONG\" Clinic_Id = 7667', 'Average', 864000)",
'ReturnData': True,
},
],
StartTime=Util.utcnow() - timedelta(hours=2),
EndTime=Util.utcnow(),
)
It returns:
{
"Messages": [],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "2f33cc09-61ff-40b0-9d28-72c4d949b2f0",
"HTTPHeaders": {
"x-amzn-requestid": "2f33cc09-61ff-40b0-9d28-72c4d949b2f0",
"date": "Fri, 06 Dec 2019 22:47:25 GMT",
"content-length": "928",
"content-type": "text/xml"
}
},
"MetricDataResults": [
{
"Timestamps": [
"2019-12-06 20:47:00+00:00"
],
"StatusCode": "Complete",
"Values": [
1
],
"Id": "m1",
"Label": "[email protected]"
},
{
"Timestamps": [
"2019-12-06 20:47:00+00:00"
],
"StatusCode": "Complete",
"Values": [
1
],
"Id": "m1",
"Label": "[email protected]"
}
]
}
I need to get value of Client_Email
, NodeName
for the metrics that have Clinic_Id = 7667
Currently, I get Client_Email as Label (Not sure why) but I need both Client_Email
and NodeName
Update:
u'MetricDataResults looks like this for me:
u'MetricDataResults': [{u'Timestamps': [], u'StatusCode': 'Complete', u'Values': [], u'Id': 'm1', u'Label': 'abc'}, {u'Timestamps': [], u'StatusCode': 'Complete', u'Values': [], u'Id': 'm1', u'Label': 'abc2'}]
Why do I have empty array in Timestamps and Values?
Upvotes: 0
Views: 1984
Reputation: 12109
Label is the only place in the response where this value could be.
I suspect you only have 1 distinct value for NodeName
and that is why the label contains only the Client_Email
. If you had more combinations of emails and node, they would show in the label, separated by space.
If you're not interested in the values of the metrics, but only in the values of dimensions, you could use list-metrics
API, like this for example:
response = cloudwatch.list_metrics(
Namespace='ABC/HEARTBEAT',
MetricName='PING_PONG',
Dimensions=[
{
'Name': 'Clinic_Id',
'Value': '7667'
},
],
)
Upvotes: 1