Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datadogpy metric query support #406

Merged
merged 1 commit into from
May 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions code_snippets/api-query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
from datadog import initialize, api
from datadog.api.base import HTTPClient
import time

options = {
@@ -15,5 +14,5 @@
# query for idle CPU for all machines tagged with speed:4000
query = 'system.cpu.idle{*}by{host}'

results = HTTPClient.request('GET', '/query', **{'from': start, 'to': end, 'query': query})
results = api.Metric.query(start=start - 3600, end=end, query=query)
print results
90 changes: 44 additions & 46 deletions content/api/index.html
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@ <h1><%= @item[:title] %> </h1>
<a class="btn" href="#hosts">Hosts</a>
<a class="btn" href="#tags">Tags</a>
<a class="btn" href="#search">Search</a>
<a class="btn" href="#query">Query</a>
<a class="btn" href="#comments">Comments</a>
<a class="btn" href="#users">Users</a>
<a class="btn" href="#graphs">Graphs</a>
@@ -147,8 +146,17 @@ <h3 id="metrics">Metrics</h3>
<div class="row-fluid">
<%= left_side_div %>
<p>
The metrics end-point allows you to post metrics data so it can
be graphed on Datadog's dashboards.
The metrics end-point allows you to:
</p>
<ul>
<li>Post metrics data so it can be graphed on Datadog's dashboards</li>
<li>Query metrics from any time period</li>
</ul>
<p>
As occurs within the Datadog UI, a graph can only contain a set number of points and as the timeframe over which a metric is viewed increases, aggregation between points will occur to stay below that set number.
</p>
<p>
Thus, if you are querying for larger timeframes of data, the points returned will be more aggregated. The max granularity within Datadog is one point per second, so if you had submitted points at that interval and requested a very small interval from the query API (in this case, probably less than 100 seconds), you could end up getting all of those points back. Otherwise, our algorithm tries to return about 150 points per any given time window, so you'll see coarser and coarser granularity as the amount of time requested increases. We do this time aggregation via averages.
</p>
</div>
</div>
@@ -171,7 +179,7 @@ <h5>Arguments</h5>
<code>[[POSIX_timestamp, numeric_value], ...]</code>
</div>
Note that the timestamp must be current.
</div>
</div>but fin
</li>
<%= argument('host', 'The name of the host that produced the metric.', :default => 'None' ) %>
<%= argument('tags', 'A list of tags associated with the metric.', :default => 'None' ) %>
@@ -190,6 +198,38 @@ <h5>Example Request</h5>
<% end %>
</div>
</div>
<h4 id="metrics-query">Query time series points</h4>
<div class="row-fluid">
<%= left_side_div %>
<p>
This end point allows you to query for metrics from any time period.
</p>

<h5>Arguments</h5>
<ul class="arguments">
<%= argument("from", "seconds since the unix epoch", :lang => 'console') %>
<%= argument("to", "seconds since the unix epoch", :lang => 'console') %>
<%= argument("start", "seconds since the unix epoch", :lang => 'python') %>
<%= argument("end", "seconds since the unix epoch", :lang => 'python') %>
<%= argument("query", "The query string") %>
</ul>
<h5>Query Language</h5>
<p>
Any query used for a graph can be used here. See <a href="/graphing/">here</a> for more details. The time between from and to should be less than 24 hours. If it is longer, you will receive points with less granularity.
</p>

</div>
<%= right_side_div %>
<h5>Signature</h5>
<code>GET https://app.datadoghq.com/api/v1/query</code>
<h5>Example Request</h5>
<%= snippet_code_block "api-query.py" %>
<%= snippet_code_block "api-query.sh" %>
<h5>Example Response</h5>
<%= snippet_result_code_block "api-query.py" %>
<%= snippet_result_code_block "api-query.sh" %>
</div>
</div>

<!--
=====================================================================
@@ -1449,48 +1489,6 @@ <h5>Example Response</h5>
</div>
</div>


<!--
=====================================================================
Query
====================================================================
-->

<h3 id="query">Query</h3>
<div class="row-fluid">
<%= left_side_div %>
<p>
This end point allows you to query for metrics from any time period.
</p>
<p>
As occurs within the Datadog UI, a graph can only contain a set number of points and as the timeframe over which a metric is viewed increases, aggregation between points will occur to stay below that set number.
</p>
<p>
Thus, if you are querying for larger timeframes of data, the points returned will be more aggregated. The max granularity within Datadog is one point per second, so if you had submitted points at that interval and requested a very small interval from the query API (in this case, probably less than 100 seconds), you could end up getting all of those points back. Otherwise, our algorithm tries to return about 150 points per any given time window, so you'll see coarser and coarser granularity as the amount of time requested increases. We do this time aggregation via averages.
</p>
<h5>Arguments</h5>
<ul class="arguments">
<%= argument("from", "seconds since the unix epoch") %>
<%= argument("to", "seconds since the unix epoch") %>
<%= argument("query", "The query string") %>
</ul>
<h5>Query Language</h5>
<p>
Any query used for a graph can be used here. See <a href="/graphing/">here</a> for more details. The time between from and to should be less than 24 hours. If it is longer, you will receive points with less granularity.
</p>

</div>
<%= right_side_div %>
<h5>Signature</h5>
<code>GET https://app.datadoghq.com/api/v1/query</code>
<h5>Example Request</h5>
<%= snippet_code_block "api-query.py" %>
<%= snippet_code_block "api-query.sh" %>
<h5>Example Response</h5>
<%= snippet_result_code_block "api-query.py" %>
<%= snippet_result_code_block "api-query.sh" %>
</div>
</div>
<!--
=====================================================================
Comments