Skip to content

Commit

Permalink
feat: add beacon-metrics-gazer + beacon-metrics-gazer grafana dashboa…
Browse files Browse the repository at this point in the history
…rd (#114)

Changelog picked up from commits here:

feat: add beacon-metrics-gazer

---------

Co-authored-by: Gyanendra Mishra <[email protected]>
  • Loading branch information
barnabasbusa and h4ck3rk3y authored Aug 10, 2023
1 parent 14dc957 commit 5540587
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 2 deletions.
6 changes: 6 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ eth_network_module = import_module("github.com/kurtosis-tech/eth-network-package
transaction_spammer = import_module("github.com/kurtosis-tech/eth2-package/src/transaction_spammer/transaction_spammer.star")
cl_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/cl_forkmon/cl_forkmon_launcher.star")
el_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/el_forkmon/el_forkmon_launcher.star")
beacon_metrics_gazer = import_module("github.com/kurtosis-tech/eth2-package/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star")
prometheus = import_module("github.com/kurtosis-tech/eth2-package/src/prometheus/prometheus_launcher.star")
grafana =import_module("github.com/kurtosis-tech/eth2-package/src/grafana/grafana_launcher.star")
testnet_verifier = import_module("github.com/kurtosis-tech/eth2-package/src/testnet_verifier/testnet_verifier.star")
Expand Down Expand Up @@ -87,6 +88,11 @@ def run(plan, args):
el_forkmon.launch_el_forkmon(plan, el_forkmon_config_template, all_el_client_contexts)
plan.print("Succesfully launched execution layer forkmon")

plan.print("Launching beacon metrics gazer")
beacon_metrics_gazer_config_template = read_file(static_files.BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH)
beacon_metrics_gazer.launch_beacon_metrics_gazer(plan, beacon_metrics_gazer_config_template, all_cl_client_contexts,network_params)
plan.print("Succesfully launched beacon metrics gazer")

plan.print("Launching prometheus...")
prometheus_private_url = prometheus.launch_prometheus(
plan,
Expand Down
69 changes: 69 additions & 0 deletions src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")


SERVICE_NAME = "beacon-metrics-gazer"
IMAGE_NAME = "dapplion/beacon-metrics-gazer:latest"

HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 8080

BEACON_METRICS_GAZER_CONFIG_FILENAME = "beacon-metrics-gazer-ranges.yaml"

BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"

USED_PORTS = {
HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL)
}


def launch_beacon_metrics_gazer(
plan,
config_template,
cl_client_contexts,
network_params
):

data = []
for index, client in enumerate(cl_client_contexts):
start_index = index*network_params.num_validator_keys_per_node
end_index = ((index+1)*network_params.num_validator_keys_per_node)-1
service_name = client.beacon_service_name
data.append({"ClientName": service_name, "Range": "{0}-{1}".format(start_index, end_index)})

template_data = {"Data": data}

template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[BEACON_METRICS_GAZER_CONFIG_FILENAME] = shared_utils.new_template_and_data(config_template, template_data)

config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "beacon-metrics-gazer-config")

config = get_config(
config_files_artifact_name,
cl_client_contexts[0].ip_addr,
cl_client_contexts[0].http_port_num)

plan.add_service(SERVICE_NAME, config)


def get_config(
config_files_artifact_name,
ip_addr,
http_port_num):
config_file_path = shared_utils.path_join(BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE, BEACON_METRICS_GAZER_CONFIG_FILENAME)
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
files = {
BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
},
cmd = [
"http://{0}:{1}".format(ip_addr, http_port_num),
"--ranges-file",
"/config/{0}".format(BEACON_METRICS_GAZER_CONFIG_FILENAME),
"--port",
"{0}".format(HTTP_PORT_NUMBER),
"--address",
"0.0.0.0",
"-v"
]
)
2 changes: 1 addition & 1 deletion src/grafana/grafana_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CONFIG_DIRPATH_ENV_VAR = "GF_PATHS_PROVISIONING"

GRAFANA_CONFIG_DIRPATH_ON_SERVICE = "/config"
GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE = "/dashboards"
GRAFANA_DASHBOARDS_FILEPATH_ON_SERVICE = GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE + "/dashboard.json"
GRAFANA_DASHBOARDS_FILEPATH_ON_SERVICE = GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE


USED_PORTS = {
Expand Down
6 changes: 5 additions & 1 deletion src/static_files/static_files.star
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ EL_FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
PROMETHEUS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/prometheus-config/prometheus.yml.tmpl"

# Beacon Metrics Gazer config
BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/beacon-metrics-gazer-config/config.yaml.tmpl"

# Grafana config
GRAFANA_CONFIG_DIRPATH = "/grafana-config"
GRAFANA_DATASOURCE_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
GRAFANA_CONFIG_DIRPATH + "/templates/datasource.yml.tmpl"
GRAFANA_DASHBOARD_PROVIDERS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
GRAFANA_CONFIG_DIRPATH + "/templates/dashboard-providers.yml.tmpl"
GRAFANA_DASHBOARDS_CONFIG_DIRPATH = STATIC_FILES_DIRPATH + \
GRAFANA_CONFIG_DIRPATH + "/dashboards/dashboard.json"
GRAFANA_CONFIG_DIRPATH + "/dashboards"
3 changes: 3 additions & 0 deletions static_files/beacon-metrics-gazer-config/config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ range $data := .Data }}
{{ $data.Range }}: {{ $data.ClientName }}
{{ end }}
Loading

0 comments on commit 5540587

Please sign in to comment.