← Back to team overview

graphite-dev team mailing list archive

Re: [Question #99926]: gaps in graphs when viewing small time frames? Bug or User error?

 

Question #99926 on Graphite changed:
https://answers.launchpad.net/graphite/+question/99926

    Status: Open => Answered

chrismd proposed the following answer:
Glad to help. If you want to search or navigate the metric hierarchy
(especially when you have a clustered setup) you could do it locally on
the graphite server by using the graphite.storage module (I really need
to document this API, so here's a first stab at it).

bash$ export PYTHONPATH=/opt/graphite/webapp
bash$ export DJANGO_SETTINGS_MODULE=graphite.settings
bash$ python
>>> from django.conf import settings
>>> import time
>>> for metric in settings.STORE.find("servers.*.cpuUsage"):
...       print metric.metric_path # servers.foo.cpuUsage
...       print metric.fs_path # /opt/graphite/storage/whisper/servers/foo/cpuUsage.wsp
...       print metric.name # cpuUsage
...       print metric.isLeaf() # True, which means we can fetch() data
...       (timeInfo, values) metric.fetch(startTime, endTime) # both unix epoch times
...       (start, end, step) = timeInfo
...       t = start
...       for value in values:
...         print time.ctime(), value
...         t += step

This will work even in a clustered configuration.

If you need to lookup metrics from a remote machine however there is a
HTTP API as well. Basically you can GET
/metrics/?query=servers.*.cpuUsage&format=pickle (or format=treejson for
a JSON object that can be used by an Ext tree). Hope that helps.

-- 
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.