Giter Club home page Giter Club logo

errbot-promql's Introduction

errbot-promql

An Errbot plugin that queries Prometheus via it's API

For many of the built-in promql commands to work, you'll need to configure your Prometheus instance to scrape Alertmanagers as well as your hosts via NetData. This is done by default for swarmstack users who have installed Prometheus/Alertmanager/NetData using the swarmstack.yml playbook. If you wish to modify the included commands, consider forking this Github repo and altering promql.py for your own needs. The swarmstack errbot-docker project also includes facilities for you to install locally-modified plugins directly into a Docker container if hosting your own copy via public or private repo isn't an option for you.

If you need an Errbot docker image, see swarmstack/errbot-docker, you will need to configure your Errbot's webserver (documented in that project) before proceeding to configure Errbot plugins such as errbot-promql below.

The default configuration string displayed by calling !plugin config PromQL can be used as-shown below for swarmstack users. Otherwise, replace http://prometheus (below) with your Prometheus server IP or hostname.

Installation

repos install https://github.com/swarmstack/errbot-promql

plugin config PromQL {'PROMQL_URL': 'http://prometheus:9090/api/v1'}

Updating

repos update swarmstack/errbot-promql

Usage

You: help
c3po: 1:46PM
PromQL

Query Prometheus via it's API

promql <query> - Execute a PromQL query against Prometheus and return pretty json results
promql alerts - Current alert counts from Prometheus
promql cpu - Current averaged CPU metrics of all or partial host via NetData from Prometheus
promql cpufree - Current free CPU of all or partial host via NetData from Prometheus
promql lowest - Current lowest free CPU, memory, and root filesystem host via NetData from Pr...
promql lowestcpufree - Current lowest free CPU host via NetData from Prometheus
promql lowestmemfree - Current lowest free memory host NetData from Prometheus
promql lowestrootfree - Current lowest free root filesystem host via NetData from Prometheus
promql memfree - Current free memory of all or partial host via NetData from Prometheus
promql raw <query> - Execute a PromQL query against Prometheus and return raw json results
promql rootfree - Current free root filesystem of all or partial host via NetData from Prometheus

Example

You: promql rootfree
c3po: 1:46 PM
Host: swarm01.example.com: 3.5GB (34%) root filesystem free
Host: swarm02.example.com: 2.2GB (22%) root filesystem free
Host: swarm03.example.com: 2.9GB (29%) root filesystem free

You: promql rootfree 01
c3po: 1:46 PM
Host: swarm01.example.com: 3.5GB (34%) root filesystem free

You: promql lowest
c3po: 1:46 PM
Host: swarm02.example.com: 97.7% cpu idle
Host: swarm03.example.com: 28269MB (93%) memory free/cached
Host: swarm42.example.com: 2.2GB (22%) root filesystem free

You: promql bottomk(1, alertmanager_alerts{state="active"})
c3po: 1:46 PM
{
"status": "success",
"data": {
    "resultType": "vector",
    "result": [
        {
            "metric": {
                "__name__": "alertmanager_alerts",
                "instance": "10.0.6.153:9093",
                "job": "alertmanager",
                "state": "active"
            },
            "value": [
                1540670301.383,
                "0"
            ]
        }
    ]
}
}

errbot-promql's People

Contributors

mh720 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.