GithubHelp home page GithubHelp logo

mxssl / selectel-billing-exporter Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 4.0 2.05 MB

Prometheus exporter для получения информации по биллингу аккаунта в хостинге Selectel

Dockerfile 8.35% Makefile 14.51% Go 77.14%
prometheus prometheus-exporter selectel selectel-api selectel-vpc-api go golang selectel-billing-exporter

selectel-billing-exporter's Introduction

Selectel Billing Exporter

Prometheus exporter для получения информации по биллингу аккаунта облака Selectel.

Как работает экспортер

Экспортер раз в час ходит по url https://api.selectel.ru/v3/balances с токеном в запросе, получает в json формате инфу по балансу средств на счете и отдает ее по url /metrics в формате prometheus.

Для работы экспортера нужно получить API токен

Как запустить

Запуск с помощью docker-compose

Создаем docker-compose.yml файл:

version: '3'
services:
  selectel_exporter:
    image: mxssl/selectel-billing-exporter:1.1.4
    ports:
      - "6789:80"
    restart: always
    environment:
      TOKEN: <тут_указываем_токен>

Запускаем экспортер:

docker compose up -d

Проверить работу экспортера:

docker compose ps
docker compose logs

Метрики доступны по url your_ip:6789/metrics

Kubernetes

helm

Установка helm чарта

Создание манифестов вручную

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: selectel-billing
  namespace: exporters
spec:
  selector:
    matchLabels:
      component: selectel-billing
  template:
    metadata:
      labels:
        component: selectel-billing
    spec:
      containers:
        - name: exporter
          image: mxssl/selectel-billing-exporter:1.1.4
          command: ["./app"]
          ports:
            - containerPort: 80
          env:
            - name: TOKEN
              value: <YOUR-TOKEN>

---
apiVersion: v1
kind: Service
metadata:
  name: selectel-billing
  namespace: exporters
spec:
  ports:
    - name: exporter
      port: 6789
      targetPort: 80
  selector:
    component: selectel-billing
kubectl apply -n exporters -f your-file.yaml

Внутри кластера метрики будут доступны по адресу selectel-billing.exporters.svc.cluster.local:6789/metrics

Настройка для prometheus

  - job_name: 'selectel_billing'
    scrape_interval: 60m
    static_configs:
      - targets: ['exporter_address:6789']

Пример алерта для alertmanager

- alert: selectel_billing
  expr: selectel_billing_final_sum{job="selectel_billing"} / 100 < 30000
  for: 180s
  labels:
    severity: warning
  annotations:
    summary: "{{ $labels.instance }}: В хостинге Selectel на счете меньше 30 000 рублей"
    description: "Необходимо пополнить счет в хостинге Selectel"

Дашборд для графаны

Дашборд

selectel-billing-exporter's People

Contributors

darwinnn avatar dependabot[bot] avatar lspresent avatar mxssl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.