Class: OpenObserve::Incidents
- Defined in:
- lib/openobserve/incidents.rb
Overview
Incidents — one firing episode of an alert, with its status and lifecycle.
Served by the v2 alerting API. The listing envelope carries both the page and a
server-side total, so #total exposes the count without making the caller reach into
the raw payload.
Every request goes through Resource#raw: the listing, the fetch, the stats and the update all declare a response type, which this domain cannot use.
Constant Summary
Constants inherited from Resource
Instance Method Summary collapse
- #get(id) ⇒ OpenObserve::Incident
- #list(status: nil, limit: nil, offset: nil) ⇒ Array<OpenObserve::Incident>
-
#stats ⇒ Hash
The aggregate counters OpenObserve reports for incidents.
-
#total(status: nil) ⇒ Integer?
The server-side count for the last listing, which is not the size of the page.
- #update(id, **attributes) ⇒ void
Methods inherited from Resource
Constructor Details
This class inherits a constructor from OpenObserve::Resource
Instance Method Details
#get(id) ⇒ OpenObserve::Incident
29 30 31 |
# File 'lib/openobserve/incidents.rb', line 29 def get(id) Incident.from(one('incident') { raw(:GET, "#{incidents_path}/#{encode(id)}") }) end |
#list(status: nil, limit: nil, offset: nil) ⇒ Array<OpenObserve::Incident>
15 16 17 18 |
# File 'lib/openobserve/incidents.rb', line 15 def list(status: nil, limit: nil, offset: nil) Array(envelope(status: status, limit: limit, offset: offset)['incidents']) .map { |incident| Incident.from(incident) } end |
#stats ⇒ Hash
Returns the aggregate counters OpenObserve reports for incidents.
34 35 36 |
# File 'lib/openobserve/incidents.rb', line 34 def stats collection { raw(:GET, "#{incidents_path}/stats") } || {} end |
#total(status: nil) ⇒ Integer?
The server-side count for the last listing, which is not the size of the page.
22 23 24 |
# File 'lib/openobserve/incidents.rb', line 22 def total(status: nil) envelope(status: status)['total'] end |
#update(id, **attributes) ⇒ void
This method returns an undefined value.
41 42 43 44 |
# File 'lib/openobserve/incidents.rb', line 41 def update(id, **attributes) call { raw(:PATCH, "#{incidents_path}/#{encode(id)}/update", body: attributes) } nil end |