Boto unable to fetch ElasticSearch Cloudwatch metrics -


i trying elasticsearch cloud-watch metrics using boto whatever do, not value. below snippet of code , same code works example if use rds metrics.

import datetime import boto.ec2.cloudwatch  end = datetime.datetime.utcnow() start = end - datetime.timedelta(minutes=5)  metric="cpuutilization"  region = boto.regioninfo.regioninfo(     name='ap-southeast-1',     endpoint='monitoring.ap-southeast-1.amazonaws.com')  conn = boto.ec2.cloudwatch.cloudwatchconnection(region=region)  data = conn.get_metric_statistics(60, start, end, metric, "aws/es", "average", {"domainname": "my-es-name"}) 

print data

[]

however if change namespace rds works fine proper dimension value. simple code can write. not sure wrong here. can me figure out this?

what doing wrong here?

thanks

i having same issue, , lost few hours trying figure out, managed find solution.

to pull elasticsearch metrics specific domain name, need indicate clientid in dimensions.

my examples below in boto3, executing code (boto2), believe need amend dimensions follow, assuming syntax right.:

data = conn.get_metric_statistics(60, start, end, metric, "aws/es", "average", {"clientid":"my-client-id", "domainname": "my-es-name"}) 

try code below (boto3). worked me.

import boto3 datetime import datetime, timedelta  cloudwatch = boto3.resource('cloudwatch', region_name='ap-southeast-1') cpu = cloudwatch.metric('aws/es', 'cpuutilization')  cpu_usage = cpu.get_statistics(     dimensions=[         {'name': 'clientid', 'value': 'your-client-id'},         {'name': 'domainname', 'value': 'your-domain-name'}     ],     starttime=(datetime.utcnow() - timedelta(minutes=5)).isoformat(),     endtime=datetime.utcnow().isoformat(),     period=60,     statistics=['average'] ) 

if prefer use client, use following instead:

client = boto3.client('cloudwatch', region_name='ap-southeast-1') response = client.get_metric_statistics(     namespace='aws/es',     metricname='cpuutilization',     dimensions=[         {'name': 'clientid', 'value': 'your-client-id'},         {'name': 'domainname', 'value': 'your-domain-name'}     ],     starttime=(datetime.utcnow() - timedelta(minutes=5)).isoformat(),     endtime=datetime.utcnow().isoformat(),     period=60,     statistics=['average'] ) 

please accept answer if works :-)


Comments

Post a Comment

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -