Giter Site home page Giter Site logo

docker-swarm-scaler's Introduction

Docker Swarm Scaler as golang package

Build Status Coverage Status

Features

  • Up and Down scaling of docker swarm services
  • AWS ECR access to update distributed swarm images

Prerequisites

Prometheus

When setting your alerts with Prometheus introduce an additional annotation for service into your rules file

service: "{{ $labels.container_label_com_docker_swarm_service_name }}"

Full example

groups:
- name: containers
  rules:
  - alert: container_eating_memory
    expr: sum(container_memory_rss{container_label_com_docker_swarm_task_name=~".+"}) by (container_label_com_docker_swarm_service_name,instance,image) / 1000000 > 3000
    for: 1m
    labels:
      severity: critical
    annotations:
      service: "{{ $labels.container_label_com_docker_swarm_service_name }}"
      summary: "Container {{ $labels.container_label_com_docker_swarm_service_name }} has high memory consumption"
      description: "{{ $labels.name }} with image {{ $labels.image }} of service {{ $labels.container_label_com_docker_swarm_service_name }} on {{ $labels.instance }} is eating up memory. Usage is {{ humanize $value}}"

Alertmanager

In order to feed the scaler with alerts you need to introduce a webhook receiver

route:
  receiver: 'receiver'

receivers:
  - name: 'receiver'
    webhook_configs:
        - send_resolved: true
          url: http://[SCALER URL]:8083

Alert json payload from Alertmanger will contain the name of your service

{
"annotations": {"service": "[YOUR DOCKER SWARM SERVICE]", "summary": "test", "description": "test"}
}

Full example of valid Alertmanger Webhook json payload

{
  "version": "4",
  "groupKey": "1",
  "status": "firing",
  "alerts": [
    {
      "labels": {"summary": "test", "description": "test"},
      "annotations": {"service": "YOUR DOCKER SWARM SERVICE", "summary": "test", "description": "test"},
      "startsAt": "2012-11-01T22:08:41+00:00",
      "endsAt": "2012-11-01T22:08:41+00:00"
    }
  ]
}

Run in docker compose

version: '3.4'

services:
  scaler_dev:
    image: petertilsen1/docker-tools_scaler:latest
    environment:
        - AWS_ACCESS_KEY_ID=[YOUR ID]
        - AWS_SECRET_ACCESS_KEY=[YOUR ACCESS KEY]
    ports:
      - "8083:8083"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: any
    logging:
      driver: json-file

Authors

Scaler was created by Peter Tilsen

docker-swarm-scaler's People

Watchers

 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.