Giter Site home page Giter Site logo

Comments (6)

nathanielc avatar nathanielc commented on July 18, 2024

@apsey How would you provide the other information a task needs, like dbrp, type, or possible vars?

from influxdata-docker.

apsey avatar apsey commented on July 18, 2024

Something similar to: https://github.com/rossmcdonald/kapacitor/blob/4db1c8c4dfe6dd9d383c2e15feaa357decf38eff/test.yml

from influxdata-docker.

apsey avatar apsey commented on July 18, 2024

Or maybe kapacitor could have another way of defining alerts at start-up that does not depend on running external commands.

from influxdata-docker.

jsternberg avatar jsternberg commented on July 18, 2024

@nathanielc do you think that's reasonable to build this feature directly into kapacitor or should we make a simple entrypoint script in python to do this?

from influxdata-docker.

nathanielc avatar nathanielc commented on July 18, 2024

@jsternberg Building this into Kapacitor itself is not a good idea, the daemon could be running in many different environments that would make doing this reliably difficult.

Adding a script to this docker conatiner would be much better since the environment is known.

from influxdata-docker.

apsey avatar apsey commented on July 18, 2024

I've added this to my dockerfile wrapper:

#!/bin/bash
# entrypoint.sh
set -ex

TICK_METADATA="/etc/kapacitor/tick_metadata.json"
TICK_ALARMS_FOLDER="/etc/kapacitor/alarms/"

function define_alarm {
  `kapacitor define $1 -type $2 -tick $TICK_ALARMS_FOLDER$3 -dbrp $4`
}
export -f define_alarm

function enable_alarm {
  `kapacitor enable $1`
}
export -f enable_alarm

function configure_all_alarms {
  sleep 60
  alarms=`jq -r '.[]|.name + " " + .type + " " + .tick + " " + .dbrp' $TICK_METADATA`
   while read b; do
    define_alarm $b
    enable_alarm $b
  done <<< "$alarms"
}

if [ "${1:0:1}" = '-' ]; then
    set -- kapacitord "$@"
fi

exec "$@" &
pid="$!"

# configure alarms
configure_all_alarms

# wait indefinitely
while true; do
    tail -f /dev/null & wait ${!}
done
ENV KAPACITOR_VERSION 1.0.0~beta3
RUN wget -q https://dl.influxdata.com/kapacitor/releases/kapacitor_${KAPACITOR_VERSION}_amd64.deb.asc && \
    wget -q https://dl.influxdata.com/kapacitor/releases/kapacitor_${KAPACITOR_VERSION}_amd64.deb && \
    gpg --batch --verify kapacitor_${KAPACITOR_VERSION}_amd64.deb.asc kapacitor_${KAPACITOR_VERSION}_amd64.deb && \
    dpkg -i kapacitor_${KAPACITOR_VERSION}_amd64.deb && \
    rm -f kapacitor_${KAPACITOR_VERSION}_amd64.deb*

RUN apt-get update --fix-missing && apt-get install -yq --no-install-recommends --force-yes \
    sqlite3 \
    vim \
    jq \
    && apt-get clean && \
    rm -rf /var/lib/apt/lists/*

EXPOSE 9092

VOLUME /var/lib/kapacitor

COPY kapacitor.conf /etc/kapacitor/kapacitor.conf
COPY tick_metadata.json /etc/kapacitor
COPY alarms /etc/kapacitor/alarms
COPY entrypoint.sh /opt/local/kapacitor/entrypoint.sh
ENTRYPOINT ["/opt/local/kapacitor/entrypoint.sh"]
CMD ["kapacitord"]

Then I have a folder called alarms with files, such as alarms/kafka_in_messages.tick:

stream
    |from()
        .database('prod_kafka')
        .retentionPolicy('default')
        .measurement('in-message-count')
    // Trigger critical alert if the throughput drops below 100 points per 300s and checked every 300s.
    |deadman(100.0, 300s, lambda: hour("time") >= 4 AND hour("time") <= 23)
        .slack()
        .channel('#channel')

from influxdata-docker.

Related Issues (20)

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.