Skip to content

Commit

Permalink
Parametrize default grafana time range on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ycedres committed Oct 18, 2024
1 parent b1363b7 commit db1d93f
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 917 deletions.
1 change: 1 addition & 0 deletions health-check/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ promtail-linux-amd64
__pycache__
**/config/exporter/config.yaml
**/config/promtail/config.yaml
**/config/grafana/dashboards/supportconfig_with_logs.json
16 changes: 12 additions & 4 deletions health-check/src/uyuni_health_check/config_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import configparser
import yaml
import json
from jinja2 import Environment, FileSystemLoader

class ConfigLoader:
Expand All @@ -24,15 +25,22 @@ def load_yaml(self, filename):

def load_jinja_template(self, template_name):
return self.jinja_env.get_template(template_name)

def get_json_template_filepath(self, json_relative_path):
return os.path.join(self.templates_dir, json_relative_path)

def load_dockerfile_dir(self, dockerfile_dir):
dockerfile_dir = os.path.join(self.containers_dir, dockerfile_dir)
return dockerfile_dir

def write_config(self, component, content):
file_path = os.path.join(self.config_dir, component, "config.yaml")
def write_config(self, component, config_file_path, content, isjson=False):
file_path = os.path.join(self.config_dir, component, config_file_path)
with open(file_path, "w") as file:
file.write(content)
if isjson:
json.dump(content, file)
else:
file.write(content)


def get_config_file_path(self, component):
return os.path.join(self.base_dir, "config", component, "config.yaml")
Expand All @@ -41,7 +49,7 @@ def get_sources_path(self):
return self.base_dir

def get_grafana_config_dir(self):
return os.path.join(self.base_dir, "grafana", "conf")
return os.path.join(self.config_dir, "grafana")

def get_prometheus_config_dir(self):
return os.path.join(self.base_dir, "prometheus", "conf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ def prepare_exporter(config=None, verbose=False, supportconfig_path=None):
def create_supportconfig_exporter_cfg(config=None, supportconfig_path=None):
exporter_template = config.load_jinja_template("exporter/exporter.yaml.j2")
opts = {"supportconfig_path": supportconfig_path}
exporter_config_file_path = config.get_config_file_path("exporter")
config.write_config("exporter", exporter_template.render(**opts))
#exporter_config_file_path = config.get_config_file_path("exporter")
config.write_config("exporter", "config.yaml", exporter_template.render(**opts))
Loading

0 comments on commit db1d93f

Please sign in to comment.