Prometheus exporter for getting information about billing account of Yandex Cloud.
First of all, need create service account at Yandex cloud.
After creating service account you need give permissions billing.account.viewer
at level of Organization at Yandex cloud. Next you need issue Authorized keys they will be use for getting IAM-token at this step you need save privateKey
and id
.
Caution
Private key of authorized keys is secret information which make execute operations at Yandex cloud. Private key need store at secure place.
Yc billing exporter once at hour get IAM token and make request to Billing API for getting remaining of money at balance.
For running yc-billing-exporter you need set next environment variables:
YC_BILLING_ID
- Yandex cloud billing IDSERVICE_ACCOUNT_ID
- Service account IDKEY_ID
- Open key ID which you get from step issue Authorized keysSECRET_KEY_PATH
- Path at local file system where storeprivateKey
(Later may be will be add some manager of secrets)
Build docker image
docker build -t yc-billing-exporter .
Create docker-compose.yml
with next content
version: '3'
services:
yc_billing_exporter:
image: yc-billing-exporter:latest
ports:
- "2112:2112"
restart: always
environment:
SERVICE_ACCOUNT_ID: "<YOUR-SERVICE-ACCOUNT-ID>"
KEY_ID: "<YOUR-KEY-ID>"
SECRET_KEY_PATH: "<YOUR-SECRET-KEY-PATH>"
YC_BILLING_ID: "<YOUR-YC-BILLING-ID>"
Run
docker compose up -d
Check correct start
docker compose logs -f
URL with metrics
http://YOUR-IP:2112/metrics
- job_name: 'yc_billing_exporter'
scrape_interval: 60m
static_configs:
- targets: ['yc_billing_exporter_ip:6789']
- alert: yandex_cloud_billing
expr: yc_billing_balance{job="yc_billing_exporter"} < 50000
for: 20m
labels:
severity: warning
annotations:
summary: "{{ $labels.instance }}: At Yandex cloud less than 50 000 rubles"
description: "Your balance at danger zone"