mirror of https://github.com/vacp2p/wakurtosis.git
Refactored grafana+prometheus star files, created new .star for templating. Added more system variables.
This commit is contained in:
parent
3066f594c7
commit
ae5982d1b9
|
@ -3,34 +3,17 @@ system_variables = import_module("github.com/logos-co/wakurtosis/src/system_vari
|
|||
|
||||
# Module Imports
|
||||
files = import_module(system_variables.FILE_HELPERS_MODULE)
|
||||
|
||||
# todo pasar templates a .star
|
||||
def get_prometheus_template_content():
|
||||
# template
|
||||
prometheus_template = """
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
org_id: 1
|
||||
url: http://{{.prometheus_url}}
|
||||
is_default: true
|
||||
version: 1
|
||||
editable: true
|
||||
"""
|
||||
|
||||
return prometheus_template
|
||||
templates = import_module(system_variables.TEMPLATES_MODULE)
|
||||
|
||||
|
||||
def set_up_graphana(prometheus_service):
|
||||
config_id, customization_id, dashboard_id = files.upload_files_grafana()
|
||||
prometheus_data = files.generate_template_prometheus_url(prometheus_service)
|
||||
prometheus_template = get_prometheus_template_content()
|
||||
prometheus_template = templates.get_prometheus_template_content_for_grafana()
|
||||
|
||||
artifact_id = render_templates(
|
||||
config={
|
||||
"datasources.yaml": struct(
|
||||
system_variables.CONTAINER_DATASOURCES_FILE_NAME_GRAFANA: struct(
|
||||
template=prometheus_template,
|
||||
data=prometheus_data,
|
||||
)
|
||||
|
@ -38,7 +21,7 @@ def set_up_graphana(prometheus_service):
|
|||
)
|
||||
|
||||
grafana_service = add_service(
|
||||
service_id="grafana",
|
||||
service_id=system_variables.GRAFANA_SERVICE_ID,
|
||||
config=struct(
|
||||
image=system_variables.GRAFANA_IMAGE,
|
||||
ports={
|
||||
|
|
|
@ -3,6 +3,7 @@ system_variables = import_module("github.com/logos-co/wakurtosis/src/system_vari
|
|||
|
||||
# Module Imports
|
||||
files = import_module(system_variables.FILE_HELPERS_MODULE)
|
||||
templates = import_module(system_variables.TEMPLATES_MODULE)
|
||||
|
||||
|
||||
def set_up_prometheus(services):
|
||||
|
@ -10,25 +11,25 @@ def set_up_prometheus(services):
|
|||
targets_artifact_id = create_prometheus_targets(services)
|
||||
|
||||
# Set up prometheus
|
||||
CONFIG_LOCATION = "/test"
|
||||
CONFIG_LOCATION2 = "/tmp"
|
||||
artifact_id = upload_files(
|
||||
src=system_variables.PROMETHEUS_CONFIGURATION_PATH
|
||||
)
|
||||
|
||||
prometheus_service = add_service(
|
||||
service_id="prometheus",
|
||||
service_id=system_variables.PROMETHEUS_SERVICE_ID,
|
||||
config=struct(
|
||||
image=system_variables.PROMETHEUS_IMAGE,
|
||||
ports={
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(number=9090, transport_protocol="TCP")
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.CONTAINER_PROMETHEUS_TCP_PORT, transport_protocol="TCP")
|
||||
},
|
||||
files={
|
||||
CONFIG_LOCATION: artifact_id,
|
||||
CONFIG_LOCATION2: targets_artifact_id
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS: artifact_id,
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS_2: targets_artifact_id
|
||||
},
|
||||
cmd=[
|
||||
"--config.file=" + CONFIG_LOCATION + "/prometheus.yml"
|
||||
"--config.file=" + system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS +
|
||||
system_variables.CONTAINER_CONFIGURATION_FILE_NAME_PROMETHEUS
|
||||
]
|
||||
)
|
||||
)
|
||||
|
@ -38,24 +39,14 @@ def set_up_prometheus(services):
|
|||
|
||||
def create_prometheus_targets(services):
|
||||
# get ip and ports of all nodes
|
||||
template_data = files.generate_template_node_targets(services, system_variables.PROMETHEUS_PORT_ID)
|
||||
template_data = files.generate_template_node_targets(services,
|
||||
system_variables.PROMETHEUS_PORT_ID)
|
||||
|
||||
# template
|
||||
template = """
|
||||
[
|
||||
{
|
||||
"labels": {
|
||||
"job":
|
||||
"wakurtosis"
|
||||
},
|
||||
"targets" : {{.targets}}
|
||||
}
|
||||
]
|
||||
"""
|
||||
template = templates.get_prometheus_template()
|
||||
|
||||
artifact_id = render_templates(
|
||||
config={
|
||||
"targets.json": struct(
|
||||
system_variables.CONTAINER_TARGETS_FILE_NAME_PROMETHEUS: struct(
|
||||
template=template,
|
||||
data=template_data,
|
||||
)
|
||||
|
|
|
@ -14,23 +14,32 @@ WAKU_ENTRYPOINT = ["/usr/bin/wakunode", "--rpc-address=0.0.0.0", "--metrics-serv
|
|||
|
||||
# Prometheus Configuration
|
||||
PROMETHEUS_IMAGE = "prom/prometheus:latest"
|
||||
PROMETHEUS_PORT_ID = "prometheus"
|
||||
PROMETHEUS_SERVICE_ID = "prometheus"
|
||||
PROMETHEUS_PORT_ID = "prometheus_tcp"
|
||||
PROMETHEUS_TCP_PORT = 8008
|
||||
PROMETHEUS_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/monitoring/prometheus.yml"
|
||||
|
||||
CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS = "/test/"
|
||||
CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS_2 = "/tmp/"
|
||||
CONTAINER_CONFIGURATION_FILE_NAME_PROMETHEUS = "prometheus.yml"
|
||||
CONTAINER_TARGETS_FILE_NAME_PROMETHEUS = "targets.json"
|
||||
CONTAINER_PROMETHEUS_TCP_PORT = 9090
|
||||
|
||||
# Grafana Configuration
|
||||
GRAFANA_IMAGE = "grafana/grafana:latest"
|
||||
GRAFANA_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/config/"
|
||||
GRAFANA_CUSTOMIZATION_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/customizations/"
|
||||
GRAFANA_DASHBOARD_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/dashboards/"
|
||||
|
||||
GRAFANA_PORT_ID = "grafana"
|
||||
GRAFANA_SERVICE_ID = "grafana"
|
||||
GRAFANA_PORT_ID = "grafana_tcp"
|
||||
GRAFANA_TCP_PORT = 3000
|
||||
|
||||
CONTAINER_CONFIGURATION_GRAFANA = "/etc/grafana/"
|
||||
CONTAINER_DASHBOARDS_GRAFANA = "/var/lib/grafana/dashboards/"
|
||||
CONTAINER_CUSTOMIZATION_GRAFANA = "/usr/share/grafana/"
|
||||
CONTAINER_DATASOURCES_GRAFANA = "/etc/grafana/provisioning/datasources/"
|
||||
CONTAINER_DATASOURCES_FILE_NAME_GRAFANA = "datasources.yaml"
|
||||
|
||||
# WSL Configuration
|
||||
WSL_IMAGE = "wsl:0.0.1"
|
||||
|
@ -52,6 +61,7 @@ PROMETHEUS_MODULE = "github.com/logos-co/wakurtosis/src/prometheus.star"
|
|||
GRAFANA_MODULE = "github.com/logos-co/wakurtosis/src/grafana.star"
|
||||
ARGUMENT_PARSER_MODULE = "github.com/logos-co/wakurtosis/src/arguments_parser.star"
|
||||
FILE_HELPERS_MODULE = "github.com/logos-co/wakurtosis/src/file_helpers.star"
|
||||
TEMPLATES_MODULE = "github.com/logos-co/wakurtosis/src/templates.star"
|
||||
WSL_MODULE = "github.com/logos-co/wakurtosis/src/wsl.star"
|
||||
|
||||
# Default main starlark arguments
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# GRAFANA
|
||||
def get_prometheus_template_content_for_grafana():
|
||||
# template
|
||||
prometheus_template = """
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
org_id: 1
|
||||
url: http://{{.prometheus_url}}
|
||||
is_default: true
|
||||
version: 1
|
||||
editable: true
|
||||
"""
|
||||
|
||||
return prometheus_template
|
||||
|
||||
# PROMETHEUS
|
||||
def get_prometheus_template():
|
||||
# template
|
||||
template = """
|
||||
[
|
||||
{
|
||||
"labels": {
|
||||
"job":
|
||||
"wakurtosis"
|
||||
},
|
||||
"targets" : {{.targets}}
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
return template
|
Loading…
Reference in New Issue