Monitor HTTP(S) URL Endpoints Using Ciao
Tags: ciao, monitoring, devops, cloudopz
Published: 2021-01-04 16:19:56

### - [ciao](https://github.com/brotandgames/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](#-Build-docker-image)
- [Quick start](#-Quick-start)
- [Check result](#-Check-result)


### 🚀 **[Build docker image](#-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"]
```

- ` Build image `

```
docker build -t alarm-ciao .
```

#### **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/
```

- Notes: The  `__log_level__, __color__, __name__, __status_after__, __url__, __time_stamp__` will be replaced through code

### 🚀 [Quick start](#-Quick-start)
- Start docker container

```
docker-compose up -d
```

- Open http://localhost:3000

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y3utlxy1qn19u9cbuiwn.png)

- Add fake URL and real URL to test
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v81buli5opi6hadajd87.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2rdu26xgq4xe99bdw99a.png)

- Receive alarm through slack-channel

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/otafzwx9aa1bkre2dpg8.png)


**Read More**
- [Monitoror - Gitlab](https://dev.to/vumdao/monitoror-gitlab-5ehe)
- [SQLPad - Quick Start With Docker](https://dev.to/vumdao/sqlpad-quick-start-with-docker-2heh)
- [Online-CV With Google-Cloud Run](https://dev.to/vumdao/online-cv-with-google-cloud-run-3la)
- [Gitlab Ancestor Check Branches](https://dev.to/vumdao/gitlab-ancestor-check-branches-4gkg)
- [HAProxy With Resolvers In Case Of AWS Application LoadBalancer](https://dev.to/vumdao/haproxy-with-resolvers-in-case-of-aws-application-loadbalancer-d1n)
- [How To Set HTTP-Request Header In Haproxy](https://dev.to/vumdao/how-to-set-http-request-header-in-haproxy-48bd)
- [How To Block IP Addresses In HAProxy](https://dev.to/vumdao/how-to-block-ip-addresses-in-haproxy-3f84)
- [How To Drop A Postgres Role/User With privileges](https://dev.to/vumdao/how-to-drop-a-postgres-role-user-with-privileges-2h1i)
- [Create An Ubuntu 20.04 Server Using Vagrant](https://dev.to/vumdao/create-an-ubuntu-20-04-server-using-vagrant-3d2i)
- [Ansible Vault Quick Start](https://dev.to/vumdao/ansible-vault-quick-start-4f51)
- [Create Alarm Clocker Using Python And SystemD](https://dev.to/vumdao/create-alarm-clocker-using-python-and-systemd-31d1)
- [5 Minutes Travellist-laravel-Demo](https://dev.to/vumdao/5-minutes-travellist-laravel-demo-2fcj)


<h3 align="center">
  <a href="https://dev.to/vumdao">:stars: Blog</a>
  <span> · </span>
  <a href="https://vumdao.hashnode.dev/">Web</a>
  <span> · </span>
  <a href="https://www.linkedin.com/in/vu-dao-9280ab43/">Linkedin</a>
  <span> · </span>
  <a href="https://www.linkedin.com/groups/12488649/">Group</a>
  <span> · </span>
  <a href="https://www.facebook.com/CloudOpz-104917804863956">Page</a>
  <span> · </span>
  <a href="https://twitter.com/VuDao81124667">Twitter :stars:</a>
</h3>