GithubHelp home page GithubHelp logo

xxxcoltxxx / selectel-balance-exporter Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 1.63 MB

Selectel balance exporter for prometheus

Go 80.40% HTML 2.00% Dockerfile 15.48% Shell 2.12%
prometheus-exporter selectel

selectel-balance-exporter's Introduction

Balance exporter for Selectel service

The selectel balance exporter allows exporting balance for each service in selectel to prometheus

How it works

Exporter request balance every hour (by default) and store it value in memory. When prometheus request metrics, exporter send balance value from memory.

Configuration

You must set environment variable:

Command-line flags

  • listen-address - The address to listen on for HTTP requests. (Default: 0.0.0.0:9600)
  • interval - Interval (in seconds) for balance requests. (Default: 3600)
  • retry-interval - Interval (in seconds) for load balance when errors. (Default: 10)
  • retry-limit - Count of tries when error. (Default: 10)

Metrics example

# HELP balance_selectel Balance for service in selectel account
# TYPE balance_selectel gauge
balance_selectel{service="primary"} 10000.54
balance_selectel{service="storage"} 20000.52
balance_selectel{service="vmware"} 0
balance_selectel{service="vpc"} 300000.47

Running with docker

docker run \
    -e SELECTEL_API_KEY=<your-key> \
    -p 9600:9600 \
    --restart=unless-stopped \
    --name selectel-balance-exporter \
    -d \
    xxxcoltxxx/selectel-balance-exporter

Running with docker-compose

Create configuration file. For example, file named docker-compose.yaml:

version: "3"

services:
  selectel-balance-exporter:
    image: xxxcoltxxx/selectel-balance-exporter
    restart: unless-stopped
    environment:
      SELECTEL_API_KEY: <your-key>
    ports:
      - 9600:9600

Run exporter:

docker-compose up -d

Show service logs:

docker-compose logs -f selectel-balance-exporter

Running with systemctl

Set variables you need:

SELECTEL_EXPORTER_VERSION=0.2.0
SELECTEL_EXPORTER_PLATFORM=linux
SELECTEL_EXPORTER_ARCH=amd64
SELECTEL_API_KEY=<your-key>

Download release:

wget https://github.com/xxxcoltxxx/selectel-balance-exporter/releases/download/v${SELECTEL_EXPORTER_VERSION}/selectel-balance-exporter_${SELECTEL_EXPORTER_VERSION}_${SELECTEL_EXPORTER_PLATFORM}_${SELECTEL_EXPORTER_ARCH}.tar.gz
tar xvzf selectel-balance-exporter_${SELECTEL_EXPORTER_VERSION}_${SELECTEL_EXPORTER_PLATFORM}_${SELECTEL_EXPORTER_ARCH}.tar.gz
mv ./selectel-balance-exporter /usr/local/bin/selectel-balance-exporter

Add service to systemctl. For example, file named /etc/systemd/system/selectel_balance_exporter.service:

[Unit]
Description=Selectel Balance Exporter
Wants=network-online.target
After=network-online.target

[Service]
Environment="SELECTEL_API_KEY=${SELECTEL_API_KEY}"
Type=simple
ExecStart=/usr/local/bin/selectel-balance-exporter

[Install]
WantedBy=multi-user.target

Reload systemctl configuration and restart service

systemctl daemon-reload
systemctl restart selectel_balance_exporter

Show service status:

systemctl status selectel_balance_exporter

Show service logs:

journalctl -fu selectel_balance_exporter

selectel-balance-exporter's People

Contributors

metanovii avatar xxxcoltxxx avatar

Stargazers

 avatar  avatar

Watchers

 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.