I am trying to get files_total and dfs_capacity_used metrics for last 1 week with code shared in https://cloudera.github.io/cm_api/docs/python-client/
import time
import datetime
from_time = datetime.datetime.fromtimestamp(time.time() - 1800)
to_time = datetime.datetime.fromtimestamp(time.time())
query = "select files_total, dfs_capacity_used " \
"where serviceName = HDFS-1 " \
" and category = SERVICE"
result = api.query_timeseries(query, from_time, to_time)
ts_list = result[0]
for ts in ts_list.timeSeries:
print "--- %s: %s ---" % (ts.metadata.entityName, ts.metadata.metricName)
for point in ts.data:
print "%s:\t%s" % (point.timestamp.isoformat(), point.value)
I am getting the output. But the Data Granuality is showing on daily basis. Is there a way to get the output every 6 hours like the option in snapshot shared from Cloudera UI as below,