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
Refactor Prometheus configuration to use flexible label filters
- Replaced prometheus_label_type_instance with two new options:
- vm_uuid_label_name: configurable name of the UUID label (default: "uuid")
- labels: list of key:value pairs for label filters (default: ["type_instance:scaph_process_power_microwatts"])
- Updated _energy_consumed_wh to parse label list and build label dictionary
- Added support for multiple label filters in any combination
- Updated all tests to use new configuration structure
- Regenerated etc/caso/caso.conf.sample with oslo-config-generator
- Updated prometheus-extractor.rst documentation:
- New configuration parameters explained
- Added examples for multiple label filters
- Updated troubleshooting section
- All tests pass (4/4 prometheus tests)
Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
1. **Scans VMs**: Retrieves the list of VMs from Nova for each configured project
45
48
2. **Queries Per VM**: For each VM, executes a Prometheus query using the configured metric name and labels
46
-
3. **Calculates Energy**: Uses the formula `sum_over_time(metric_name{type_instance="value", uuid="vm-uuid"}[query_range]) * (step_seconds/3600) / 1000000` to convert microwatt power samples to Watt-hours
47
-
4. **Creates Records**: Generates an `EnergyRecord` for each VM with energy consumption data and execution metrics
49
+
3. **Builds Labels**: Combines the configured label filters with the VM UUID label (e.g., `{type_instance="scaph_process_power_microwatts", uuid="vm-uuid"}`)
50
+
4. **Calculates Energy**: Uses the formula `sum_over_time(metric_name{labels}[query_range]) * (step_seconds/3600) / 1000000` to convert microwatt power samples to Watt-hours
51
+
5. **Creates Records**: Generates an `EnergyRecord` for each VM with energy consumption data and execution metrics
48
52
49
53
## Configuration Parameters
50
54
51
55
- **prometheus_endpoint**: URL of the Prometheus server (default: `http://localhost:9090`)
52
56
- **prometheus_metric_name**: Name of the metric to query (default: `prometheus_value`)
53
-
- **prometheus_label_type_instance**: Value for the `type_instance` label used to filter metrics (default: `scaph_process_power_microwatts`)
57
+
- **vm_uuid_label_name**: Name of the label that matches the VM UUID in Prometheus metrics (default: `uuid`)
58
+
- **labels**: List of label filters as `key:value` pairs to filter the Prometheus metric. The VM UUID label will be added automatically (default: `["type_instance:scaph_process_power_microwatts"]`)
54
59
- **prometheus_step_seconds**: Frequency between samples in the time series, in seconds (default: `30`)
55
60
- **prometheus_query_range**: Time range for the query (default: `1h`). Examples: `1h`, `6h`, `24h`
56
61
- **prometheus_verify_ssl**: Whether to verify SSL certificates when connecting to Prometheus (default: `true`)
@@ -65,7 +70,8 @@ Scaphandre exports energy metrics in microwatts:
0 commit comments