A Prometheus exporter that exposes metrics from the AlphaSMS API.
Warning
This project is for testing and educational purposes only. Comprehensive error handling and tests are intentionally omitted from this project. Please DO NOT use this in production without adding thorough error checking, proper logging, and comprehensive unit tests. Using code without adequate error handling and tests can cause unexpected behavior and may lead to security vulnerabilities.
- Clone this repository.
git clone https://github.com/yourusername/alphasms_exporter
- Navigate to the project directory.
cd alphasms_exporter
- Set the AlphaSMS API key as an environment variable.
Ensure to replace
your-api-key
with your actual API key.
export ALPHASMS_API_KEY=your-api-key
- Build and Run
go build -o alphasms_exporter
./alphasms_exporter
Now, you can find your metrics at http://localhost:8080/metrics
.
You can build and run this exporter using Docker:
docker build -t alphasms_exporter .
docker run -p 8080:8080 -e ALPHASMS_API_KEY='your-api-key' alphasms_exporter
Replace your-api-key
with your actual API key.
This exporter provides the following metrics:
- alphasms_user_balance_amount: The current balance amount
- alphasms_user_balance_error: The current error code while connecting to api
- alphasms_user_balance_validity: Validity date of balance amount
Exporter will also include exporter specific metrics
To expose more metrics from the AlphaSMS API, you can:
-
Define new methods similar to
GetUserBalance
inalphasms/client.go
-
In
alphasms/exporter.go
, define new Prometheus metrics and update theDescribe
andCollect
methods accordingly. -
Add the invocation of your new methods to the
Collect
method.