From e021c931dd8651369cd5f3ecba4ecc47ddd1d7a5 Mon Sep 17 00:00:00 2001 From: Yann Mahe Date: Wed, 20 May 2015 11:56:23 -0400 Subject: [PATCH] Datadogpy metric query support --- code_snippets/api-query.py | 3 +- content/api/index.html | 90 +++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/code_snippets/api-query.py b/code_snippets/api-query.py index dc6db76e269f1..071bab7bc198a 100644 --- a/code_snippets/api-query.py +++ b/code_snippets/api-query.py @@ -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 diff --git a/content/api/index.html b/content/api/index.html index 922bbcc8e39d0..0ddfc5757dbf3 100644 --- a/content/api/index.html +++ b/content/api/index.html @@ -31,7 +31,6 @@

<%= @item[:title] %>

Hosts Tags Search - Query Comments Users Graphs @@ -147,8 +146,17 @@

Metrics

<%= left_side_div %>

- 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: +

+ +

+ 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. +

+

+ 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.

@@ -171,7 +179,7 @@
Arguments
[[POSIX_timestamp, numeric_value], ...] Note that the timestamp must be current. - + but fin <%= 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 @@
Example Request
<% end %> +

Query time series points

+
+ <%= left_side_div %> +

+ This end point allows you to query for metrics from any time period. +

+ +
Arguments
+ +
Query Language
+

+ Any query used for a graph can be used here. See here 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. +

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

Query

-
- <%= left_side_div %> -

- This end point allows you to query for metrics from any time period. -

-

- 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. -

-

- 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. -

-
Arguments
- -
Query Language
-

- Any query used for a graph can be used here. See here 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. -

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