docstr: Creates the grafana configurations that are by default provided by Ray.
docstr_tok: ["Creates","the","grafana","configurations","that","are","by","default","provided","by","Ray","."]
code: def _create_default_grafana_configs(self):
      """
      Creates the grafana configurations that are by default provided by Ray.
      """
      grafana_config_output_path = os.path.join(
          self._metrics_root, "grafana"
      )
  
      # Copy default grafana configurations
      if os.path.exists(grafana_config_output_path):
          shutil.rmtree(grafana_config_output_path)
      os.makedirs(
          os.path.dirname(grafana_config_output_path), exist_ok=True
      )
      shutil.copytree(
          GRAFANA_CONFIG_INPUT_PATH, grafana_config_output_path
      )
  
      # Overwrite grafana's dashboard provisioning directory based on env var
      dashboard_provisioning_path = os.path.join(
          grafana_config_output_path, "provisioning", "dashboards"
      )
      os.makedirs(
          dashboard_provisioning_path,
          exist_ok=True,
      )
      with open(
          os.path.join(
              dashboard_provisioning_path,
              "default.yml",
          ),
          "w",
      ) as f:
          f.write(
              DASHBOARD_PROVISIONING_TEMPLATE.format(
                  dashboard_output_folder=self._grafana_dashboard_output_dir
              )
          )
  
      # Overwrite grafana's prometheus datasource based on env var
      prometheus_host = os.environ.get(
          PROMETHEUS_HOST_ENV_VAR, DEFAULT_PROMETHEUS_HOST
      )
      data_sources_path = os.path.join(
          grafana_config_output_path, "provisioning", "datasources"
      )
      os.makedirs(
          data_sources_path,
          exist_ok=True,
      )
      os.makedirs(
          self._grafana_dashboard_output_dir,
          exist_ok=True,
      )
      with open(
          os.path.join(
              data_sources_path,
              "default.yml",
          ),
          "w",
      ) as f:
          f.write(
              GRAFANA_DATASOURCE_TEMPLATE.format(
                  prometheus_host=prometheus_host,
                  prometheus_name=self._prometheus_name,
              )
          )
      with open(
          os.path.join(
              self._grafana_dashboard_output_dir,
              "default_grafana_dashboard.json",
          ),
          "w",
      ) as f:
          (
              content,
              self._dashboard_uids["default"],
          ) = generate_default_grafana_dashboard()
          f.write(content)
      with open(
          os.path.join(
              self._grafana_dashboard_output_dir,
              "serve_grafana_dashboard.json",
          ),
          "w",
      ) as f:
          (
              content,
              self._dashboard_uids["serve"],
          ) = generate_serve_grafana_dashboard()
          f.write(content)
      with open(
          os.path.join(
              self._grafana_dashboard_output_dir,
              "serve_deployment_grafana_dashboard.json",
          ),
          "w",
      ) as f:
          (
              content,
              self._dashboard_uids["serve_deployment"],
          ) = generate_serve_deployment_grafana_dashboard()
          f.write(content)
      with open(
          os.path.join(
              self._grafana_dashboard_output_dir,
              "data_grafana_dashboard.json",
          ),
          "w",
      ) as f:
          (
              content,
              self._dashboard_uids["data"],
          ) = generate_data_grafana_dashboard()
          f.write(content)
  
imports: import asyncio
  import aiohttp
  import logging
  import os
  import shutil
  from typing import Optional
  import psutil
  from urllib.parse import quote
  from ray.dashboard.modules.metrics.grafana_dashboard_factory import generate_default_grafana_dashboard, generate_serve_grafana_dashboard, generate_serve_deployment_grafana_dashboard, generate_data_grafana_dashboard
  from ray.dashboard.modules.metrics.grafana_datasource_template import GRAFANA_DATASOURCE_TEMPLATE
  from ray.dashboard.modules.metrics.grafana_dashboard_provisioning_template import DASHBOARD_PROVISIONING_TEMPLATE
  import ray.dashboard.optional_utils
  import ray.dashboard.utils
  from ray.dashboard.consts import AVAILABLE_COMPONENT_NAMES_FOR_METRICS
label_desc: Use image node_id 3 for calling the MetricsHead obj's underlying member method code with example usage: obj._create_default_grafana_configs() without return types