# Example

TIP

Chapter in progress...

In this example we have the Prometheus with collected metrics with node_exporter. We will track free memory ratio with metrics node_memory_MemAvailable_bytes and node_memory_MemTotal_bytes

  1. Create the prometheus config file prometheus.yml
global:
  scrape_interval: 5s
scrape_configs:
  - job_name: "node_exporter"
    static_configs:
      - targets: ["node_exporter:9100"]
  1. Create the docker-compose.yml
version: '3'
services:
  prometheus:
    image: "prom/prometheus:v2.29.2"
    volumes:
      - "./prometheus.yml:/etc/prometheus/prometheus.yml"
    ports:
      - "9100:9100"
  node_exporter:
    image: "prom/node-exporter:v1.2.2"
  1. Run docker compose
docker-compose up
  1. Create the balerter config file balerter.hcl
scripts {
  file "demo" { 
    filename = "script.lua"    
  }
}

datasources {
  prometheus "prom1" {
    url = "http://localhost:9100"
  }
}

channels {
  notify "notify1" {}
}
  1. Create the balerter script script.lua
-- @cron */10 * * * * *

local alert = require('alert')
local prom = require('datasource.prometheus.prom1')

alert.error('memalert', 'Foooo!')
  1. Download the Balerter from the releases page (opens new window)

  2. Run the Balerter

balerter -config balerter.hcl
Last Updated: 8/30/2021, 4:06:20 PM