Merge "Elastic: Set system fields and indices"
This commit is contained in:
commit
080b4453a2
@ -4,6 +4,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import re
|
||||
from sysinv.helm import base
|
||||
from sysinv.helm import common
|
||||
|
||||
@ -52,3 +53,32 @@ class ElasticBaseHelm(base.BaseHelm):
|
||||
operator.chart_group_chart_delete(
|
||||
operator.CHART_GROUPS_LUT[self.CHART],
|
||||
operator.CHARTS_LUT[self.CHART])
|
||||
|
||||
def get_system_info_overrides(self):
|
||||
# Get the system name and system uuid from the database
|
||||
# for use in setting overrides. Also returns a massaged
|
||||
# version of the system name for use in elasticsearch index,
|
||||
# and beats templates.
|
||||
#
|
||||
# Since the system_name_for_index is used as the index name
|
||||
# in elasticsearch, in the beats templates, and in also in the url
|
||||
# setting up the templates, we must be fairly restrictive here.
|
||||
# The Helm Chart repeats this same regular expression substitution,
|
||||
# but we perform it here as well so the user can see what is being used
|
||||
# when looking at the overrides.
|
||||
|
||||
system = self.dbapi.isystem_get_one()
|
||||
|
||||
system_name = system.name.encode('utf8', 'strict')
|
||||
system_uuid = system.uuid.encode('utf8', 'strict')
|
||||
system_name_for_index = re.sub('[^A-Za-z0-9-]+', '', system_name.lower())
|
||||
|
||||
# fields must be set to a non-empty value.
|
||||
if not system_name:
|
||||
system_name = "None"
|
||||
system_fields = {
|
||||
"name": system_name,
|
||||
"uid": system_uuid,
|
||||
}
|
||||
|
||||
return system_fields, system_name_for_index
|
||||
|
@ -18,9 +18,11 @@ class FilebeatHelm(elastic.ElasticBaseHelm):
|
||||
CHART = common.HELM_CHART_FILEBEAT
|
||||
|
||||
def get_overrides(self, namespace=None):
|
||||
system_fields, system_name_for_index = self.get_system_info_overrides()
|
||||
overrides = {
|
||||
common.HELM_NS_MONITOR: {
|
||||
'config': self._get_config_overrides(),
|
||||
'config': self._get_config_overrides(system_fields),
|
||||
'systemNameForIndex': system_name_for_index,
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,15 +34,15 @@ class FilebeatHelm(elastic.ElasticBaseHelm):
|
||||
else:
|
||||
return overrides
|
||||
|
||||
def _get_config_overrides(self):
|
||||
def _get_config_overrides(self, system_fields):
|
||||
conf = {
|
||||
'processors': [{'add_kubernetes_metadata': {'in_cluster': True}}],
|
||||
|
||||
'filebeat.inputs': [
|
||||
{
|
||||
'enabled': True,
|
||||
'fields': {
|
||||
"hostname": "${NODE_NAME}",
|
||||
"system": system_fields
|
||||
},
|
||||
'paths': [
|
||||
"/var/log/*.log",
|
||||
|
@ -18,6 +18,7 @@ class LogstashHelm(elastic.ElasticBaseHelm):
|
||||
CHART = common.HELM_CHART_LOGSTASH
|
||||
|
||||
def get_overrides(self, namespace=None):
|
||||
system_fields, system_name_for_index = self.get_system_info_overrides()
|
||||
overrides = {
|
||||
common.HELM_NS_MONITOR: {
|
||||
'replicaCount': self._count_hosts_by_label(
|
||||
@ -27,6 +28,7 @@ class LogstashHelm(elastic.ElasticBaseHelm):
|
||||
'size': "20Gi"},
|
||||
'config': {
|
||||
'elasticsearch.path': ""},
|
||||
'systemNameForIndex': system_name_for_index
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ class MetricbeatHelm(elastic.ElasticBaseHelm):
|
||||
CHART = common.HELM_CHART_METRICBEAT
|
||||
|
||||
def get_overrides(self, namespace=None):
|
||||
system_fields, system_name_for_index = self.get_system_info_overrides()
|
||||
overrides = {
|
||||
common.HELM_NS_MONITOR: {
|
||||
'daemonset': {
|
||||
@ -25,13 +26,16 @@ class MetricbeatHelm(elastic.ElasticBaseHelm):
|
||||
'system': self._get_metric_system(),
|
||||
'kubernetes': self._get_metric_kubernetes(),
|
||||
},
|
||||
'config': self._get_config_overrides(system_fields),
|
||||
},
|
||||
'deployment': {
|
||||
'modules': {
|
||||
'kubernetes':
|
||||
self._get_metric_deployment_kubernetes()
|
||||
}
|
||||
}
|
||||
},
|
||||
'config': self._get_config_overrides(system_fields),
|
||||
},
|
||||
'systemNameForIndex': system_name_for_index,
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +47,14 @@ class MetricbeatHelm(elastic.ElasticBaseHelm):
|
||||
else:
|
||||
return overrides
|
||||
|
||||
def _get_config_overrides(self, system_fields):
|
||||
conf = {
|
||||
'fields': {
|
||||
"system": system_fields
|
||||
}
|
||||
}
|
||||
return conf
|
||||
|
||||
def _get_metric_system(self):
|
||||
conf = {
|
||||
"enabled": True,
|
||||
|
Loading…
Reference in New Issue
Block a user