telemetry.k8s.krkn_telemetry_kubernetes module
- class telemetry.k8s.krkn_telemetry_kubernetes.KrknTelemetryKubernetes(safe_logger: SafeLogger, lib_kubernetes: KrknKubernetes, krkn_telemetry_config: dict[str, any] | None = None, telemetry_request_id: str = '')
Bases:
object
- __init__(safe_logger: SafeLogger, lib_kubernetes: KrknKubernetes, krkn_telemetry_config: dict[str, any] | None = None, telemetry_request_id: str = '')
- collect_cluster_metadata(chaos_telemetry: ChaosRunTelemetry)
Collects useful cluster metadata: - cloud infrastructure - network plugins - number of objects deployed - node system infos to enrich the ChaosRunTelemetry object that will be sent to the telemetry service:
- Parameters:
chaos_telemetry – the chaos telemetry to be enriched by the cluster metadata
- default_telemetry_group = 'default'
- generate_url_and_put_to_s3_worker(queue: Queue, queue_size: int, request_id: str, telemetry_group: str, api_url: str, username: str, password: str, thread_number: int, uploaded_file_list: list[str], max_retries: int, remote_file_prefix: str, remote_file_extension: str)
Worker function that creates an s3 link to put files and upload the file directly on the bucket.
- Parameters:
queue – queue that will be consumed. The queue elements must be tuples on which the first item must be the file sequence number, the second a local filename full-path that will be uploaded in the S3 bucket and the third will be a retry counter updated by the thread on upload exception and compared with max_retries.
queue_size – total number of files
request_id – uuid of the session that will represent the folder on which the prometheus files will be stored within the respective group
telemetry_group – the group of telemetry on which the file will be stored. The group will be the folder starting from the S3 bucket root
api_url – API endpoint to generate the S3 temporary link
username – API username
password – API password
thread_number – Thread number
uploaded_file_list – uploaded file list shared between threads
max_retries – maximum number of retries from config.yaml. If 0 will retry indefinitely.
remote_file_prefix – the prefix that will given to the file in the S3 bucket along with the progressive number (if is a multiple file archive)
remote_file_extension – the extension of the remote file on the S3 bucket
- Returns:
- get_bucket_url_for_filename(api_url: str, bucket_folder: str, remote_filename: str, username: str, password: str) str
Gets from the telemetry API a one shot S3 link to upload prometheus data
- Parameters:
api_url – telemetry base URL
bucket_folder – folder on which the prometheus archives will be stored
remote_filename – name of the file that will be stored in the bucket
username – API username
password – API password
- Returns:
the url where the file will be uploaded
- get_lib_kubernetes() KrknKubernetes
Returns the instance of KrknKubernetes
- Returns:
a KrknKubernetes instance
- get_prometheus_pod_data(telemetry_config: dict, request_id: str, prometheus_pod_name: str, prometheus_container_name: str, prometheus_namespace: str, remote_archive_path: str = '/prometheus') list[int, str]
Downloads the prometheus metrics folder from a prometheus pod
- Parameters:
telemetry_config – krkn telemetry conf section will be stored
request_id – uuid of the session that will represent the temporary archive files
prometheus_pod_name – the name of the prometheus pod from which the data will be archived
prometheus_container_name – the name of the container in the prometheus pod
prometheus_namespace – the namespace in which the prometheus pod lives
remote_archive_path – (Optional) the path where prometheus logs are stored, if not specified will default to /prometheus
- Returns:
the list of the archive number and filenames downloaded
- get_telemetry_config() dict[str, any]
Returns the telemetry config section from config.yaml
- Returns:
the telemetry config section
- get_telemetry_request_id() str
Gets the telemetry request id that represents the path on S3 where the telemetry data is uploaded
- Returns:
the krkn telemetry id
- put_critical_alerts(request_id: str, telemetry_config: dict, alerts: ChaosRunAlertSummary)
Puts collected critical alerts on the S3 bucket
- Parameters:
request_id – uuid of the session that will represent the S3 folder on which the prometheus files will be stored
telemetry_config – telemetry section of kraken config.yaml
alerts – list of strings representing the alert log lines printed to stdout
- put_file_to_url(url: str, local_filename: str)
Puts a local file on an url :param url: url where the file will be put :param local_filename: local file full-path
- put_prometheus_data(telemetry_config: dict, archive_volumes: list[int, str], request_id: str)
Puts a list of files on telemetry S3 bucket, multithreading.
- Parameters:
telemetry_config – telemetry section of kraken config.yaml
archive_volumes – a list of tuples containing the archive number, and the archive full path to be uploaded
request_id – uuid of the session that will represent the S3 folder on which the prometheus files will be stored
- safe_logger: SafeLogger = None
- send_telemetry(telemetry_config: dict, uuid: str, chaos_telemetry: ChaosRunTelemetry) str | None
Sends Telemetry Data to the Telemetry Web Service
- Parameters:
telemetry_config – krkn telemetry conf section
uuid – uuid used as folder in S3 bucket
chaos_telemetry – already populated ChaosRunTelemetry object
- Returns:
the telemetry object json string
- set_parameters_base64(scenario_telemetry: ScenarioTelemetry, file_path: str) dict