Skip to content

Commit 69c1e12

Browse files
committed
fix: update documentation for Prometheus extractor and GreenDIGIT CIM messenger configuration
1 parent d73a579 commit 69c1e12

3 files changed

Lines changed: 194 additions & 166 deletions

File tree

doc/source/configuration.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,27 @@ To publish only energy records to logstash::
283283

284284
Options defined here configure the Prometheus extractor for gathering energy
285285
consumption metrics. This extractor uses the ``prometheus-api-client`` library
286-
to query a Prometheus instance and calculate energy consumption from
286+
to query a Prometheus instance and calculate energy consumption from
287287
instantaneous power samples. Available options:
288288

289289
* ``prometheus_endpoint`` (default: ``http://localhost:9090``), Prometheus
290290
server endpoint URL.
291-
* ``prometheus_metric_name`` (default: ``prometheus_value``), Name of the
291+
* ``prometheus_metric_name`` (default: ``prometheus_value``), Name of the
292292
Prometheus metric to query for energy consumption data.
293-
* ``prometheus_label_type_instance`` (default: ``scaph_process_power_microwatts``),
294-
Value for the ``type_instance`` label used to filter metrics in Prometheus.
293+
* ``vm_uuid_label_name`` (default: ``uuid``), Name of the label in the
294+
Prometheus metric that matches the VM UUID.
295+
* ``labels`` (default: ``["type_instance:scaph_process_power_microwatts"]``),
296+
List of label filters expressed as ``key:value`` pairs used to filter the
297+
Prometheus metric. The VM UUID label will be automatically added to the query.
295298
* ``prometheus_step_seconds`` (default: ``30``), Frequency between samples in
296299
the time series, in seconds. This is used to calculate energy from power samples.
297-
* ``prometheus_verify_ssl`` (default: ``true``), Whether to verify SSL
300+
* ``prometheus_verify_ssl`` (default: ``true``), Whether to verify SSL
298301
certificates when connecting to Prometheus.
299302

300303
The extractor calculates energy in Watt-hours (Wh) from microwatt power samples
301-
using the formula: ``sum_over_time(metric{labels}[range]) * (step_seconds/3600) / 1000000``.
304+
using the formula:
305+
306+
``sum_over_time(metric{labels}[range]) * (step_seconds/3600) / 1000000``
302307

303308
To use the Prometheus extractor, add ``prometheus`` to the ``extractor`` option
304309
in the main configuration. For more details, see :doc:`prometheus-extractor`.

doc/source/greendigit_cim_messenger.rst

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,62 @@ energy consumption metrics in cASO.
77
Overview
88
--------
99

10-
The GreenDIGIT CIM messenger sends `EnergyRecord` objects to the GreenDIGIT
10+
The GreenDIGIT CIM messenger sends ``EnergyRecord`` objects to the GreenDIGIT
1111
Common Information Model (CIM) Service. The messenger supports authentication
1212
via bearer token and allows publishing energy consumption data from cASO extractors
1313
to SZTAKI CIM endpoints.
1414

15-
Additionally, the messenger verifies SSL certificates and endpoint availability
15+
Additionally, the messenger verifies SSL certificates and endpoint availability
1616
before publishing to ensure reliability in production environments.
1717

1818
Configuration
1919
-------------
2020

2121
To use the GreenDIGIT CIM messenger, add the following configuration to your
22-
`caso.conf` file:
22+
``caso.conf`` file:
2323

24-
```ini
25-
[DEFAULT]
26-
# Add the messenger to your list of messengers
27-
messengers = greendigit_cim
24+
.. code-block:: ini
2825
29-
[greendigit_cim]
30-
# Base URL of SZTAKI GreenDIGIT CIM Service.
31-
# Specific endpoints for authentication (/gd-cim-api/v1/token) and publishing (/gd-cim-api/v1/submit)
32-
# will be constructed internally by the messenger.
33-
base_url = https://greendigit-cim.sztaki.hu
26+
[DEFAULT]
27+
# Add the messenger to your list of messengers
28+
messengers = greendigit_cim
3429
35-
# Credentials used to obtain the bearer token
36-
email = user@example.org
37-
password = secret-password
30+
[greendigit_cim]
31+
# Base URL of SZTAKI GreenDIGIT CIM Service.
32+
# Specific endpoints for authentication (/gd-cim-api/v1/token) and publishing (/gd-cim-api/v1/submit)
33+
# will be constructed internally by the messenger.
34+
base_url = https://greendigit-cim.sztaki.hu
3835
39-
# SSL verification (recommended for production)
40-
verify_ssl = true
36+
# Credentials used to obtain the bearer token
37+
email = user@example.org
38+
password = secret-password
4139
42-
[messenger_greendigit_cim]
43-
# Only energy records will be published to this messenger
44-
record_types = energy
45-
```
40+
# SSL verification (recommended for production)
41+
verify_ssl = true
42+
43+
[messenger_greendigit_cim]
44+
# Only energy records will be published to this messenger
45+
record_types = energy
4646
4747
How it Works
4848
------------
4949

5050
The GreenDIGIT CIM messenger performs the following steps:
5151

5252
1. **Verify Endpoints**: Checks that the authentication and publishing endpoints are reachable and that SSL certificates are valid.
53-
2. **Authenticate**: Uses the configured base URL and the credentials provided in caso.conf
54-
to obtain a bearer token from `/gd-cim-api/v1/token`.
55-
3. **Serialize Records**: Converts `EnergyRecord` objects to JSON using field mappings consistent with cASO standards.
56-
4. **Publish Records**: Sends the JSON payload to `/gd-cim-api/v1/submit` via HTTP POST with the bearer token in the Authorization header.
57-
5. **Logging:** Records the number of published records and HTTP response status.
53+
2. **Authenticate**: Uses the configured base URL and the credentials provided in ``caso.conf`` to obtain a bearer token from ``/gd-cim-api/v1/token``.
54+
3. **Serialize Records**: Converts ``EnergyRecord`` objects to JSON using field mappings consistent with cASO standards.
55+
4. **Publish Records**: Sends the JSON payload to ``/gd-cim-api/v1/submit`` via HTTP POST with the bearer token in the ``Authorization`` header.
56+
5. **Logging**: Records the number of published records and HTTP response status.
5857

5958
Testing
6059
-------
6160

6261
To test the messenger:
6362

6463
1. Verify that the SZTAKI CIM endpoints are reachable from the host running cASO.
65-
2. EEnsure the credentials are correctly set in `caso.conf`.
66-
3. Run cASO in `--dry-run` mode to preview `EnergyRecord` objects without publishing.
64+
2. Ensure the credentials are correctly set in ``caso.conf``.
65+
3. Run cASO in ``--dry-run`` mode to preview ``EnergyRecord`` objects without publishing.
6766
4. Check logs for successful publication messages or errors.
6867

6968
Troubleshooting
@@ -72,25 +71,25 @@ Troubleshooting
7271
**Authentication errors:**
7372

7473
- Ensure credentials are correct.
75-
- Verify network connectivity to base URL.
76-
- Ensure the endpoint accepts GET requests.
74+
- Verify network connectivity to ``base_url``.
75+
- Ensure the authentication endpoint is reachable.
7776

7877
**Publishing errors:**
7978

8079
- Check that the publish endpoint is reachable.
81-
- Validate that JSON serialization of `EnergyRecord` is correct.
80+
- Validate that JSON serialization of ``EnergyRecord`` is correct.
8281
- Review HTTP status codes in logs for hints.
8382

8483
**No records published:**
8584

86-
- Ensure extractors have generated `EnergyRecord` objects.
87-
- Confirm that the messenger is listed in `messengers` in `[DEFAULT]` section.
85+
- Ensure extractors have generated ``EnergyRecord`` objects.
86+
- Confirm that the messenger is listed in ``messengers`` in the ``[DEFAULT]`` section.
8887

8988
Technical Details
9089
-----------------
9190

9291
- Uses bearer token authentication.
93-
- Records are serialized using `model_dump_json` with aliases and excluding `None` values.
94-
- HTTP POST to `/gd-cim-api/submit` includes a JSON array of `EnergyRecord` objects.
92+
- Records are serialized using ``model_dump_json`` with aliases and excluding ``None`` values.
93+
- HTTP POST to ``/gd-cim-api/v1/submit`` includes a JSON array of ``EnergyRecord`` objects.
9594
- Verifies SSL and endpoint availability before publishing.
9695
- Logs the number of records sent and HTTP response status.

0 commit comments

Comments
 (0)