Skip to content

Commit

Permalink
fix port mapping for prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
qu0b committed Sep 11, 2023
1 parent 4b5467b commit 83a3d7e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/mainnet-testnet-custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/mainnet-testnet-inst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/mainnet-testnet-race.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/mainnet-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/minimal-testnet-inst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/dencun-devnet-8/minimal-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/deneb-devnet-7/mainnet-testnet-inst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion builds/deneb-devnet-7/mainnet-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion configs/mainnet-deneb-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion configs/mainnet-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion configs/minimal-testnet-antithesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 1 addition & 1 deletion configs/minimal-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,4 @@ generic-instances:
"--web.console.templates=/opt/bitnami/prometheus/conf/consoles",
]
additional-volumes: ["./data/prometheus/conf:/opt/bitnami/prometheus/conf"]
ports: "9090:9090"
ports: ["9090:9090"]
2 changes: 2 additions & 0 deletions src/etb/config/etb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def __init__(self, name: str, config: dict):
self.engine_http_port: int = config["engine-http-port"]
self.engine_ws_port: int = config["engine-ws-port"]
self.metric_port: int = config["metric-port"]
self.metrics_path: str = config["metrics-path"]

def get_env_vars(self) -> dict[str, str]:
"""Returns the environment variables used by the execution client that
Expand Down Expand Up @@ -453,6 +454,7 @@ def __init__(self, name: str, config: dict):
self.validator_rpc_port: int = config["validator-rpc-port"]
self.validator_metric_port: int = config["validator-metric-port"]
self.num_validators: int = config["num-validators"]
self.metrics_path: int = config["metrics-path"]

def get_env_vars(self) -> dict[str, str]:
"""Returns the environment variables used by the consensus client that
Expand Down
40 changes: 19 additions & 21 deletions src/testnet_bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def move_trusted_setup_files(etb_config: ETBConfig):
shutil.copy(trusted_setup_json, etb_config.files.trusted_setup_json_file)


def make_prometheus_config(etb_config: dict[str, Any]) -> dict[str, Any]:
client_instances = etb_config["client-instances"]
consensus_configs = etb_config["consensus-configs"]
execution_configs = etb_config["execution-configs"]
def make_prometheus_config(etb_config: ETBConfig) -> dict[str, Any]:
client_instances = etb_config.client_instances
consensus_configs = etb_config.consensus_configs
execution_configs = etb_config.execution_configs

metrics_paths: dict[str, str] = dict()
for config in consensus_configs.values():
Expand All @@ -65,21 +65,20 @@ def make_prometheus_config(etb_config: dict[str, Any]) -> dict[str, Any]:
metrics_paths[config["client"]] = config["metrics-path"]

targets = defaultdict(list)
for k, v in client_instances.items():
consensus_client = consensus_configs[v["consensus-config"]]
consensus_client_name = consensus_client["client"]
beacon_metric_port = consensus_client["beacon-metric-port"]
validator_metric_port = consensus_client["validator-metric-port"]

execution_client = execution_configs[v["execution-config"]]
execution_client_name = execution_client["client"]
execution_metric_port = execution_client["metric-port"]

nodes = [f"{k}-{n}" for n in range(v["num-nodes"])]
for n in nodes:
targets[consensus_client_name].append(f"{n}:{beacon_metric_port}")
targets[consensus_client_name].append(f"{n}:{validator_metric_port}")
targets[execution_client_name].append(f"{n}:{execution_metric_port}")
for k, client_nodes in client_instances.items():
for instance in client_nodes:
consensus_client = instance.consensus_config
consensus_client_name = consensus_client.client
beacon_metric_port = consensus_client.beacon_metric_port
validator_metric_port = consensus_client.validator_metric_port

execution_client = instance.execution_config
execution_client_name = execution_client.client
execution_metric_port = execution_client.metric_port

targets[consensus_client_name].append(f"{k}-{instance.ndx}:{beacon_metric_port}")
targets[consensus_client_name].append(f"{k}-{instance.ndx}:{validator_metric_port}")
targets[execution_client_name].append(f"{k}-{instance.ndx}:{execution_metric_port}")

jobs = [
{
Expand Down Expand Up @@ -229,8 +228,7 @@ def ignore_aliases(self, data):
# generate prometheus.yaml from the etb-config
# (just read the etb-config file back in and parse what's needed, it's
# less hassle)
with open(etb_config_path) as f:
prometheus_config = make_prometheus_config(yaml.safe_load(f))
prometheus_config = make_prometheus_config(etb_config)

prometheus_conf_dir = etb_config.files.testnet_root / "prometheus" / "conf"
prometheus_conf_dir.mkdir(exist_ok=True, parents=True)
Expand Down

0 comments on commit 83a3d7e

Please sign in to comment.