Class: Infrawrench::MetricAlertsNamespace

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

Overview

client.metric_alerts

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ MetricAlertsNamespace

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

Parameters:



4065
4066
4067
# File 'lib/infrawrench/client.rb', line 4065

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(body:, org_id: nil, request_options: nil) ⇒ Hash

Create a metric alert rule

Rules select resources by query (plugin + resource type + tag), never by id list, so a rule automatically covers resources created after it was written. The poller evaluates enabled rules about once a minute and alerts when the condition held for the whole trailing window.

POST /api/org/orgId/metric-alerts

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.

  • body (Hash)

    Request body, shaped as MetricAlertRuleInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



4086
4087
4088
4089
4090
4091
4092
4093
4094
# File 'lib/infrawrench/client.rb', line 4086

def create(body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/metric-alerts",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#delete(id:, org_id: nil, request_options: nil) ⇒ Hash

Delete a metric alert rule

Soft delete. The rule's firing history stays readable via /metric-alerts/events.

DELETE /api/org/orgId/metric-alerts/id

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.

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

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

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

Returns:

  • (Hash)

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

Raises:



4111
4112
4113
4114
4115
4116
4117
4118
# File 'lib/infrawrench/client.rb', line 4111

def delete(id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/metric-alerts/{id}",
    path_params: { "orgId" => org_id, "id" => id },
    request_options: request_options
  )
end

#events(org_id: nil, rule_id: nil, limit: nil, request_options: nil) ⇒ Array<Hash>

Recent metric alert firings

GET /api/org/orgId/metric-alerts/events

Parameters:

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

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

  • rule_id (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: nil)
  • request_options (Hash, nil) (defaults to: nil)

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

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

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<MetricAlertEvent> — see sig/infrawrench/sdk.rbs.

Raises:



4132
4133
4134
4135
4136
4137
4138
4139
4140
# File 'lib/infrawrench/client.rb', line 4132

def events(org_id: nil, rule_id: nil, limit: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts/events",
    path_params: { "orgId" => org_id },
    query: { "ruleId" => rule_id, "limit" => limit },
    request_options: request_options
  )
end

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

Get a metric alert rule

GET /api/org/orgId/metric-alerts/id

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.

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

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

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

Returns:

  • (Hash)

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

Raises:



4154
4155
4156
4157
4158
4159
4160
4161
# File 'lib/infrawrench/client.rb', line 4154

def get(id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts/{id}",
    path_params: { "orgId" => org_id, "id" => id },
    request_options: request_options
  )
end

#list(org_id: nil, request_options: nil) ⇒ Array<Hash>

List metric alert rules with live firing status

GET /api/org/orgId/metric-alerts

Parameters:

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

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

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

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

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

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<MetricAlertRuleWithStatus> — see sig/infrawrench/sdk.rbs.

Raises:



4173
4174
4175
4176
4177
4178
4179
4180
# File 'lib/infrawrench/client.rb', line 4173

def list(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#metric_keys(org_id: nil, plugin_id: nil, resource_type_id: nil, request_options: nil) ⇒ Array<Hash>

List metric series that actually exist

The series labels resources reported in the last 7 days, optionally narrowed to one plugin and resource type — what the rule builder's metric picker is fed from.

GET /api/org/orgId/metric-alerts/metric-keys

Parameters:

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

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

  • plugin_id (String, nil) (defaults to: nil)
  • resource_type_id (String, nil) (defaults to: nil)
  • request_options (Hash, nil) (defaults to: nil)

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

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

Returns:

  • (Array<Hash>)

    Parsed JSON, shaped as Array<MetricSeriesKey> — see sig/infrawrench/sdk.rbs.

Raises:



4198
4199
4200
4201
4202
4203
4204
4205
4206
# File 'lib/infrawrench/client.rb', line 4198

def metric_keys(org_id: nil, plugin_id: nil, resource_type_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts/metric-keys",
    path_params: { "orgId" => org_id },
    query: { "pluginId" => plugin_id, "resourceTypeId" => resource_type_id },
    request_options: request_options
  )
end

#selector_options(org_id: nil, request_options: nil) ⇒ Hash

List what the organization's resources offer to select on

GET /api/org/orgId/metric-alerts/selector-options

Parameters:

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

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

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

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

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

Returns:

  • (Hash)

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

Raises:



4218
4219
4220
4221
4222
4223
4224
4225
# File 'lib/infrawrench/client.rb', line 4218

def selector_options(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts/selector-options",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#selector_preview(org_id: nil, plugin_id: nil, resource_type_id: nil, tag_key: nil, tag_value: nil, request_options: nil) ⇒ Hash

Preview which resources a selector matches right now

GET /api/org/orgId/metric-alerts/selector-preview

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.

  • plugin_id (String, nil) (defaults to: nil)
  • resource_type_id (String, nil) (defaults to: nil)
  • tag_key (String, nil) (defaults to: nil)
  • tag_value (String, nil) (defaults to: nil)
  • request_options (Hash, nil) (defaults to: nil)

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

  • org_id: (String, nil) (defaults to: nil)
  • plugin_id: (String, nil) (defaults to: nil)
  • resource_type_id: (String, nil) (defaults to: nil)
  • tag_key: (String, nil) (defaults to: nil)
  • tag_value: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

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

Raises:



4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
# File 'lib/infrawrench/client.rb', line 4243

def selector_preview(
  org_id: nil,
  plugin_id: nil,
  resource_type_id: nil,
  tag_key: nil,
  tag_value: nil,
  request_options: nil
)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/metric-alerts/selector-preview",
    path_params: { "orgId" => org_id },
    query: {
      "pluginId" => plugin_id,
      "resourceTypeId" => resource_type_id,
      "tagKey" => tag_key,
      "tagValue" => tag_value
    },
    request_options: request_options
  )
end

#update(id:, body:, org_id: nil, request_options: nil) ⇒ Hash

Update a metric alert rule

PUT /api/org/orgId/metric-alerts/id

Raises on 400: Bad request

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.

  • id (String)
  • body (Hash)

    Request body, shaped as MetricAlertRuleInput.

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

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

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

Returns:

  • (Hash)

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

Raises:



4280
4281
4282
4283
4284
4285
4286
4287
4288
# File 'lib/infrawrench/client.rb', line 4280

def update(id:, body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "PUT",
    path: "/api/org/{orgId}/metric-alerts/{id}",
    path_params: { "orgId" => org_id, "id" => id },
    body: body,
    request_options: request_options
  )
end