Coder Social home page Coder Social logo

redborder / events-counter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 88 KB

Simple utility for counting messages on a Kafka topic.

Home Page: https://redborder.github.io/events-counter/

License: GNU Affero General Public License v3.0

Makefile 4.68% Go 95.32%
redborder redborder-ng rpm service

events-counter's Introduction

Build Status Coverage Status Go Report Card

events-counter

Overview

events-counter is a simple utility that can be used for accounting messages in a Kafka topic. It supports accounting by number of bytes (regardless the numer of messages).

Messages are expected to be on JSON format when counting messages.

events-counter has two independent modules:

  • UUIDCounter
    • Reads messages from a set of input topics.
    • Count the number of bytes of these messages.
    • Sends a message periodically to an output topic with the account of bytes on the inputs topic.
  • CountersMonitor
    • The input topic of the counter monitor is the output topic of the UUIDCounter.
    • Reads messages with the account of bytes. Discards old messages.
    • If the number of total bytes exceeds the limit sends an alert.

events-counter ignores Teldat sensors traffic, so these kind of sensors can send an unlimited amount of bytes.

License

events-counter limits can't be configured. These limits are loaded from a LICENSE file. These licenses must be signed to be considered a valid license. Also, a license has an expiration time and it won't be considered valid after the expiration time.

The public key used to verify the license should be specified at compile time and can't be modified once the binary is compiled. To specify the public key, the application should be compiled like this:

export PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0\nFPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/\n3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQAB\n-----END PUBLIC KEY-----"
make

Note that every line break should be replaced by "\n"

Installing

To install this application ensure you have the GOPATH environment variable set and glide installed.

curl https://glide.sh/get | sh

And then:

  1. Clone this repo and cd to the project

    git clone https://github.com/redBorder/events-counter && cd events-counter
  2. Install dependencies and compile

    make
  3. Install on desired directory

    prefix=/opt/events-counter/ make install

Usage

Usage of events-counter:

--version
    Show version info
--config string
    Config file
--debug
    Print debug info

Configuration

counters:
  batch_timeout_s: 5                     # Max time to wait before send a count message
  batch_max_messages: 1000               # Max number of messages to hold before send a count message
  uuid_key: "sensor_uuid"                # JSON key for the UUID
  kafka:                                 # Kafka configuration
    write_topic: "rb_monitor"            # Topic to send the count
    read_topics:                         # Topics to read messages for accounting
      - "rb_flow"
    attributes:                          # Custom internal rdkafka attributes
      bootstrap.servers: "kafka:9092"
      group.id: "counters"

monitor:
  timer:
    period: 86400                        # Width in seconds of the interval between counters reset (86400 -> 24h)
    offset: 0                            # Offset in seconds to change the start of the interval (0 -> 00:00h)
  kafka:                                 # Kafka configuration
    write_topic: "rb_limits"             # Topic to send the alerts
    read_topics:                         # Topics to read messages with accounting info
      - "rb_monitor"
    attributes:                          # Custom internal rdkafka attributes
      bootstrap.servers: "kafka:9092"
      enable.auto.commit: "false"        # IMPORTANT: Should be set to false
      group.id: "monitor"

licenses_directory: /etc/licenses       # Path to the directory where licenses are stored
organization_mode: false                # Ignore organization_uuid. Count every message as belonging to org "*"

events-counter's People

Contributors

bigomby avatar javiercrg avatar manegron avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

bigomby

events-counter's Issues

Reset signal should not be sent when no licenses are available

Make events-counter specify the organization_uuid when sending a signal to reset counters. The reset signal should only be sent when there is at least one license for the organization.

The organization "*" is the "global organization". A reset signal for the global organization unblocks all sensors.


#redmine-9701

Count message per organization

  • Organization mode
    • Messages from org A are accounted to org A if there is a license for this org.
    • Messages from org B are not accounted if there is no license for org B.
    • Messages with no organization are not accounted.
  • Normal mode:
    • All messages are accounted for the generic organization * regardless the real organization (which may be null).

Monitor messages

Create a component for monitor the count of messages and send an alert to notify that the max number of allowed messages has been reached.

Basic functionality

Create a service that reads JSON messages on a Kafka topic and when a specified limit has been reached it should send an alert message on another Kafka topic so another service can perform the proper action to block the data coming from the sensor.

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.