Class: Infrawrench::CostsAnomaliesNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.costs.anomalies

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ CostsAnomaliesNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CostsAnomaliesNamespace.

Parameters:



4724
4725
4726
# File 'lib/infrawrench/client.rb', line 4724

def initialize(transport)
  @transport = transport
end

Instance Method Details

#acknowledge(anomaly_id:, org_id: nil, body: nil, request_options: nil) ⇒ Hash

Explain a detected cost anomaly

Record what a finding actually was, and publish that sentence as a cost annotation on every chart covering the anomalous day — the point being that 'we migrated the fleet' is not a fact about whichever report somebody happened to open. The note's date (the anomalous day) and its org-wide scope are derived from the anomaly and are not the caller's to choose.

The reply is the updated anomaly, carrying acknowledgement with the id of the note it created. Sending it again replaces the sentence and rewords that note rather than filing a second one; it will not recreate a note that has since been deleted, since deleting a note is a deliberate act and the finding stays explained without it.

This does not suppress detection. If the same provider or service spikes again on a later day, that is a new anomaly and it is detected and alerted on as normal.

POST /api/org/orgId/costs/anomalies/anomalyId/acknowledge

Raises on 400: Bad request

Raises on 403: Forbidden

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • anomaly_id (String)
  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as Hash.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • anomaly_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • body: ({ "explanation" => String }, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as CostAnomaly — see sig/infrawrench/sdk.rbs.

Raises:



4761
4762
4763
4764
4765
4766
4767
4768
4769
# File 'lib/infrawrench/client.rb', line 4761

def acknowledge(anomaly_id:, org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/costs/anomalies/{anomalyId}/acknowledge",
    path_params: { "orgId" => org_id, "anomalyId" => anomaly_id },
    body: body,
    request_options: request_options
  )
end

#get(org_id: nil, days: nil, request_options: nil) ⇒ Hash

List recently detected cost anomalies

Spend anomalies detected by the daily background pass. Two kinds share the list: a spike, where a provider's or service's spend exceeded its trailing 28-day baseline by a statistical threshold (mean + N·stddev, with an absolute floor to ignore penny-scale noise), and a new_source, where a provider or service with no spend at all across that window suddenly billed a material amount. Thresholds are per organization — see GET /costs/anomaly-settings. Newest day first, capped at 200 rows.

Requires permission: costs:read.

GET /api/org/orgId/costs/anomalies

Raises on 400: Bad request

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • days (String, nil) (defaults to: nil)

    Window in days over anomalous days, 1-90. Defaults to 30.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • days: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



4793
4794
4795
4796
4797
4798
4799
4800
4801
# File 'lib/infrawrench/client.rb', line 4793

def get(org_id: nil, days: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/costs/anomalies",
    path_params: { "orgId" => org_id },
    query: { "days" => days },
    request_options: request_options
  )
end