mirror of
https://github.com/vacp2p/wakurtosis.git
synced 2026-01-09 06:47:58 -05:00
Trying to set up prometheus under Kurtosis
This commit is contained in:
@@ -1 +1 @@
|
||||
name: "github.com/logos-co/wakurtosis/kurtosis-module/starlark"
|
||||
name: "github.com/logos-co/wakurtosis"
|
||||
86
main.star
86
main.star
@@ -1,22 +1,24 @@
|
||||
IMAGE_NAME = "statusteam/nim-waku:deploy-status-prod"
|
||||
WAKU_IMAGE = "statusteam/nim-waku:deploy-status-prod"
|
||||
WAKU_RPC_PORT_ID = "rpc"
|
||||
TCP_PORT = 8545
|
||||
|
||||
# Waku Matrics Port
|
||||
PROMETHEUS_IMAGE = "prom/prometheus:latest"
|
||||
PROMETHEUS_PORT_ID = "prometheus"
|
||||
PROMETHEUS_TCP_PORT = 8008
|
||||
PROMETHEUS_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/prometheus.yml"
|
||||
|
||||
POST_RELAY_MESSAGE = "post_waku_v2_relay_v1_message"
|
||||
GET_WAKU_INFO_METHOD = "get_waku_v2_debug_v1_info"
|
||||
CONNECT_TO_PEER_METHOD = "post_waku_v2_admin_v1_peers"
|
||||
|
||||
GENERAL_TOML_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/configurable_toml/kurtosis-module/starlark/config_files/waku_general.toml"
|
||||
GENERAL_TOML_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/kurtosis-module/starlark/config_files/waku_general.toml"
|
||||
GENERAL_TOML_CONFIGURATION_NAME = "waku_general.toml"
|
||||
|
||||
|
||||
def create_waku_id(other_node_info):
|
||||
ip = other_node_info["service"].ip_address
|
||||
port = other_node_info["service"].ports["rpc"].number
|
||||
port = other_node_info["service"].ports[WAKU_RPC_PORT_ID].number
|
||||
node_id = other_node_info["id"]
|
||||
|
||||
return '["/ip4/' + str(ip) + '/tcp/' + str(port) + '/p2p/' + node_id + '"]'
|
||||
@@ -79,7 +81,6 @@ def get_toml_configuration_artifact(wakunode_name, same_toml_configuration):
|
||||
return artifact_id, file_name
|
||||
|
||||
|
||||
|
||||
def instantiate_waku_nodes(waku_topology, same_toml_configuration):
|
||||
services = {}
|
||||
|
||||
@@ -92,7 +93,7 @@ def instantiate_waku_nodes(waku_topology, same_toml_configuration):
|
||||
waku_service = add_service(
|
||||
service_id=wakunode_name,
|
||||
config=struct(
|
||||
image=IMAGE_NAME,
|
||||
image=WAKU_IMAGE,
|
||||
ports={
|
||||
WAKU_RPC_PORT_ID: struct(number=TCP_PORT, protocol="TCP"),
|
||||
PROMETHEUS_PORT_ID: struct(number=PROMETHEUS_TCP_PORT, protocol="TCP")
|
||||
@@ -139,13 +140,73 @@ def send_test_messages(topology_information):
|
||||
send_waku_message(wakunode_name, "test")
|
||||
|
||||
|
||||
def generate_template_data(services):
|
||||
template_data = {}
|
||||
node_data = []
|
||||
for wakunode_name in services.keys():
|
||||
node_data.append(
|
||||
services[wakunode_name]["service"].ip_address + ":" + str(services[wakunode_name]["service"].ports[
|
||||
PROMETHEUS_PORT_ID].number))
|
||||
|
||||
template_data["targets"] = node_data
|
||||
|
||||
return template_data
|
||||
|
||||
|
||||
def create_prometheus_targets(services):
|
||||
# get ip and ports of all nodes
|
||||
template_data = generate_template_data(services)
|
||||
|
||||
# template
|
||||
template = "[{\"labels\": {\"job\": \"wakurtosis\"}, \"targets\" : [{{.targets}}] } ]"
|
||||
|
||||
artifact_id = render_templates(
|
||||
config={
|
||||
"/tmp/targets.json": struct(
|
||||
template=template,
|
||||
data=template_data,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def set_up_prometheus(services):
|
||||
# Create targets.json
|
||||
|
||||
create_prometheus_targets(services)
|
||||
|
||||
# Set up prometheus
|
||||
CONFIG_LOCATION = "/tmp"
|
||||
artifact_id = upload_files(
|
||||
src=PROMETHEUS_CONFIGURATION_PATH
|
||||
)
|
||||
prometheus_service = add_service(
|
||||
service_id="prometheus",
|
||||
config=struct(
|
||||
image=PROMETHEUS_IMAGE,
|
||||
ports={
|
||||
WAKU_RPC_PORT_ID: struct(number=TCP_PORT, protocol="TCP"),
|
||||
PROMETHEUS_PORT_ID: struct(number=PROMETHEUS_TCP_PORT, protocol="TCP")
|
||||
},
|
||||
files={
|
||||
artifact_id: CONFIG_LOCATION
|
||||
},
|
||||
cmd=[
|
||||
"--config.file=" + CONFIG_LOCATION + "/prometheus.yml"
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
return prometheus_service
|
||||
|
||||
|
||||
def run(args):
|
||||
contents = read_file(src="github.com/logos-co/wakurtosis/kurtosis-module/starlark/waku_test_topology.json")
|
||||
waku_topology = read_file(src="github.com/logos-co/wakurtosis/kurtosis-module/starlark/waku_test_topology.json")
|
||||
|
||||
same_toml_configuration = args.same_toml_configuration
|
||||
# decoded = json.decode(contents)
|
||||
# waku_topology = json.decode(waku_topology)
|
||||
|
||||
decoded = {
|
||||
waku_topology = {
|
||||
"waku_0": {
|
||||
"ports_shift": 0,
|
||||
"topics": "test",
|
||||
@@ -162,8 +223,11 @@ def run(args):
|
||||
}
|
||||
}
|
||||
|
||||
services = instantiate_waku_nodes(decoded, same_toml_configuration)
|
||||
services = instantiate_waku_nodes(waku_topology, same_toml_configuration)
|
||||
|
||||
interconnect_waku_nodes(decoded, services)
|
||||
# Set up prometheus + graphana
|
||||
set_up_prometheus(services)
|
||||
|
||||
send_test_messages(decoded)
|
||||
interconnect_waku_nodes(waku_topology, services)
|
||||
|
||||
send_test_messages(waku_topology)
|
||||
|
||||
@@ -10,4 +10,4 @@ scrape_configs:
|
||||
scrape_interval: 1s
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- 'targets.json'
|
||||
- '/tmp/targets.json'
|
||||
Reference in New Issue
Block a user