https://github.com/woblerr/medusa_exporter
Prometheus exporter for Medusa for Apache Cassandra
https://github.com/woblerr/medusa_exporter
backup cassandra cassandra-medusa collected-metrics docker exporter metrics prometheus prometheus-exporter
Last synced: 3 months ago
JSON representation
Prometheus exporter for Medusa for Apache Cassandra
- Host: GitHub
- URL: https://github.com/woblerr/medusa_exporter
- Owner: woblerr
- License: mit
- Created: 2025-10-15T21:40:27.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-11-28T18:18:35.000Z (8 months ago)
- Last Synced: 2025-11-30T01:34:17.108Z (8 months ago)
- Topics: backup, cassandra, cassandra-medusa, collected-metrics, docker, exporter, metrics, prometheus, prometheus-exporter
- Language: Go
- Homepage:
- Size: 3.02 MB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Medusa Exporter for Apache Cassandra
[](https://github.com/woblerr/medusa_exporter/actions)
[](https://coveralls.io/github/woblerr/medusa_exporter?branch=master)
[](https://goreportcard.com/report/github.com/woblerr/medusa_exporter)
Prometheus exporter for [cassandra-medusa](https://github.com/thelastpickle/cassandra-medusa).
The metrics are collected based on result of `medusa list-backups --output json` command. You need to run exporter on the same host where Medusa was installed or inside Docker.
## Grafana dashboard
To get a dashboard for visualizing the collected metrics, you can use a ready-made dashboard [Medusa Exporter Dashboard](https://github.com/woblerr/medusa_exporter-dashboard) or make your own.
## Collected metrics
### Backup metrics
| Metric | Description | Labels | Additional Info |
| ----------- | ------------------ | ------------- | --------------- |
| `medusa_backup_info` | backup info | backup_name, backup_type, prefix, start_time | Values description:
`1` - info about backup is exist. |
| `medusa_backup_status` | backup status | backup_name, backup_type | Values description:
`0` - backup is complete,
`1` - backup is not complete. |
| `medusa_backup_duration_seconds` | backup duration in seconds | backup_name, backup_type, start_time, stop_time | |
| `medusa_backup_size_bytes` | backup size in bytes | backup_name, backup_type | |
| `medusa_backup_objects` | number of objects in backup | backup_name, backup_type | |
| `medusa_backup_completed_nodes` | number of completed nodes in backup | backup_name, backup_type | |
| `medusa_backup_incomplete_nodes` | number of incomplete nodes in backup | backup_name, backup_type | |
| `medusa_backup_missing_nodes` | number of missing nodes in backup | backup_name, backup_type | |
| `medusa_node_backup_info` | node backup info | backup_name, backup_type, node_fqdn, prefix, release_version, server_type, start_time | Values description:
`1` - info about node backup is exist.
For missing nodes: `release_version`, `server_type`, and `start_time` labels are set to `none`. |
| `medusa_node_backup_status` | node backup status | backup_name, backup_type, node_fqdn | Values description:
`0` - node backup is complete,
`1` - node backup is not complete,
`2` - node is missing. |
| `medusa_node_backup_duration_seconds` | node backup duration in seconds | backup_name, backup_type, node_fqdn, start_time, stop_time | For missing nodes: `start_time` and `stop_time` labels are set to `none`, value is `0`. |
| `medusa_node_backup_size_bytes` | node backup size in bytes | backup_name, backup_type, node_fqdn | For missing nodes: value is `0`. |
| `medusa_node_backup_objects` | number of objects in node backup | backup_name, backup_type, node_fqdn | For missing nodes: value is `0`. |
### Last backup metrics
| Metric | Description | Labels | Additional Info |
| ----------- | ------------------ | ------------- | --------------- |
| `medusa_backup_since_last_completion_seconds` | seconds since the last completed full or differential backup | backup_type | |
| `medusa_backup_last_duration_seconds` | backup duration for the last full or differential backup | backup_type | |
| `medusa_backup_last_size_bytes` | backup size for the last full or differential backup | backup_type | |
| `medusa_backup_last_objects` | number of objects in backup for the last full or differential backup | backup_type | |
### Exporter metrics
| Metric | Description | Labels | Additional Info |
| ----------- | ------------------ | ------------- | --------------- |
| `medusa_exporter_build_info` | information about Medusa exporter | branch, goarch, goos, goversion, revision, tags, version | |
| `medusa_exporter_status` | Medusa exporter get data status | prefix | Values description:
`0` - errors occurred when fetching information from Medusa,
`1` - information successfully fetched from Medusa. |
### Additional description of metrics
For `medusa_backup_duration_seconds` and `medusa_node_backup_duration_seconds` metrics the following logic is applied:
* if backup/node backup is complete then value calculated;
* if backup/node backup is not complete, then value is `0`, labels `stop_time` is `none`;
* for missing nodes: value is `0`, labels `start_time` and `stop_time` are set to `none`.
For missing nodes, `medusa_node_backup_*` metrics are set with default values:
* `medusa_node_backup_info`: labels `release_version`, `server_type`, and `start_time` are set to `none`;
* `medusa_node_backup_status`: value is `2` (missing);
* `medusa_node_backup_duration_seconds`, `medusa_node_backup_size_bytes`, `medusa_node_backup_objects`: value is `0`.
For `medusa_*_last_*` metrics the following logic is applied:
* metrics are calculated only for completed backups;
* if only full completed backups exist, only `backup_type="full"` metrics will be set;
* if only differential backups exist, only `backup_type="differential"` metrics will be set;
* if both types exist, both labels will be set with their respective latest backups;
* metrics are not set if no completed backups exist at all.
* Medusa allows creating only differential backups without full backups - in this case, only `backup_type="differential"` metrics will be available.
## Compatibility with cassandra-medusa versions
The number of collected metrics may vary depending on cassandra-medusa version.
For different versions, some metrics may not be collected or have insignificant label values:
* `cassandra-medusa < v0.27.0`
Changes from [cassandra-medusa/pull/899](https://github.com/thelastpickle/cassandra-medusa/pull/899) PR are required for the exporter.
## Getting Started
### Building and running
```bash
git clone https://github.com/woblerr/medusa_exporter.git
cd medusa_exporter
make build
./medusa_exporter
```
Available configuration flags:
```bash
usage: medusa_exporter []
Flags:
-h, --[no-]help Show context-sensitive help (also try --help-long and --help-man).
--web.telemetry-path="/metrics"
Path under which to expose metrics.
--web.listen-address=:19500 ...
Addresses on which to expose metrics and web interface. Repeatable for multiple
addresses. Examples: `:9100` or `[::1]:9100` for http, `vsock://:9100` for vsock
--web.config.file="" Path to configuration file that can enable TLS or authentication. See:
https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
--collect.interval=600 Collecting metrics interval in seconds.
--medusa.config-file="" Full path to Medusa configuration file.
--medusa.prefix="" Prefix for shared storage.
--log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt, json]
--[no-]version Show application version.
```
#### Additional description of flags
Custom `config` for `medusa` command can be specified via `--medusa.config` flag. Full paths must be specified.
For example, `--medusa.config=/tmp/medusa.conf`.
When `--log.level=debug` is specified - information of values and labels for metrics is printing to the log.
The flag `--web.config.file` allows to specify the path to the configuration for TLS and/or basic authentication.
The description of TLS configuration and basic authentication can be found at [exporter-toolkit/web](https://github.com/prometheus/exporter-toolkit/blob/v0.14.1/docs/web-configuration.md).
### Running as systemd service
* Register `medusa_exporter` (already builded, if not - exec `make build` before) as a systemd service:
```bash
make prepare-service
```
Validate prepared file `medusa_exporter.service` and run:
```bash
sudo make install-service
```
* View service logs:
```bash
journalctl -u medusa_exporter.service
```
* Delete systemd service:
```bash
sudo make remove-service
```
---
Manual register systemd service:
```bash
cp medusa_exporter.service.template medusa_exporter.service
```
In file `medusa_exporter.service` replace `{PATH_TO_FILE}` to full path to `medusa_exporter`.
```bash
sudo cp medusa_exporter.service /etc/systemd/system/medusa_exporter.service
sudo systemctl daemon-reload
sudo systemctl enable medusa_exporter.service
sudo systemctl restart medusa_exporter.service
systemctl -l status medusa_exporter.service
```
### RPM/DEB packages
You can use the already prepared rpm/deb package to install the exporter. Only the medusa_exporter binary and the service file are installed by package.
For example:
```bash
rpm -ql medusa_exporter
/etc/systemd/system/medusa_exporter.service
/usr/bin/medusa_exporter
```
### Running tests
Run the unit tests:
```bash
make test
```
Run the end-to-end tests:
```bash
make test-e2e
```