Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9ddc144
Updating README file and rebasing
ayefimov-1 Feb 3, 2026
99b320f
Review Changes
ayefimov-1 Apr 16, 2026
6c10d04
Removing internal variables from README
ayefimov-1 Apr 20, 2026
d5a3ec6
Validates chargeback data is generated and then
ayefimov-1 Feb 3, 2026
da2f3df
Review Changes
ayefimov-1 Apr 16, 2026
1d35938
Delete roles/telemetry_chargeback/.gitignore (#353)
elfiesmelfie Apr 17, 2026
8ed2835
Validates chargeback data is generated and then
ayefimov-1 Feb 3, 2026
d2bbe9c
Method to select telemetry_chargeback scenarios to run that do not re…
myadla Apr 16, 2026
1b3e334
Use Ansible blocks to group conditional scenario selection logic
myadla Apr 17, 2026
1b78dde
Merge pull request #349 from infrawatch/myadla_neg_tests
myadla Apr 20, 2026
46db84b
Merge branch 'master' into alexy_ck_get_cost
ayefimov-1 Apr 21, 2026
815cc32
Merge branch 'master' into alexy_ck_get_cost
ayefimov-1 Apr 21, 2026
0cb1ea9
Merge branch 'master' into alexy_ck_get_cost
ayefimov-1 Apr 28, 2026
7e9e88a
Add updated db summary output to be more consistent
ayefimov-1 Apr 29, 2026
1577d50
Merge branch 'master' into alexy_ck_get_cost
ayefimov-1 Apr 30, 2026
bd4fad8
telemetry_chargeback now allows test scenario list
ayefimov-1 May 4, 2026
78e2d8f
ayefimov-1 Apr 21, 2026
09c5dbc
remove loki_rate file
ayefimov-1 Apr 22, 2026
7189d24
added --ascending/--descending flags for generating
ayefimov-1 Apr 22, 2026
02cd181
Updating README file.
ayefimov-1 Apr 22, 2026
8904220
Add ability to pass test scenario list via extra-vars
ayefimov-1 Apr 23, 2026
b6f1196
Allow test scenario list to be passed as extra-vars value
ayefimov-1 Apr 23, 2026
abf5019
Add the ability to pass test scenario list via
ayefimov-1 Apr 27, 2026
8c0ad60
Add cloudkitty_debug_dir to README variable table
ayefimov-1 May 6, 2026
1cf9456
Delete .gitignore
ayefimov-1 May 19, 2026
15a1bf3
Merge branch 'master' into alexy_ck_job_6
ayefimov-1 May 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions roles/telemetry_chargeback/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ openstackpod: "openstackclient"
# Time window settings
lookback: 6
limit: 50

# List of test scenario files to run
cloudkitty_test_scenarios: []
6 changes: 3 additions & 3 deletions roles/telemetry_chargeback/files/gen_synth_loki_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get_value_for_step(
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%dT%H:%M:%S+00:00'
datefmt='%Y-%m-%dT%H:%M:%SZ'
)
logger = logging.getLogger()

Expand All @@ -62,11 +62,11 @@ def _format_timestamp(epoch_seconds: float, invalid_timestamp: str) -> str:
invalid_timestamp (str): String to return for invalid timestamps.

Returns:
str: The formatted datetime string (e.g., "2023-10-26T14:30:00+00:00").
str: The formatted datetime string (e.g., "2023-10-26T14:30:00Z").
"""
try:
dt_object = datetime.fromtimestamp(epoch_seconds, tz=timezone.utc)
return dt_object.isoformat()
return dt_object.strftime('%Y-%m-%dT%H:%M:%SZ')
except (ValueError, TypeError):
logger.warning(f"Invalid epoch value provided: {epoch_seconds}")
return invalid_timestamp
Expand Down
71 changes: 71 additions & 0 deletions roles/telemetry_chargeback/tasks/retrieve_loki_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
- name: "Expected Count {{ scenario_name }}"
ansible.builtin.debug:
msg: "Input file has {{ synth_data_rates.data_log.log_count }} data entries that Loki has to return"

# Query Loki
- name: "Retrieve Logs from Loki via API {{ scenario_name }}"
block:
- name: "Query Loki API"
ansible.builtin.uri:
url: "{{ loki_query_url }}?query={{ logql_query | urlencode }}&start={{ synth_data_rates.time.begin_step.nanosec }}&limit={{ limit }}"
method: GET
client_cert: "{{ cert_dir }}/tls.crt"
client_key: "{{ cert_dir }}/tls.key"
ca_path: "{{ cert_dir }}/ca.crt"
validate_certs: false
return_content: true
body_format: json
register: loki_response
# Wait condition
until:
- loki_response.status == 200
- loki_response.json.status == 'success'
- loki_response.json.data.result | length > 0
- (loki_response.json.data.result | map(attribute='values') | map('length') | sum) >= (synth_data_rates.data_log.log_count | int)
retries: 25
delay: 60

- name: "Save Loki Data to JSON file"
ansible.builtin.copy:
content: "{{ loki_response.json | to_json }}"
dest: "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}"
mode: '0644'

# Validate
- name: "Verify Data Integrity {{ scenario_name }}"
vars:
actual_count: "{{ loki_response.json.data.result | map(attribute='values') | map('length') | sum }}"
ansible.builtin.assert:
that:
- loki_response.json.status == 'success'
- loki_response.json.data.result | length > 0
- actual_count | int == (synth_data_rates.data_log.log_count | int)
fail_msg: >-
Query did not return all data entries. Expected
{{ synth_data_rates.data_log.log_count }} log entries, but Loki
only returned {{ actual_count }}
success_msg: "Query returned all data entries. Input file had {{ synth_data_rates.data_log.log_count }} entries and Loki returned {{ actual_count }}"

rescue:
- name: "Debug failure"
ansible.builtin.debug:
msg:
- "Status: {{ loki_response.status | default('Unknown') }}"
- "Body: {{ loki_response.content | default('No Content') }}"
- "Msg: {{ loki_response.msg | default('Request failed') }}"

# Failure
- name: "Report Retrieval Failure"
ansible.builtin.fail:
msg: "Retrieval Failed"

- name: "Generate chargeback stats from Loki-retrieved data file: {{ scenario_name }}"
ansible.builtin.command:
cmd: >
python3 "{{ cloudkitty_summary_script }}"
-j "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_data_suffix }}"
-o "{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_loki_totals_metrics_suffix }}"
--debug "{{ cloudkitty_debug_dir }}"
register: synth_rating_info
changed_when: synth_rating_info.rc == 0
7 changes: 3 additions & 4 deletions roles/telemetry_chargeback/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
cloudkitty_synth_script: "{{ role_path }}/files/gen_synth_loki_data.py"
cloudkitty_data_template: "{{ role_path }}/templates/loki_data_templ.j2"
cloudkitty_summary_script: "{{ role_path }}/files/gen_db_summary.py"

# Legacy variables (deprecated, kept for compatibility)
ck_data_config: "{{ role_path }}/files/test_static.yml"
ck_output_file_local: "{{ artifacts_dir_zuul }}/loki_synth_data.json"
ck_output_file_remote: "{{ logs_dir_zuul }}/gen_loki_synth_data.log"

# Scenario and script paths (using role_path)
cloudkitty_scenario_dir: "{{ role_path }}/files"
cloudkitty_summary_script: "{{ role_path }}/files/gen_db_summary.py"

# File naming conventions (internal standardization)
cloudkitty_synth_data_suffix: "-synth_data.json"
cloudkitty_loki_data_suffix: "-loki_data.json"
Expand Down
Loading