Git Product home page Git Product logo

prometheusruleloader's Introduction

This tool watches a volume mounted configmap directory and kubernetes events for services with annotations labeled "nordstrom.net/alerts/prometheus" for Prometheus alerting rules. If they are found they are validated and placed into two files (one for annotations and one for configmaps) then the passed enpoint is hit.

Parameters

  • -cmrules - Takes a filename where you would like the configmap rules to be written
  • -svrules - Takes a filename where you would like the service annotation rules to be written
  • -map - Path where the configmap is mounted
  • -endpoint - Endpoint to make a bodyless POST request to (Prometheus uses /-/reload)

All of these parameters will by default use the following envriomental variables:

  • cmrules defaults to 'CM_RULES_LOCATION'
  • svrules defaults to 'SV_RULES_LOCATION'
  • map defaults to 'CONFIG_MAP_LOCATION'
  • endpoint defaults to 'PROMETHEUS_RELOAD_ENDPOINT'

for example:

./PrometheusRuleLoader -cmrules ./cmrules.rules -svrules ./svrules.rules -map ./config -endpoint http://prometheus.cluster.local/-/reload

Service Annotations

The annotation supports either a json string or a json array. The annotation must have the key "nordstrom.net/alerts/prometheus"

Examples:

---
apiVersion: v1
kind: Service
metadata:
  name: fakeservice
  namespace: default
  labels:
    app: fake
  annotations: 
    nordstrom.net/prometheusAlerts: |
      - ALERT TooManyFoosTooFast
        IF sum(rate(fooCounter[1m])) > 1
        FOR 1m
        LABELS { severity = "critical" }
        ANNOTATIONS {
          description = "Rate of foo very high ({{ $value }})."
        }
      - ALERT TooManyLogsTooFast
        IF sum(rate(logCounter[1m])) > 1
        FOR 1m
        LABELS { severity = "warning" }
        ANNOTATIONS {
          description = "Rate of log very high ({{ $value }})."
        }
spec:
  ports:
    - name: foo
      port: 80
  selector:
    app: foo

Other Notes

Every rule is verified and only ones that pass are added to the configuration files. If you see a rule failing to pass you can use the promtool that ships with prometheus to verify it.

prometheusruleloader's People

Contributors

bregor avatar sleepybrett avatar

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.