Class: DatadogAPIClient::V1::MetricsAPI
- Inherits:
-
Object
- Object
- DatadogAPIClient::V1::MetricsAPI
- Defined in:
- lib/datadog_api_client/v1/api/metrics_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_metric_metadata(metric_name, opts = {}) ⇒ Object
Get metric metadata.
-
#get_metric_metadata_with_http_info(metric_name, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>
Get metric metadata.
-
#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ MetricsAPI
constructor
A new instance of MetricsAPI.
-
#list_active_metrics(from, opts = {}) ⇒ Object
Get active metrics list.
-
#list_active_metrics_with_http_info(from, opts = {}) ⇒ Array<(MetricsListResponse, Integer, Hash)>
Get active metrics list.
-
#list_metrics(q, opts = {}) ⇒ Object
Search metrics.
-
#list_metrics_with_http_info(q, opts = {}) ⇒ Array<(MetricSearchResponse, Integer, Hash)>
Search metrics.
-
#query_metrics(from, to, query, opts = {}) ⇒ Object
Query timeseries points.
-
#query_metrics_with_http_info(from, to, query, opts = {}) ⇒ Array<(MetricsQueryResponse, Integer, Hash)>
Query timeseries points.
-
#submit_distribution_points(body, opts = {}) ⇒ Object
Submit distribution points.
-
#submit_distribution_points_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>
Submit distribution points.
-
#submit_metrics(body, opts = {}) ⇒ Object
Submit metrics.
-
#submit_metrics_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>
Submit metrics.
-
#update_metric_metadata(metric_name, body, opts = {}) ⇒ Object
Edit metric metadata.
-
#update_metric_metadata_with_http_info(metric_name, body, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>
Edit metric metadata.
Constructor Details
#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ MetricsAPI
Returns a new instance of MetricsAPI.
22 23 24 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 22 def initialize(api_client = APIClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
20 21 22 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 20 def api_client @api_client end |
Instance Method Details
#get_metric_metadata(metric_name, opts = {}) ⇒ Object
Get metric metadata.
30 31 32 33 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 30 def (metric_name, opts = {}) data, _status_code, _headers = (metric_name, opts) data end |
#get_metric_metadata_with_http_info(metric_name, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>
Get metric metadata.
Get metadata about a specific metric.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 40 def (metric_name, opts = {}) if @api_client.config.unstable_operations.has_key?(:get_metric_metadata) unstable_enabled = @api_client.config.unstable_operations[:get_metric_metadata] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "get_metric_metadata") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_metric_metadata")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.get_metric_metadata ...' end # verify the required parameter 'metric_name' is set if @api_client.config.client_side_validation && metric_name.nil? fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.get_metric_metadata" end # resource path local_var_path = '/api/v1/metrics/{metric_name}'.sub('{' + 'metric_name' + '}', CGI.escape(metric_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'MetricMetadata' # auth_names auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth] = opts.merge( :operation => :get_metric_metadata, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#get_metric_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_active_metrics(from, opts = {}) ⇒ Object
Get active metrics list.
105 106 107 108 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 105 def list_active_metrics(from, opts = {}) data, _status_code, _headers = list_active_metrics_with_http_info(from, opts) data end |
#list_active_metrics_with_http_info(from, opts = {}) ⇒ Array<(MetricsListResponse, Integer, Hash)>
Get active metrics list.
Get the list of actively reporting metrics from a given time until now.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 117 def list_active_metrics_with_http_info(from, opts = {}) if @api_client.config.unstable_operations.has_key?(:list_active_metrics) unstable_enabled = @api_client.config.unstable_operations[:list_active_metrics] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "list_active_metrics") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_active_metrics")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_active_metrics ...' end # verify the required parameter 'from' is set if @api_client.config.client_side_validation && from.nil? fail ArgumentError, "Missing the required parameter 'from' when calling MetricsAPI.list_active_metrics" end # resource path local_var_path = '/api/v1/metrics' # query parameters query_params = opts[:query_params] || {} query_params[:'from'] = from query_params[:'host'] = opts[:'host'] if !opts[:'host'].nil? query_params[:'tag_filter'] = opts[:'tag_filter'] if !opts[:'tag_filter'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'MetricsListResponse' # auth_names auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth] = opts.merge( :operation => :list_active_metrics, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#list_active_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_metrics(q, opts = {}) ⇒ Object
Search metrics.
183 184 185 186 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 183 def list_metrics(q, opts = {}) data, _status_code, _headers = list_metrics_with_http_info(q, opts) data end |
#list_metrics_with_http_info(q, opts = {}) ⇒ Array<(MetricSearchResponse, Integer, Hash)>
Search metrics.
Search for metrics from the last 24 hours in Datadog.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 193 def list_metrics_with_http_info(q, opts = {}) if @api_client.config.unstable_operations.has_key?(:list_metrics) unstable_enabled = @api_client.config.unstable_operations[:list_metrics] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "list_metrics") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_metrics")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_metrics ...' end # verify the required parameter 'q' is set if @api_client.config.client_side_validation && q.nil? fail ArgumentError, "Missing the required parameter 'q' when calling MetricsAPI.list_metrics" end # resource path local_var_path = '/api/v1/search' # query parameters query_params = opts[:query_params] || {} query_params[:'q'] = q # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'MetricSearchResponse' # auth_names auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth] = opts.merge( :operation => :list_metrics, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#list_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#query_metrics(from, to, query, opts = {}) ⇒ Object
Query timeseries points.
259 260 261 262 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 259 def query_metrics(from, to, query, opts = {}) data, _status_code, _headers = query_metrics_with_http_info(from, to, query, opts) data end |
#query_metrics_with_http_info(from, to, query, opts = {}) ⇒ Array<(MetricsQueryResponse, Integer, Hash)>
Query timeseries points.
Query timeseries points.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 271 def query_metrics_with_http_info(from, to, query, opts = {}) if @api_client.config.unstable_operations.has_key?(:query_metrics) unstable_enabled = @api_client.config.unstable_operations[:query_metrics] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "query_metrics") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "query_metrics")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.query_metrics ...' end # verify the required parameter 'from' is set if @api_client.config.client_side_validation && from.nil? fail ArgumentError, "Missing the required parameter 'from' when calling MetricsAPI.query_metrics" end # verify the required parameter 'to' is set if @api_client.config.client_side_validation && to.nil? fail ArgumentError, "Missing the required parameter 'to' when calling MetricsAPI.query_metrics" end # verify the required parameter 'query' is set if @api_client.config.client_side_validation && query.nil? fail ArgumentError, "Missing the required parameter 'query' when calling MetricsAPI.query_metrics" end # resource path local_var_path = '/api/v1/query' # query parameters query_params = opts[:query_params] || {} query_params[:'from'] = from query_params[:'to'] = to query_params[:'query'] = query # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'MetricsQueryResponse' # auth_names auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth] = opts.merge( :operation => :query_metrics, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#query_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#submit_distribution_points(body, opts = {}) ⇒ Object
Submit distribution points.
308 309 310 311 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 308 def submit_distribution_points(body, opts = {}) data, _status_code, _headers = submit_distribution_points_with_http_info(body, opts) data end |
#submit_distribution_points_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>
Submit distribution points.
The distribution points end-point allows you to post distribution data that can be graphed on Datadog’s dashboards.
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 321 def submit_distribution_points_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.submit_distribution_points ...' end allowable_values = ['deflate'] if @api_client.config.client_side_validation && opts[:'content_encoding'] && !allowable_values.include?(opts[:'content_encoding']) fail ArgumentError, "invalid value for \"content_encoding\", must be one of #{allowable_values}" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling MetricsAPI.submit_distribution_points" end # resource path local_var_path = '/api/v1/distribution_points' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/json', 'application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['text/json']) header_params['Content-Encoding'] = opts[:'content_encoding'] if !opts[:'content_encoding'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'IntakePayloadAccepted' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth] = opts.merge( :operation => :submit_distribution_points, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type, :api_version => "V1" ) data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#submit_distribution_points\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#submit_metrics(body, opts = {}) ⇒ Object
Submit metrics.
346 347 348 349 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 346 def submit_metrics(body, opts = {}) data, _status_code, _headers = submit_metrics_with_http_info(body, opts) data end |
#submit_metrics_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>
Submit metrics.
The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards. The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:
- 64 bits for the timestamp
- 64 bits for the value
- 40 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes. However, with the DogStatsD API, compression is applied, which reduces the payload size.
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 357 def submit_metrics_with_http_info(body, opts = {}) if @api_client.config.unstable_operations.has_key?(:submit_metrics) unstable_enabled = @api_client.config.unstable_operations[:submit_metrics] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "submit_metrics") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "submit_metrics")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.submit_metrics ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling MetricsAPI.submit_metrics" end # resource path local_var_path = '/api/v1/series' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/json', 'application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['text/json']) header_params['Content-Encoding'] = opts[:'content_encoding'] if !opts[:'content_encoding'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'IntakePayloadAccepted' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth] = opts.merge( :operation => :submit_metrics, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#submit_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#update_metric_metadata(metric_name, body, opts = {}) ⇒ Object
Edit metric metadata.
424 425 426 427 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 424 def (metric_name, body, opts = {}) data, _status_code, _headers = (metric_name, body, opts) data end |
#update_metric_metadata_with_http_info(metric_name, body, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>
Edit metric metadata.
Edit metadata of a specific metric. Find out more about supported types.
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 435 def (metric_name, body, opts = {}) if @api_client.config.unstable_operations.has_key?(:update_metric_metadata) unstable_enabled = @api_client.config.unstable_operations[:update_metric_metadata] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "update_metric_metadata") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "update_metric_metadata")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.update_metric_metadata ...' end # verify the required parameter 'metric_name' is set if @api_client.config.client_side_validation && metric_name.nil? fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.update_metric_metadata" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling MetricsAPI.update_metric_metadata" end # resource path local_var_path = '/api/v1/metrics/{metric_name}'.sub('{' + 'metric_name' + '}', CGI.escape(metric_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'MetricMetadata' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] = opts.merge( :operation => :update_metric_metadata, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#update_metric_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |