Skip to content

Commit

Permalink
add grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed Sep 25, 2024
1 parent 7ab1376 commit 2b69306
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,16 @@ prometheus_params:
min_mem: 128
max_mem: 2048
# Configuration place for grafana
grafana_params:
# Resource management for grafana container
# CPU is milicores
# RAM is in MB
min_cpu: 10
max_cpu: 1000
min_mem: 128
max_mem: 2048
# Configuration place for the assertoor testing tool - https://github.com/ethpandaops/assertoor
assertoor_params:
# Assertoor docker image to use
Expand Down
3 changes: 2 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def run(plan, args={}):
all_ethereum_metrics_exporter_contexts,
all_xatu_sentry_contexts,
global_node_selectors,
args_with_right_defaults.prometheus_params
args_with_right_defaults.prometheus_params,
)

plan.print("Launching grafana...")
Expand All @@ -648,6 +648,7 @@ def run(plan, args={}):
grafana_dashboards_config_template,
prometheus_private_url,
global_node_selectors,
args_with_right_defaults.grafana_params,
additional_dashboards=args_with_right_defaults.grafana_additional_dashboards,
)
plan.print("Successfully launched grafana")
Expand Down
17 changes: 7 additions & 10 deletions src/grafana/grafana_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,14 @@ USED_PORTS = {
)
}

# The min/max CPU/memory that grafana can use
MIN_CPU = 10
MAX_CPU = 1000
MIN_MEMORY = 128
MAX_MEMORY = 2048


def launch_grafana(
plan,
datasource_config_template,
dashboard_providers_config_template,
prometheus_private_url,
global_node_selectors,
grafana_params,
additional_dashboards=[],
):
(
Expand All @@ -75,6 +70,7 @@ def launch_grafana(
grafana_config_artifacts_uuid,
merged_dashboards_artifact_name,
global_node_selectors,
grafana_params,
)

plan.add_service(SERVICE_NAME, config)
Expand Down Expand Up @@ -130,6 +126,7 @@ def get_config(
grafana_config_artifacts_name,
grafana_dashboards_artifacts_name,
node_selectors,
grafana_params,
):
return ServiceConfig(
image=IMAGE_NAME,
Expand All @@ -145,10 +142,10 @@ def get_config(
GRAFANA_CONFIG_DIRPATH_ON_SERVICE: grafana_config_artifacts_name,
GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE: grafana_dashboards_artifacts_name,
},
min_cpu=MIN_CPU,
max_cpu=MAX_CPU,
min_memory=MIN_MEMORY,
max_memory=MAX_MEMORY,
min_cpu=grafana_params.min_cpu,
max_cpu=grafana_params.max_cpu,
min_memory=grafana_params.min_memory,
max_memory=grafana_params.max_memory,
node_selectors=node_selectors,
)

Expand Down
17 changes: 17 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def input_parser(plan, input_args):
result["custom_flood_params"] = get_default_custom_flood_params()
result["disable_peer_scoring"] = False
result["goomy_blob_params"] = get_default_goomy_blob_params()
result["prometheus_params"] = get_default_prometheus_params()
result["grafana_params"] = get_default_grafana_params()
result["assertoor_params"] = get_default_assertoor_params()
result["prometheus_params"] = get_default_prometheus_params()
result["xatu_sentry_params"] = get_default_xatu_sentry_params()
Expand Down Expand Up @@ -336,6 +338,12 @@ def input_parser(plan, input_args):
min_mem=result["prometheus_params"]["min_mem"],
max_mem=result["prometheus_params"]["max_mem"],
),
grafana_params=struct(
min_cpu=result["grafana_params"]["min_cpu"],
max_cpu=result["grafana_params"]["max_cpu"],
min_mem=result["grafana_params"]["min_mem"],
max_mem=result["grafana_params"]["max_mem"],
),
apache_port=result["apache_port"],
assertoor_params=struct(
image=result["assertoor_params"]["image"],
Expand Down Expand Up @@ -1012,6 +1020,15 @@ def get_default_prometheus_params():
}


def get_default_grafana_params():
return {
"min_cpu": 10,
"max_cpu": 1000,
"min_mem": 128,
"max_mem": 2048,
}


def get_default_xatu_sentry_params():
return {
"xatu_sentry_image": "ethpandaops/xatu:latest",
Expand Down
1 change: 1 addition & 0 deletions src/prometheus/prometheus_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ METRICS_INFO_ADDITIONAL_CONFIG_KEY = "config"

PROMETHEUS_DEFAULT_SCRAPE_INTERVAL = "15s"


def launch_prometheus(
plan,
el_contexts,
Expand Down

0 comments on commit 2b69306

Please sign in to comment.