Git Product home page Git Product logo

check_elasticsearch's Introduction

check_elasticsearch

This plugin aims to monitor queries in Elasticsearch by allowing you to run a raw query on a specific or all indexes, or call a saved filter in Kibana. The data returned will be a count (integer) and will also be graphed accordingly. It's intention is to graph counts (=matches) based on query/filter you define.

This plugin is compatible with Elasticsearch 5.x, Nagios / Naemon.

Installation

Python dependencies that are required can be installed as follows:

$ yum install python-docopt python-elasticsearch
or
$ apt install python-docopt python-elasticsearch

Obviously, dependent on what package manager you use.

Configure Elasticsearch to bind on all available interfaces (or as specific interface, but that's not covered below):

Edit: /etc/elasticsearch/elasticsearch.yml to read following:

network.host: 0.0.0.0

Instead of the default, which is:

# network.host: 192.168.0.1

Examples

The plugin allows you to fetch logs matching either a query or a filter.

Retrieve a count that matches a query with syntax example:

$ check_elasticsearch.py --host <host> --index <index> --query <query> --warning <warning> --critical <critical>

Query example using the query mode:

$ check_elasticsearch.py --host "http://<elasticsearch ip>:9200/" --index "filebeat-*" --query "system_process_id=148" --warning 1 --critical 2

Retrieve a count matching a saved Kibana filter with syntax example:

$ check_elasticsearch.py --host <host> --filter <query> --warning <warning> --critical <critical>

Filter example using the filter mode:

$ check_elasticsearch.py --host "http://<elasticsearch ip>:9200/" --filter "some_saved_filter_in_kibana" --warning 1 --critical 2

Example output

$ check_elasticsearch.py --host "http://<elastic ip>:9200" --filter "some_saved_filter_in_kibana" --warning 200 --critical 400
WARNING - Total hits: 264 | hits=264

Available arguments

For a list of available arguments, run this plugin with --help:

$ check_elasticsearch.py --help
Usage:
check_elasticsearch.py --host <host> --index <index> --query <query> --warning <warning> --critical <critical>
check_elasticsearch.py --host <host> --filter <query> --warning <warning> --critical <critical>

DEPENDENCIES:
pip install docopt elasticsearch

Arguments:
HOST    Endpoint to Elasticsearch, eg. http://<ip>:<port>
INDEX   Elastic index to use, eg. rsyslog-* or filebeat-*. Use _all to search all indexes (more resource intensive)
QUERY   Raw Elastic/Lucene query, eg. "received_from=10.0.5.2 and program=systemd and host=10.0.5.10 and @timestamp: [now-5h TO now]"
FILTER  Name of saved filter in Kibana, its index will be used automatically.
WARNING Threshold as integer. eg. 128
CRITICAL Threshold as integer. eg. 299

Examples:
check_elasticsearch.py --host "http://<elastic ip>:9200/" --index "filebeat-*" --query "system_process_id=148" --warning 1 --critical 2
check_elasticsearch.py --host "http://<elastic ip>:9200/" --filter "some_saved_filter_in_kibana" --warning 1 --critical 2

Contributions

Thanks goes to these wonderful people:

  • Oskar Rittsél (@OP5)
  • Jörgen Bertholdsson (@OP5)

check_elasticsearch's People

Contributors

misiupajor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

check_elasticsearch's Issues

New feature

If possilbe, when calling stored filters. Could it be possible to send parameters to the filter?

As in:
A filter is save in Kibana, host:$ARG1$ AND message:"there is no gravity"

And via the plugin send the arg1 parameter when callling?

What is the license?

Thanks for this plugin!

I was wondering what the license is for this software.

Error when talking to Log analytics

Got this when talking to a log analytics server (https and user/password login)

/opt/plugins/custom/check_elasticsearch.py --host https://address --index syslog-* --query "logsource:hostname AND program:logheartbeat" --warning 0 --critical 1
Result code: WARNING
ERROR OUTPUT:
/usr/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py:54: UserWarning: Connecting to address using SSL with verify_certs=False is insecure.
'Connecting to %s using SSL with verify_certs=False is insecure.' % host)
Error: Exception: TransportError(N/A, 'Unable to sniff hosts.')

STANDARD OUTPUT:

Link to Kibana in plugin output

A link to Kibana showing the query/filter result would be nice to have in the plugin output. This will make it easier for users to click through to the loglines, making searching for issues a breeze

Add support for basic auth

When Elasticsearch are behind a basic auth login the plugin wont work.
Have tried do use plugin with a ES behind an Nginx proxy.

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.