import os import runpy import sys import attr sys.path.append(os.path.dirname(__file__)) from common import ( DATASOURCE_INPUT, SERVERLESS_PROMQL_POLICY, use_promql_policy, ) from grafanalib.core import GRAPH_TOOLTIP_MODE_SHARED_CROSSHAIR, Dashboard dashboard_path = os.path.join(os.path.dirname(__file__), "tikv_details.dashboard.py") serverless_dashboard_path = os.path.join( os.path.dirname(__file__), "tikv_details_serverless.dashboard.py" ) details = runpy.run_path(dashboard_path) serverless_details = runpy.run_path(serverless_dashboard_path) worker_promql_policy = attr.evolve( SERVERLESS_PROMQL_POLICY, default_label_selectors=(r'instance=~"${worker_instance:regex}"',), ) with use_promql_policy(worker_promql_policy): panels = [ details["CloudWorkerService"]( copr_process_selector='container="cop-worker"', tikv_worker_process_selector='container="tikv-worker"', copr_worker_prefetch_selectors=[ 'instance=~"$worker_instance"', 'container="cop-worker"', ], ), details["CloudWorkerNativeBR"](), details["CloudWorkerSchemaManager"](), ] worker_ia_policy = attr.evolve( worker_promql_policy, default_label_selectors=( *worker_promql_policy.default_label_selectors, 'container=~"tikv-worker|cop-worker"', ), ) with use_promql_policy(worker_ia_policy): panels.extend( [ details["IA"](), details["WorkerThreadCPU"](), ] ) serverless_templates = serverless_details["ServerlessTemplates"]() worker_templates = attr.evolve( serverless_templates, list=[ template_variable for template_variable in serverless_templates.list if template_variable.name != "instance" ], ) dashboard = Dashboard( title="Starter-Essential-TiKV-Worker-for-Clinic", uid="tikv-worker-serverless", timezone="browser", refresh="1m", inputs=[ attr.evolve(DATASOURCE_INPUT, label="o11y-global-data"), serverless_details["VARIABLES_DATASOURCE_INPUT"], ], editable=True, templating=worker_templates, panels=panels, schemaVersion=14, graphTooltip=GRAPH_TOOLTIP_MODE_SHARED_CROSSHAIR, ).auto_panel_ids()