|
RTC Toolkit 6.0.0
|
Classes | |
| class | GrafanaConfig |
| Simple data class holding configuration for Grafana. More... | |
Functions | |
| dict|None | fetch_json (str url, GrafanaConfig config) |
| Helper function fetching JSON from Grafana REST API. | |
| dict|None | post_json (str url, dict payload, GrafanaConfig config) |
| Helper function sending JSON payload to Grafana REST API via POST method. | |
| dict|None | put_json (str url, dict payload, GrafanaConfig config) |
| Helper function sending JSON payload to Grafana REST API via PUT method. | |
| dict|None | patch_json (str url, dict payload, GrafanaConfig config) |
| Helper function sending JSON payload to Grafana REST API via PATCH method. | |
| dict|None | del_req (str url, GrafanaConfig config) |
| Helper function sending DELETE request to Grafana REST API. | |
| ensure_dir (str path) | |
| Creates directory if it doesn't exist. | |
| find_json_files (str path) | |
| Returns a list of .json files in the given directory. | |
| load_json_file (str path) | |
| Load and return JSON data from the given file. | |
| save_json (str path, dict data) | |
| Save dictionary as JSON to the given file with formatting. | |
| str | format_title (str title) |
| Convert a title string to lowercase with underscores instead of spaces. | |
| str | format_name (str name) |
| Convert a name string to lowercase, underscores, and remove slashes. | |
| export_data_sources (GrafanaConfig config) | |
| Export all Grafana data sources to JSON files in the configured data directory. | |
| export_folders (GrafanaConfig config) | |
| Export all Grafana folders to the configured data directory. | |
| export_dashboards (GrafanaConfig config) | |
| Export all Grafana dashboards to JSON files in the configured data directory. | |
| export_library_panels (GrafanaConfig config) | |
| Export all Grafana libary pannels to JSON files in the configured data directory. | |
| export_alerts (GrafanaConfig config) | |
| Export all Grafana alerts to JSON files in the configured data directory. | |
| import_data_sources (GrafanaConfig config, str secrets) | |
| Import data sources into Grafana, optionally injecting secret tokens. | |
| import_folders (GrafanaConfig config) | |
| Import Grafana folders from JSON files, creating or updating them. | |
| import_dashboards (GrafanaConfig config) | |
| Import Grafana dashboards from JSON files, creating or updating them. | |
| import_library_panels (GrafanaConfig config) | |
| Import Grafana library panels from JSON files, creating or updating them. | |
| import_alerts (GrafanaConfig config) | |
| Import Grafana alerts from JSON files, creating or updating them. | |
| rtctk_grafana_import (uri=None, token=None, data_dir=None, secrets=None) | |
| Import all Grafana resources in a specific order: data sources, folders, alerts, library panels, and dashboards. | |
| rtctk_grafana_export (uri=None, token=None, data_dir=None) | |
| Export Grafana resources from API and saves them as JSON files in the configured data directory. | |
| rtctk_grafana_cleanup (uri=None, token=None, data_dir=None) | |
| Remove all Grafana resources previously exported or imported from the data directory. | |
Variables | |
| logger = CiiLogManager.get_logger() | |
| int | REQ_TIMEOUT = 10 |
| dict | None grafana.grafana_widget_tool.del_req | ( | str | url, |
| GrafanaConfig | config ) |
Helper function sending DELETE request to Grafana REST API.
| grafana.grafana_widget_tool.ensure_dir | ( | str | path | ) |
Creates directory if it doesn't exist.
| grafana.grafana_widget_tool.export_alerts | ( | GrafanaConfig | config | ) |
Export all Grafana alerts to JSON files in the configured data directory.
| grafana.grafana_widget_tool.export_dashboards | ( | GrafanaConfig | config | ) |
Export all Grafana dashboards to JSON files in the configured data directory.
| grafana.grafana_widget_tool.export_data_sources | ( | GrafanaConfig | config | ) |
Export all Grafana data sources to JSON files in the configured data directory.
| grafana.grafana_widget_tool.export_folders | ( | GrafanaConfig | config | ) |
Export all Grafana folders to the configured data directory.
| grafana.grafana_widget_tool.export_library_panels | ( | GrafanaConfig | config | ) |
Export all Grafana libary pannels to JSON files in the configured data directory.
| dict | None grafana.grafana_widget_tool.fetch_json | ( | str | url, |
| GrafanaConfig | config ) |
Helper function fetching JSON from Grafana REST API.
| grafana.grafana_widget_tool.find_json_files | ( | str | path | ) |
Returns a list of .json files in the given directory.
Logs warnings if none found.
| str grafana.grafana_widget_tool.format_name | ( | str | name | ) |
Convert a name string to lowercase, underscores, and remove slashes.
| str grafana.grafana_widget_tool.format_title | ( | str | title | ) |
Convert a title string to lowercase with underscores instead of spaces.
| grafana.grafana_widget_tool.import_alerts | ( | GrafanaConfig | config | ) |
Import Grafana alerts from JSON files, creating or updating them.
| grafana.grafana_widget_tool.import_dashboards | ( | GrafanaConfig | config | ) |
Import Grafana dashboards from JSON files, creating or updating them.
| grafana.grafana_widget_tool.import_data_sources | ( | GrafanaConfig | config, |
| str | secrets ) |
Import data sources into Grafana, optionally injecting secret tokens.
| grafana.grafana_widget_tool.import_folders | ( | GrafanaConfig | config | ) |
Import Grafana folders from JSON files, creating or updating them.
| grafana.grafana_widget_tool.import_library_panels | ( | GrafanaConfig | config | ) |
Import Grafana library panels from JSON files, creating or updating them.
| grafana.grafana_widget_tool.load_json_file | ( | str | path | ) |
Load and return JSON data from the given file.
| dict | None grafana.grafana_widget_tool.patch_json | ( | str | url, |
| dict | payload, | ||
| GrafanaConfig | config ) |
Helper function sending JSON payload to Grafana REST API via PATCH method.
| dict | None grafana.grafana_widget_tool.post_json | ( | str | url, |
| dict | payload, | ||
| GrafanaConfig | config ) |
Helper function sending JSON payload to Grafana REST API via POST method.
| dict | None grafana.grafana_widget_tool.put_json | ( | str | url, |
| dict | payload, | ||
| GrafanaConfig | config ) |
Helper function sending JSON payload to Grafana REST API via PUT method.
| grafana.grafana_widget_tool.rtctk_grafana_cleanup | ( | uri = None, | |
| token = None, | |||
| data_dir = None ) |
Remove all Grafana resources previously exported or imported from the data directory.
This function scans the configured data directory for JSON files corresponding to dashboards, library panels, alerts, folders, and data sources. It then deletes each resource from the Grafana instance using the UIDs of each resource.
| grafana.grafana_widget_tool.rtctk_grafana_export | ( | uri = None, | |
| token = None, | |||
| data_dir = None ) |
Export Grafana resources from API and saves them as JSON files in the configured data directory.
| grafana.grafana_widget_tool.rtctk_grafana_import | ( | uri = None, | |
| token = None, | |||
| data_dir = None, | |||
| secrets = None ) |
Import all Grafana resources in a specific order: data sources, folders, alerts, library panels, and dashboards.
| grafana.grafana_widget_tool.save_json | ( | str | path, |
| dict | data ) |
Save dictionary as JSON to the given file with formatting.
| grafana.grafana_widget_tool.logger = CiiLogManager.get_logger() |
| int grafana.grafana_widget_tool.REQ_TIMEOUT = 10 |