DEV Community

Cover image for Monitor HTTP(S) URL Endpoints Using Ciao
🚀 Vu Dao 🚀
🚀 Vu Dao 🚀

Posted on • Updated on

Monitor HTTP(S) URL Endpoints Using Ciao

- ciao checks HTTP(S) URL endpoints for a HTTP status code (or errors on the lower TCP stack) and sends a notification on status change via E-Mail or Webhooks.

- It uses Cron syntax to schedule the checks and comes along with a Web UI and a RESTful JSON API.

What’s In This Document

🚀 Build docker image

1. Dockerfile to build image alarm-ciao

Dockerfile



FROM ruby:2.6.5-alpine

# for postgres: postgresql-dev
RUN apk add --no-cache \
        sqlite-dev \
        tzdata \
        yarn

WORKDIR /app

ARG RACK_ENV=production
ENV RACK_ENV=$RACK_ENV

ADD Gemfile* /app/
RUN set -x \
    && apk add --no-cache --virtual .build-deps \
        build-base \
        libxml2-dev \
        libxslt-dev \
    && gem install bundler \
    && bundle install --without development:test --jobs 20 -j"$(nproc)" --retry 3 \
    # Remove unneeded files (cached *.gem, *.o, *.c)
    && rm -rf \
        /usr/local/bundle/cache/*.gem \
        /usr/local/bundle/gems/**/*.c \
        /usr/local/bundle/gems/**/*.o \
    && apk del .build-deps

COPY package.json yarn.lock /app/
RUN set -x \
    && yarn install \
    && rm -rf /tmp/*

COPY . ./

# The command '/bin/sh -c rake assets:precompile' needs the RAILS_MASTER_KEY to be set!?
# https://github.com/rails/rails/issues/32947
#
# Added xz-libs (should be only build-dep) because nokogiri needs liblzma.so.5
# during rake tasks (eg. assets-precompile)
RUN set -x \
    && apk add --no-cache xz-libs \
    && SECRET_KEY_BASE=foo bundle exec rake assets:precompile \
    # Remove folders not needed in resulting image
    && rm -rf \
        /tmp/* \
        app/assets \
        lib/assets \
        node_modules \
        spec \
        tmp/cache \
        vendor/assets

ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_SERVE_STATIC_FILES=true
ENV EXECJS_RUNTIME=Disabled

EXPOSE 3000

VOLUME /app/db/sqlite

CMD ["./start.sh"]


Enter fullscreen mode Exit fullscreen mode
  • Build image


docker build -t alarm-ciao .


Enter fullscreen mode Exit fullscreen mode

2. docker-compose file which sets alarm to slack-channel



version: "3"
services:
  ciao:
    image: alarm-ciao
    container_name: ciao
    ports:
      - '3000:3000'
    environment:
      - 'CIAO_WEBHOOK_ENDPOINT_1=https://hooks.slack.com/services/T1111TT1/A11AA1AAAA1/aAAaAAA11AAAa1AaAAAaAAA1'
      - 'CIAO_WEBHOOK_PAYLOAD_1={"username":"Ciao Check","attachments":[{"fallback":"Required plain-text summary of the attachment.","pretext":"__log_level__","color":"__color__","text":"__time_stamp__","title":"__name__ Status code (__status_after__)","footer":"__url__","footer_icon":"https://miro.medium.com/fit/c/262/262/2*sN7hp_jv8UsChU50y3e6ag.png"}]}'
    volumes:
      - /opt/ciao/data:/app/db/sqlite/


Enter fullscreen mode Exit fullscreen mode
  • Notes: The __log_level__, __color__, __name__, __status_after__, __url__, __time_stamp__ will be replaced through code

🚀 Quick start

  • Start docker container


docker-compose up -d


Enter fullscreen mode Exit fullscreen mode

Alt Text

  • Add fake URL and real URL to test Alt Text

Alt Text

  • Receive alarm through slack-channel

Alt Text

Read More

🌠 Blog · Web · Linkedin · Group · Page · Twitter 🌠

Top comments (0)