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
Update documentation and remove requests dependency
- Removed requests dependency from pyproject.toml (no longer needed)
- Updated prometheus-extractor.rst with new configuration parameters:
- Documented prometheus_metric_name, prometheus_label_type_instance
- Documented prometheus_step_seconds, prometheus_query_range, prometheus_verify_ssl
- Removed old prometheus_query and prometheus_timeout references
- Added detailed explanation of energy calculation formula
- Updated examples for Scaphandre and custom metrics
- Updated troubleshooting section
- Updated configuration.rst with new prometheus section:
- Documented all new configuration options
- Added reference to prometheus-extractor.rst
- Explained energy calculation from microwatt samples
- Updated etc/caso/caso.conf.sample with new prometheus configuration options
- Updated poetry.lock to reflect dependency changes
- All tests pass (6/6 energy-related tests)
Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
Copy file name to clipboardExpand all lines: doc/source/prometheus-extractor.rst
+93-46Lines changed: 93 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ This document provides information on using the Prometheus extractor to gather e
6
6
7
7
The Prometheus extractor queries a Prometheus instance to retrieve energy consumption metrics for each VM in the configured projects and generates `EnergyRecord` objects that can be published through cASO's messenger system.
8
8
9
+
The extractor uses the `prometheus-api-client` library to connect to Prometheus and calculate energy consumption in Watt-hours (Wh) from instantaneous power samples stored in Prometheus.
10
+
9
11
## Configuration
10
12
11
13
To use the Prometheus extractor, add the following configuration to your `caso.conf` file:
# Timeout for Prometheus API requests (in seconds)
27
-
prometheus_timeout = 30
33
+
# Query time range (e.g., '1h', '6h', '24h')
34
+
prometheus_query_range = 1h
35
+
36
+
# Whether to verify SSL when connecting to Prometheus
37
+
prometheus_verify_ssl = true
28
38
```
29
39
30
40
## How It Works
31
41
32
42
The Prometheus extractor:
33
43
34
44
1. **Scans VMs**: Retrieves the list of VMs from Nova for each configured project
35
-
2. **Queries Per VM**: For each VM, executes a customizable Prometheus query
36
-
3. **Template Variables**: Replaces `{{uuid}}` in the query with the actual VM UUID
37
-
4. **Creates Records**: Generates an `EnergyRecord` for each VM with energy consumption data
45
+
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
38
48
39
-
## Customizing the PromQL Query
49
+
## Configuration Parameters
40
50
41
-
The query template can use `{{uuid}}` as a placeholder for the VM UUID. The default query assumes you have energy consumption metrics labeled with the VM UUID.
51
+
- **prometheus_endpoint**: URL of the Prometheus server (default: `http://localhost:9090`)
52
+
- **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`)
54
+
- **prometheus_step_seconds**: Frequency between samples in the time series, in seconds (default: `30`)
55
+
- **prometheus_query_range**: Time range for the query (default: `1h`). Examples: `1h`, `6h`, `24h`
56
+
- **prometheus_verify_ssl**: Whether to verify SSL certificates when connecting to Prometheus (default: `true`)
0 commit comments