Skip to content

Commit c49debe

Browse files
committed
opensearch field
1 parent b404153 commit c49debe

File tree

8 files changed

+563
-4
lines changed

8 files changed

+563
-4
lines changed

src-admintool/web/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ <h2>Merritt Internals</h2>
297297
<li class="graph"><a class="json" href="{{ADMINTOOL_HOME}}?path=admin_obj_agg">Merritt Admin Objects Count</a></li>
298298
<li class="coll"><a class="json" href="{{ADMINTOOL_HOME}}?path=admin_coll">Collections Table Special Cases</a></li>
299299
<li class="config"><a href="{{COLLADMIN_HOME}}?path=instances">Merritt Servers</a></li>
300-
<li class="config"><a href="{{COLLADMIN_HOME}}?path=ssm-describe">SSM Parameter Registry</a></li>
301-
</ul>
300+
<li class="config"><a href="{{COLLADMIN_HOME}}?path=ssm-describe">SSM Parameter Registry</a></li>
301+
<li class="config"><a href="{{COLLADMIN_HOME}}?path=opensearch-describe">OpenSearch Field Registry</a></li>
302+
</ul>
302303
</div>
303304

304305
<div class="nav_section nav_merritt_users nav_merritt_internals">
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'action'
4+
require 'yaml'
5+
6+
# Collection Admin Task class - see config/actions.yml for description
7+
class OpenSearchDescribeAction < AdminAction
8+
def initialize(config, action, path, myparams)
9+
super(config, action, path, myparams)
10+
file = 'import/filebeat/fields.json'
11+
@title = "Merritt OpenSearch Fields (#{File.ctime(file).to_s[0..15]})"
12+
@fields = JSON.parse(File.read(file))
13+
#load_registry
14+
end
15+
16+
def load_registry
17+
reg = YAML.safe_load(File.read('import/filebeat/opensearch.registry.yml'), aliases: true)
18+
process_registry_node(LambdaBase.ssm_root_path.chop, reg)
19+
end
20+
21+
def process_registry_node(path, reg)
22+
if reg.key?('description')
23+
p = @parameters.fetch(path, SsmInfo.new(path))
24+
p.set_description(reg['description'])
25+
p.set_deprecated(reg.fetch('deprecated', ''))
26+
p.set_skip(reg.fetch('skip', false))
27+
@parameters[path] = p
28+
return
29+
end
30+
31+
reg.each_key do |k|
32+
r = reg[k]
33+
next unless r.instance_of?(::Hash)
34+
35+
process_registry_node("#{path}/#{k}", r)
36+
end
37+
38+
return unless reg.fetch('skip', false)
39+
40+
@parameters.each_key do |pp|
41+
next unless pp =~ /^#{path}.*/
42+
43+
@parameters[pp].set_skip(true)
44+
end
45+
end
46+
47+
def get_title
48+
@title
49+
end
50+
51+
def table_headers
52+
['Field Name', 'Type', 'Statis']
53+
end
54+
55+
def table_types
56+
['name', '', 'status']
57+
end
58+
59+
def perform_action
60+
convert_json_to_table({}.to_json)
61+
end
62+
63+
def table_rows(_body)
64+
rows = []
65+
@fields.each do |val|
66+
name = val.fetch('name', '')
67+
next if name =~ /\.keyword$/
68+
type = val.fetch('type', '')
69+
rows.append([name, type, 'PASS'])
70+
end
71+
rows
72+
end
73+
74+
def has_table
75+
true
76+
end
77+
78+
def get_alternative_queries
79+
[]
80+
end
81+
82+
def init_status
83+
:PASS
84+
end
85+
end

src-colladmin/config/actions.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,18 @@ ssm-describe:
371371
These variables are compared against a [registry of expected SSM variables](https://github.com/CDLUC3/mrt-admin-lambda/blob/main/src-colladmin/config/ssm.registry.yml).
372372
documentation: |
373373
Aws: SSM Query
374+
opensearch-describe:
375+
link-title: List and Describe Merritt OpenSearch Fields
376+
breadcrumb: bp_internals
377+
class: OpenSearchDescribeAction
378+
category: Dev Ops
379+
sensitivity: readonly
380+
testing: automated
381+
description: |
382+
Generate a report describing the OpenSearch fields generated from Merritt application logs.
383+
These variables are compared against a [TBD registry of expected OpenSearch fields](https://github.com/CDLUC3/mrt-admin-lambda/blob/main/src-colladmin/import/filebeat/opensearch.registry.yml).
384+
documentation: |
385+
Aws: OpenSearch Query
374386
storage-get-manifest:
375387
link-title: Get Storage Manifest for an Object from Cloud Storage
376388
class: StorageAction

src-colladmin/import/filebeat/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22

33
- export `filebeat-uc3-mrt-prd*` index pattern saved object
44
- save as `filebeat.ndjson`
5-
- run `ruby fields.rb filebeat.ndjson > fields.json`
5+
- run `ruby fields.rb filebeat.ndjson > fields.json`
6+
7+
## By saving fields.json to git, we can notice diffs in our field useage
8+
9+
- [fields.json](fields.json)
10+
11+
## TODO
12+
13+
Much like the documentation that we have for our SSM variables, this file can be used to document the opensearch index fields in use by Merritt applications.

0 commit comments

Comments
 (0)