Class: OpenObserve::Streams
- Defined in:
- lib/openobserve/streams.rb
Overview
Streams — the containers logs, metrics and traces land in.
Read-only by design here: creating, deleting or re-configuring a stream is an administration act, outside this gem's working set (search and alerting).
Reads go through Resource#raw rather than Api::Api::Streams, which pins
type: Api::Models::StreamList200Response on its listing — see Resource#raw for why
a declared response type is unusable here.
Constant Summary
Constants inherited from Resource
Instance Method Summary collapse
- #list(type: nil, keyword: nil, limit: nil, offset: nil, sort: nil) ⇒ Array<OpenObserve::Stream>
-
#names ⇒ Array<String>
Stream names only.
-
#schema(name, type: nil) ⇒ OpenObserve::Stream
The stream and its field list.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from OpenObserve::Resource
Instance Method Details
#list(type: nil, keyword: nil, limit: nil, offset: nil, sort: nil) ⇒ Array<OpenObserve::Stream>
15 16 17 18 19 20 21 22 23 |
# File 'lib/openobserve/streams.rb', line 15 def list(type: nil, keyword: nil, limit: nil, offset: nil, sort: nil) envelope = collection do raw(:GET, "/api/#{encode(organization)}/streams", query: { 'type' => type, 'keyword' => keyword, 'limit' => limit, 'offset' => offset, 'sort' => sort, }) end Array(envelope && envelope['list']).map { |stream| Stream.from(stream) } end |
#names ⇒ Array<String>
Returns stream names only.
26 27 28 |
# File 'lib/openobserve/streams.rb', line 26 def names(...) list(...).map { |stream| stream['name'] } end |
#schema(name, type: nil) ⇒ OpenObserve::Stream
Returns the stream and its field list.
33 34 35 36 37 38 39 40 |
# File 'lib/openobserve/streams.rb', line 33 def schema(name, type: nil) payload = one('stream') do raw(:GET, "/api/#{encode(organization)}/streams/#{encode(name)}/schema", query: { 'type' => type }) end Stream.from(payload) end |