Class: Gitlab::Elasticsearch::Logs::Lines

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/elasticsearch/logs/lines.rb

Constant Summary collapse

InvalidCursor =
Class.new(RuntimeError)
LOGS_LIMIT =

How many log lines to fetch in a query

500

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Lines

Returns a new instance of Lines.


12
13
14
# File 'lib/gitlab/elasticsearch/logs/lines.rb', line 12

def initialize(client)
  @client = client
end

Instance Method Details

#pod_logs(namespace, pod_name: nil, container_name: nil, search: nil, start_time: nil, end_time: nil, cursor: nil, chart_above_v2: true) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/elasticsearch/logs/lines.rb', line 16

def pod_logs(namespace, pod_name: nil, container_name: nil, search: nil, start_time: nil, end_time: nil, cursor: nil, chart_above_v2: true)
  query = { bool: { must: [] } }.tap do |q|
    filter_pod_name(q, pod_name)
    filter_namespace(q, namespace)
    filter_container_name(q, container_name)
    filter_search(q, search)
    filter_times(q, start_time, end_time)
  end

  body = build_body(query, cursor, chart_above_v2)
  response = @client.search body: body

  format_response(response)
end