Kibana Sentinl

Wed, Aug 16, 2017 3-minute read

Kibana is great for looking at logs, but it won’t tell you when something goes wrong unless you’re watching. Sentinl adds that alerting layer, and in this post we install the plugin on Kibana.

One thing to keep in mind up front: install the plugin version that matches your installed Kibana version.

$ RUN /opt/kibana/bin/kibana plugin --install sentinl -u https://github.com/sirensolutions/sentinl/releases/download/tag-4.6.4-4/sentinl.zip

Once it’s installed, open the Kibana web UI, head to the Sentinl tab, and create a new watcher. A watcher is essentially the recipe for an alert, and it pulls together four things:

  • interval: how often (every X minutes/seconds/hours) the check runs
  • input: what it retrieves
  • condition: under which condition it raises an alert
  • action: which channels it notifies

Let’s walk through each one with an example.

Starting with the input: in the scanned logs, we look at entries of type:kube-logs where container_name = drupal-test.

{
  "search": {
    "request": {
      "index": [
        "filebeat-*"
      ],
      "types": [
        "kube-logs"
      ],
      "body": {
        "query": {
          "match": {
            "container_name": {
              "query": "drupal-test",
              "type": "phrase"
            }
          }
        }
      }
    }
  }
}

Condition

Next comes the condition that decides whether those results are worth an alert. If it gets more than 10 hits within the specified period:

payload.hits.total > 10

Action

Finally, the action defines what happens when the condition is met, in this case sending a notification to the specified email address.

Thanks to the throttle period, a message will arrive every 15 minutes. If there is no alert, it is tagged as “level”: “INFO”.

"actions": {
      "email_admin": {
        "throttle_period": "0h15m0s",
        "email": {
          "to": "alarm@localhost",
          "from": "sentinl@localhost",
          "subject": "Sentinl Alarm",
          "priority": "high",
          "body": "Found {{payload.hits.total}} Events"
        }
      }

– Turkish Version –

Kibana Sentinl

Kibana logları incelemek için harika, ama siz başında beklemediğiniz sürece bir şeyler ters gittiğinde sizi uyarmıyor. Sentinl tam da bu uyarı katmanını ekliyor; bu yazımızda da Kibana üzerine Sentinl plugin’ini kuruyoruz.

Baştan dikkat edilmesi gereken bir nokta var: kurulu olan Kibana’ya uygun sürümü kurmak gerekiyor.

$ RUN /opt/kibana/bin/kibana plugin --install sentinl -u https://github.com/sirensolutions/sentinl/releases/download/tag-4.6.4-4/sentinl.zip

Kurulum tamamlandıktan sonra Kibana web UI üzerinden Sentinl sekmesine geçip yeni bir watcher oluşturuyoruz. Watcher aslında bir alert’in tarifi gibi düşünülebilir ve dört şeyi bir araya getirir:

  • interval: kaç dk/sn/saatte bir kontrole başlayacağını
  • input: neleri alacağını
  • condition: hangi koşulda alert vereceğini
  • action: hangi kanallara haberi ileteceğini

Şimdi bunların her birini bir örnekle ele alalım.

input ile başlıyoruz: taranan loglarda type:kube-logs içindekilerin arasından container_name = drupal-test olanları inceliyoruz.

{
  "search": {
    "request": {
      "index": [
        "filebeat-*"
      ],
      "types": [
        "kube-logs"
      ],
      "body": {
        "query": {
          "match": {
            "container_name": {
              "query": "drupal-test",
              "type": "phrase"
            }
          }
        }
      }
    }
  }
}

Condition

Sıradaki adım, bu sonuçların bir alert’e değip değmeyeceğine karar veren koşul. Belirlenen süre içerisinde 10’dan fazla hit alırsa:

payload.hits.total > 10

Action

Son olarak action, koşul sağlandığında ne olacağını tanımlıyor; burada belirlenen maile gönderim sağlıyor.

throttle period sayesinde her 15 dakikada bir mesaj gelecek. Eğer alert yoksa “level”: “INFO” olarak etiketleniyor.

"actions": {
      "email_admin": {
        "throttle_period": "0h15m0s",
        "email": {
          "to": "alarm@localhost",
          "from": "sentinl@localhost",
          "subject": "Sentinl Alarm",
          "priority": "high",
          "body": "Found {{payload.hits.total}} Events"
        }
      }