Important Note: dCache v9.2 is a minimum requirement for the successful operation of the wlcgConverter.
The billing records are read either from Apache Kafka or from dCache's JSON billing files. More information on configuring dCache for the use with Kafka can be found here; for the billing files see Reading billing files instead of Kafka.
The "wlcgConverter" reads dCache billing records from Kafka, or from dCache's JSON billing files, and converts each xroot transfer into one record of the WLCG transfer-monitoring format. The fields of that record and how each is derived are described in docs/RECORD.md.
It is run as a systemd service on any linux machine that has a network connection to the Kafka brokers providing the billing records, or, with billing files, on the host where dCache writes them.
The tool also offers further functionalities, such as:
- sending the converted records to CERN's message broker over TLS, after verifying the broker's certificate
- ip filtering of configurable subnets, that are to be excluded from transmission
- writing the converted records to a local file
Version 2.0 changes the record format. The v1 fields bytes_in, bytes_out, status, error_category and ipv6 are no longer sent; see CHANGELOG.md.
To send records to MONIT, these must be provided beforehand:
- a DN has to be whitelisted at CERN (Mail your request together with a DN to: wlcgmon-tf@cern.ch)
- a certificate file
- a corresponding key file
- a file with the CA certificates that signed the broker's certificate, in PEM format (setting
amq_ca_certs)
Before you can start using the "wlcgConverter" some prerequisites have to be met.
- Install Python 3.10 or newer and the necessary python libraries in a virtual environment.
- Fill in all obligatory information into the "wlcgConverter_config.yaml" configuration file.
- Place files from "wlcgConverterPackage" directory into specified locations.
- Start the service.
The wlcgConverter needs Python 3.10 or newer (tested with 3.10, 3.12 and 3.14) and the python packages listed, with their exact versions, in requirements.txt:
- stomp.py 9.0.0
- PyYAML 6.0.3
- python-dateutil 3.0.0
- kafka-python 3.0.11
The packages are installed into their own virtual environment, /opt/wlcgConverter/venv, so they do not depend on or change the system's Python packages. Create it with a Python 3.10 or newer. On EL9 (RHEL, AlmaLinux, Rocky) the default python3 is 3.9, which is too old; install the python3.12 package instead (yum works the same as dnf there). Run as root, from the repository root:
dnf install python3.12
mkdir -p /opt/wlcgConverter
python3.12 -m venv /opt/wlcgConverter/venv
/opt/wlcgConverter/venv/bin/pip install -r requirements.txt
On other distributions, use any Python 3.10 or newer in place of python3.12.
- Please open the "wlcgConverter_config.yaml" file and provide the fields denoted with ''obligatory".
- You may configure the ones denoted "optional " as well if needed.
- Read the commentaries carefully. Since changing some optional fields may make others obligatory.
- Please do not enter or change information in fields that do not have commentaries indicating to do so.
- Version 2.0 adds obligatory settings:
server_site(the WLCG site name of this storage) andserver_version(the dCache release). Withsend_data: True,amq_port_tlsandamq_ca_certsare obligatory as well; records are only sent over TLS. - The converter checks the configuration at startup and exits with code 2, naming the setting, if one is missing or invalid.
With input: file the converter reads the daily billing files that dCache's billing service writes, instead of a Kafka topic. The records and everything sent are the same.
dCache: the billing service must write JSON: billing.format.json=true (and billing.enable.text=true, the default). That property exists since dCache 10.0. It writes one record per line to <billing.text.dir>/YYYY/MM/billing-YYYY.MM.DD, or to <billing.text.dir>/billing-YYYY.MM.DD with billing.text.flat-dir=true; both layouts are read. billing-error-* files hold copies of the failed records and are not read. dCache's text format is not readable: the converter stops with exit code 2 and says so.
Configuration: input: file and billing_dir (dCache's billing.text.dir, e.g. /var/lib/dcache/billing). kafka_broker_incoming and topic are not needed then. Use one input, never both at once: every record would be sent twice.
Permissions: the user wlcgconverter needs read access to billing_dir, including the month folders dCache creates later. One way is an ACL with a default entry, run as root:
setfacl -R -m u:wlcgconverter:rX /var/lib/dcache/billing
find /var/lib/dcache/billing -type d -exec setfacl -d -m u:wlcgconverter:rX {} +
sudo -u wlcgconverter ls /var/lib/dcache/billing
The converter only reads there; it never writes, moves or deletes billing files.
Read positions: the converter keeps, per file, how far it has read in /var/lib/wlcg_converter/billing_positions.json and saves it only after the broker confirmed a batch. At the first start it begins at the current end of the files, so nothing old is sent. After a stop or an outage it continues where it was, so records written in the meantime are sent afterwards; a batch can arrive twice, but no record is lost. Records are lost only if a file is deleted or compressed before it was read; the converter logs a warning then. Keep the billing files uncompressed for at least a few days.
After a long stop, everything written since then is read and sent to CERN in one go; the converter logs a warning with the number of days at startup. To skip that and start at the end of the files instead, delete /var/lib/wlcg_converter/billing_positions.json before starting it.
Two deliberate choices, which can be changed if a site needs it:
- the read positions file has a fixed path, the systemd unit's state directory, and no setting;
- a fully read file is no longer watched once it is 3 days older (by name) than the newest file; late lines in it after that are not read.
Switching from Kafka: stop the service, set input: file and billing_dir, start it again. It begins at the end of the files, so records written while it was stopped are not sent.
Docker and Kubernetes: mount billing_dir read-only into the container, and keep /var/lib/wlcg_converter on a persistent volume. The emptyDir in k8s/deployment.yaml is lost when the pod is replaced; the converter then starts again at the end of the files.
In the "wlcgConverterPackage" directory you will find the script wlcgConverter.py, the wlcg package it imports, the systemd unit and the config file. These must be copied to the following locations.
The script and the wlcg directory must stay together; never copy the script on its own.
Run these commands as root from within the directory:
cp -r wlcgConverter.py wlcg /opt/wlcgConverter/
cp wlcgConverter.service /etc/systemd/system/
mkdir /etc/wlcg_converter/
cp wlcgConverter_config.yaml /etc/wlcg_converter/
The service runs as the user wlcgconverter, not as root. Create it, and let it read the configuration and the certificate files, which may contain secrets:
useradd -r -s /sbin/nologin wlcgconverter
chown root:wlcgconverter /etc/wlcg_converter/wlcgConverter_config.yaml
chmod 640 /etc/wlcg_converter/wlcgConverter_config.yaml
Give the certificate, key and CA files the same group and mode. systemd creates /var/log/wlcg_converter/ for the log file and /var/lib/wlcg_converter/ for the optional scitags_cache_file, owned by that user; files the service writes there are readable by that user only. With local_dump: True, put path_to_converted_json_file in a directory the user can write, e.g. /var/lib/wlcg_converter/.
The systemd unit starts the converter with the Python of the virtual environment. To run it by hand, e.g. to check a configuration, use the same command:
/opt/wlcgConverter/venv/bin/python /opt/wlcgConverter/wlcgConverter.py /etc/wlcg_converter/wlcgConverter_config.yaml
A missing or invalid setting stops it with exit code 2; systemd does not restart it in that case, so fix the configuration and start the service again.
Run the following commands as root:
systemctl daemon-reload
systemctl start wlcgConverter.service
systemctl status wlcgConverter.service
The latter command simply outputs the status of the service. If the shown status is "active (running)", everything is working as expected.
If the broker does not confirm a batch of records, the converter logs the reason and stops with exit code 1 without marking the batch as processed in Kafka or in the read positions. systemd starts it again after 30 seconds, and it sends that batch again. A record can therefore arrive twice, but it is not lost. systemctl stop lets the converter finish the batch in progress (write, send, commit) before it exits; a second stop signal ends it at once. When running the Docker image without systemd or Kubernetes, start the container with a restart policy, e.g. docker run --restart unless-stopped …, so it is started again after such a stop.
Troubleshooting the service is best done with the information provided by the following command:
journalctl -u wlcgConverter.service
You can file an issue via github.
NOTE: A more convenient packaging option for this software tool is currently being developed. Any help and contribution regarding this is most appreciated.
This software is licensed under Apache License 2.0. Find more information here.