You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get chargeback data results from loki and validate
that the total cost is correct
Used Gemini and Cursor
Validates chargeback total cost
- uses synth data to calculate total cost via script
- run "openstack rating summary get" to get total cost from loki
- compares script_totals and Loki_Totals if same then job passes
Closes: https://issues.redhat.com/browse/OSPRH-26066
Copy file name to clipboardExpand all lines: roles/telemetry_chargeback/README.md
+50-7Lines changed: 50 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ The **`telemetry_chargeback`** role is designed to test the **RHOSO Cloudkitty**
5
5
The role performs two main functions:
6
6
7
7
1.**CloudKitty Validation** - Enables and configures the CloudKitty hashmap rating module, then validates its state.
8
-
2.**Synthetic Data Generation** - Generates synthetic Loki log data for testing chargeback scenarios using a Python script and Jinja2 template.
8
+
2.**Synthetic Data Generation & Analysis** - Generates synthetic Loki log data for testing chargeback scenarios and calculates metric totals. The role automatically discovers and processes all scenario files matching `test_*.yml` in the `files/` directory. For each scenario it runs: generate synthetic data, compute syn-totals, ingest to Loki, flush Loki ingester memory, and get cost via CloudKitty rating summary (using begin/end from syn-totals). Retrieve-from-Loki is available but currently commented out in the task flow.
9
9
10
10
Requirements
11
11
------------
@@ -15,14 +15,15 @@ It relies on the following being available on the target or control host:
15
15
* The **OpenStack CLI client** must be installed and configured with administrative credentials.
16
16
* Required Python libraries for the `openstack` CLI (e.g., `python3-openstackclient`).
17
17
* Connectivity to the OpenStack API endpoint.
18
-
***Python 3** with the following libraries for synthetic data generation:
18
+
***Python 3** with the following libraries for synthetic data generation and analysis:
19
19
*`PyYAML`
20
20
*`Jinja2`
21
21
22
22
It is expected to be run **after** a successful deployment and configuration of the following components:
23
23
24
24
***OpenStack:** A functional OpenStack cloud (RHOSO) environment.
25
25
***Cloudkitty:** The Cloudkitty service must be installed, configured, and running.
26
+
***Loki / OpenShift (for ingest and flush):** When using ingest and flush tasks, the control host must have `oc` CLI access, and the Cloudkitty Loki stack (route, certificates, ingester) must be deployed. The role sets Loki push/query URLs and extracts certificates via `setup_loki_env.yml`.
26
27
27
28
Role Variables
28
29
--------------
@@ -42,22 +43,64 @@ These variables are used internally by the role and typically do not need to be
42
43
|----------|---------------|-------------|
43
44
|`logs_dir_zuul`|`/home/zuul/ci-framework-data/logs`| Remote directory for log files. |
44
45
|`artifacts_dir_zuul`|`/home/zuul/ci-framework-data/artifacts`| Directory for generated artifacts. |
|`ck_begin_end_suffix`|`_begin_end.yml`| Suffix for begin/end timestamp output files. |
45
52
|`ck_synth_script`|`{{ role_path }}/files/gen_synth_loki_data.py`| Path to the synthetic data generation script. |
46
-
|`ck_data_template`|`{{ role_path }}/template/loki_data_templ.j2`| Path to the Jinja2 template for Loki data format. |
47
-
|`ck_data_config`|`{{ role_path }}/files/test_static.yml`| Path to the scenario configuration file. |
48
-
|`ck_output_file_local`|`{{ artifacts_dir_zuul }}/loki_synth_data.json`| Local path for generated synthetic data. |
49
-
|`ck_output_file_remote`|`{{ logs_dir_zuul }}/gen_loki_synth_data.log`| Remote destination for synthetic data. |
53
+
|`ck_data_template`|`{{ role_path }}/templates/loki_data_templ.j2`| Path to the Jinja2 template for Loki data format. |
54
+
|`ck_totals_script`|`{{ role_path }}/files/gen_synth_loki_metrics.totals.py`| Path to the metric totals calculation script. |
55
+
56
+
### Loki / OpenShift Variables (vars/main.yml)
57
+
58
+
Used by setup, ingest, flush, and retrieve tasks when running against Loki on OpenShift:
59
+
60
+
| Variable | Default Value | Description |
61
+
|----------|---------------|-------------|
62
+
|`cert_secret_name`|`cert-cloudkitty-client-internal`| OpenShift secret name for client certificates. |
63
+
|`cert_dir`|`{{ ansible_user_dir }}/ck-certs`| Local directory for extracted ingest/query certs. |
64
+
|`client_secret`|`secret/cloudkitty-lokistack-gateway-client-http`| Secret for flush client certs. |
65
+
|`ca_configmap`|`cm/cloudkitty-lokistack-ca-bundle`| ConfigMap for CA bundle. |
66
+
|`remote_cert_dir`|`osp-certs`| Directory inside the OpenStack pod for certs. |
67
+
|`local_cert_dir`|`{{ ansible_env.HOME }}/flush_certs`| Local directory for flush certs. |
68
+
|`logql_query`|`{service="cloudkitty"}` (overridable via `loki_query`) | LogQL query for Loki. |
69
+
|`ck_namespace`|`openstack`| OpenShift namespace for Cloudkitty/Loki resources. |
70
+
|`openstackpod`|`openstackclient`| OpenStack client pod name for exec/cp. |
71
+
|`lookback`|`6`| Days lookback for Loki query time range. |
72
+
|`limit`|`50`| Limit for Loki query results. |
73
+
74
+
Loki push/query URLs are set dynamically in `setup_loki_env.yml` from the Cloudkitty Loki route.
75
+
76
+
### Dynamically Set Variables (gen_synth_loki_data.yml)
77
+
78
+
These variables are set dynamically for each scenario file during the loop:
79
+
80
+
| Variable | Description |
81
+
|----------|-------------|
82
+
|`ck_data_file`| Local path for generated JSON data (`{{ artifacts_dir_zuul }}/{{ scenario_name }}.json`) |
83
+
|`ck_synth_totals_file`| Local path for calculated metric totals (`{{ artifacts_dir_zuul }}/{{ scenario_name }}_syn-totals.yml`) |
84
+
|`ck_begin_end_timestamp`| Local path for begin/end timestamp file (`{{ artifacts_dir_zuul }}/{{ scenario_name }}_begin_end.yml`) |
85
+
|`ck_test_file`| Path to the scenario configuration file (`{{ ck_scenario_dir }}/{{ scenario_name }}.yml`) |
50
86
51
87
Scenario Configuration
52
88
----------------------
53
-
The synthetic data generation is controlled by a YAML configuration file (`files/test_static.yml`). This file defines:
89
+
The synthetic data generation is controlled by YAML configuration files in the `files/` directory. Any file matching `test_*.yml` will be automatically discovered and processed.
90
+
91
+
Each scenario file defines:
54
92
55
93
***generation** - Time range configuration (days, step_seconds)
56
94
***log_types** - List of log type definitions with name, type, unit, qty, price, groupby, and metadata
57
95
***required_fields** - Fields required for validation
58
96
***date_fields** - Date fields to add to groupby (week_of_the_year, day_of_the_year, month, year)
0 commit comments