Skip to content

Commit

Permalink
ECK: Two more view-files, improve parser-file
Browse files Browse the repository at this point in the history
Add list- and info-views for Agent & ApmServer
and improve the parser-file for ECK.

Signed-off-by: David Weinehall <[email protected]>
  • Loading branch information
taotriad committed Oct 23, 2024
1 parent f750b02 commit eb53bf2
Show file tree
Hide file tree
Showing 4 changed files with 533 additions and 4 deletions.
18 changes: 14 additions & 4 deletions clustermanagementtoolkit/itemgetters.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,21 @@ def get_dict_list(obj: Dict, **kwargs: Any) -> List[Any]:
for item in tmp_vlist:
newobj: List[Tuple] = []
for field in fields:
tmp = deep_get(item, DictPath(field))
if tmp is not None:
tmp = str(tmp)
if isinstance(field, dict):
field_ = deep_get(field, DictPath("field"), "")
field_regex = deep_get(field, DictPath("regex"), "")
if (tmp := deep_get(item, DictPath(field_))) is not None:
tmp = str(tmp)
if field_regex:
tmp2 = re.match(field_regex, tmp)
tmp = tmp2.group(1)
else:
tmp = "<none>"
else:
tmp = "<none>"
if (tmp := deep_get(item, DictPath(field))) is not None:
tmp = str(tmp)
else:
tmp = "<none>"
newobj.append(tmp)
vlist.append(tuple(newobj))
return vlist
Expand Down
1 change: 1 addition & 0 deletions parsers/eck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- image_name: "/eck/eck-operator"
- image_name: "/apm/apm-server"
- image_name: "/elasticsearch/elasticsearch"
- image_name: "/beats/elastic-agent"
parser_rules:
- name: "glog"
- name: "json"
Expand Down
159 changes: 159 additions & 0 deletions views/Agent.agent.k8s.elastic.co.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
kind: "Agent"
api_family: "agent.k8s.elastic.co"
default_command: "agents"
listview:
name: "Agents"
group: "Logging"
field_indexes:
Normal:
fields: ["namespace", "name", "version", "available_nodes", "health", "age"]
sortcolumn: "namespace"
fields:
available_nodes:
header: "Available Nodes:"
paths:
- path: [["status#availableNodes"], ["status#expectedNodes"]]
pathtype: "tuple"
formatter: "list"
formatting:
field_colors:
- type: "numerical"
- type: "numerical"
item_separator:
type: "fraction"
align: "right"
health:
header: "Health:"
path: "status#health"
default: "<unset>"
type: "str"
formatter: "value_mapper"
formatting:
mapping:
mappings:
green:
field_colors:
- context: "main"
type: "status_ok"
unknown:
field_colors:
- context: "main"
type: "status_unknown"
version:
header: "Version:"
path: "spec#version"
type: "str"
formatting:
field_colors:
- type: "version"
infoview:
name: "Agent Info"
infopad:
row_indexes:
Normal:
fields: ["kibana_ref", "version", "available_nodes", "health"]
rows:
available_nodes:
header: [["Available Nodes:", ["main", "infoheader"]]]
paths:
- path: [["status#availableNodes"], ["status#expectedNodes"]]
pathtype: "tuple"
formatter: "list"
formatting:
field_colors:
- type: "numerical"
- type: "numerical"
item_separator:
type: "fraction"
health:
header: [["Health:", ["main", "infoheader"]]]
path: "status#health"
default: "<unset>"
type: "str"
formatter: "value_mapper"
formatting:
mapping:
mappings:
green:
field_colors:
- context: "main"
type: "status_ok"
unknown:
field_colors:
- context: "main"
type: "status_unknown"
kibana_ref:
header: [["K", ["main", "infoheader_shortcut"]], ["ibana Reference:", ["main", "infoheader"]]]
path: "spec#elasticsearchRef#name"
default: "<unset>"
type: "str"
version:
header: [["Version:", ["main", "infoheader"]]]
path: "spec#version"
type: "str"
formatting:
field_colors:
- type: "version"
shortcuts:
"Configuration":
key: "c"
modifier: "shift"
read_only: true
helptext: "Show configuration"
action: "call"
action_call: "view_yaml"
action_args:
title: "Configuration"
_pass_obj: true
path: "spec#config"
"List Elasticsearch statuses":
key: "e"
modifier: "shift"
read_only: true
helptext: "List Elasticsearch statuses"
widget: "windowwidget"
title: "Elasticsearch Statuses:"
headers: ["Namespace:", "Name:", "Status:"]
itemgetter: "get_dict_list"
itemgetter_args:
path: "status#elasticsearchAssociationsStatus"
fields:
- field: "key"
regex: "^([^/]+)/.+"
- field: "key"
regex: "^[^/]+/(.+)"
- "value"
# This isn't supported for now
sortcolumn: "namespace"
selectable: true
action: "call"
action_call: "resourceinfodispatch_with_lookup"
action_args:
kind: "Elasticsearch"
api_family: "elasticsearch.k8s.elastic.co"
name_path: 1
namespace_path: 0
"Open Kibana":
key: "k"
modifier: "shift"
read_only: true
helptext: "Open info page for Kibana"
action: "call"
action_call: "resourceinfodispatch_with_lookup"
action_args:
_pass_obj: true
kind: "Kibana"
api_family: "kibana.k8s.elastic.co"
namespace_path: "metadata#namespace"
name_path: "spec#kibanaRef#name"
"Pod template":
key: "t"
modifier: "shift"
read_only: true
helptext: "Show Pod template"
action: "call"
action_call: "view_yaml"
action_args:
title: "Pod template"
_pass_obj: true
path: "spec#daemonSet#podTemplate"
Loading

0 comments on commit eb53bf2

Please sign in to comment.