MCPcopy Index your code
hub / github.com/balerter/balerter

github.com/balerter/balerter @v1.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.3 ↗ · + Follow
382 symbols 1,081 edges 98 files 2 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

balerter Go Report Card Test

A Project in active development. Features may have breaking changes at any time before v1.0.0 version

Balerter is a scripts based alerting system.

In your script you may: - obtain needed data from different data sources (prometheus, clickhouse, postgres, external HTTP API etc.) - analyze data and make a decision about alert status - change Alerts statuses and receive notifications about it

In the example bellow we create one Clickhouse datasource, one scripts source and one alert channel. In the script we run query to clickhouse, check the value and fire the alert (or switch off it)

Full documentation available on https://balerter.com

Example

docker pull balerter/balerter
docker run \
    -v /peth/to/config.yml:/opt/config.yml \
    -v /path/to/scripts:/opt/scripts \ 
    -v /path/to/cert.crt:/home/user/db.crt \
    balerter/balerter -config=/opt/config.yml

Config file config.yml

scripts:
  sources:
    update_interval: 5s
    folder:
      - name: debug-folder
        path: /opt/scripts
        mask: '*.lua'

datasources:
  clickhouse:
    - name: ch1
      host: localhost
      port: 6440
      username: default
      password: secret
      database: default
      ssl_mode: verified_full
      ssl_cert_path: /home/user/db.crt

channels:
  slack:
    - name: slack1
      url: https://hooks.slack.com/services/hash
      message_prefix_success: ':eight_spoked_asterisk: '
      message_prefix_error: ':sos: '

Sample script rps.lua

-- @interval 10s

local minRequestsRPS = 100

local log = require("log")
local ch1 = require("datasource.clickhouse.ch1")

local res, err = ch1.query("SELECT sum(requests) AS rps FROM some_table WHERE date = now()")
if err ~= nil then
    log.error("clickhouse 'ch1' query error: " .. err)
    return
end

local resultRPS = res[1].rps

if resultRPS < minResultRPS then
    alert.error("rps-min-limit", "Requests RPS are very small: " .. tostring(resultRPS))
else
    alert.success("rps-min-limit", "Requests RPS ok"")
end 

Roadmap

For v1.0.0

  • [x] add filters to api /alerts
    • [x] by alert level
    • [x] by alert name
  • [x] stabilize core DB modules
  • [ ] full translate the documentation to English
  • [x] add core module http for send requests from scripts

Other

  • core modules enhancements
    • [ ] add prometheus methods for querying metadata
      • [ ] series
      • [ ] labels
      • [ ] label values
  • [ ] Official grafana dashboard
  • New script sources
    • [ ] Postgres - select scripts from Postgres table
    • [ ] ...
  • new entity: external KV storage - for persist data
  • engines for external KV storage
    • [ ] file
    • [ ] consul
    • [ ] postgres
  • New datasources
    • [ ] MongoDB
    • [ ] ...
  • New channels
    • [ ] email
    • [ ] webhook
    • [ ] rocketchat
    • [ ] ...
  • [ ] chart module enhancement

Extension points exported contracts — how you extend this code

Module (Interface)
(no doc) [13 implementers]
internal/modules/modules.go
Provider (Interface)
(no doc) [9 implementers]
internal/script/manager/manager.go
Provider (Interface)
(no doc) [9 implementers]
internal/storages/manager/manager.go
SendOption (FuncType)
(no doc)
internal/alert/manager/send.go
KVer (Interface)
(no doc) [1 implementers]
internal/modules/kv/kv.go

Core symbols most depended-on inside this repo

String
called by 113
internal/alert/alert/alert.go
Get
called by 38
internal/modules/kv/kv.go
Logger
called by 24
internal/logger/logger.go
Name
called by 13
internal/modules/modules.go
ParseMeta
called by 12
internal/script/script/script.go
Run
called by 9
internal/api/manager/api.go
luaCall
called by 8
internal/alert/manager/lua_call.go
Get
called by 8
internal/runner/runner.go

Shape

Method 179
Function 110
Struct 80
Interface 10
TypeAlias 2
FuncType 1

Languages

Go100%

Modules by API surface

internal/modules/kv/kv.go15 symbols
internal/runner/job_test.go14 symbols
internal/runner/runner.go11 symbols
internal/alert/alert/alert.go11 symbols
internal/modules/log/log.go9 symbols
internal/modules/chart/chart.go9 symbols
internal/alert/manager/manager.go9 symbols
internal/script/script/script_test.go8 symbols
internal/script/script/script.go8 symbols
internal/modules/modules.go8 symbols
internal/alert/manager/lua_call_test.go7 symbols
internal/storages/provider/s3/s3.go6 symbols

For agents

$ claude mcp add balerter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact