npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lskjs/bots-plugin-prometheus

v2.85.1

Published

LSK.js plugin for @lskjs/bots module for telegram, slack, discord, whatsapp, twitter, instagram and vk bots creation

Downloads

109

Readme

LSK.js – bots-plugin-prometheus

@lskjs/bots-plugin-prometheus – LSK.js plugin for @lskjs/bots module for telegram, slack, discord, whatsapp, twitter, instagram and vk bots creation

LSK logo NPM version NPM downloads NPM Dependency count Have TypeScript types Have tree shaking NPM Package size Package size Ask us in Telegram


Table of contents

⌨️ Install

# yarn
yarn i @lskjs/bots-plugin-prometheus bluebird lodash

# npm
npm i @lskjs/bots-plugin-prometheus bluebird lodash

Bots Plugin Prometheus

Bots Plugin Prometheus (@lskjs/bots-plugin-prometheus) - плагин, позволяющий настраивать реакции бота на различные триггеры.

Конфиг плагина находится по пути bots.plugins.prometheus и имеет вид:

bots: {
  plugins: {
    prometheus: {
      projects: [
        //...
      ],
    },
  },
},

Проекты состоят из 4-х частей:

| Rule Part | Type | Required | Description | | ------ | :------: | :------: | ------ | | cron | Array of String\String | - | Позволяет устанавливать расписания срабатываний экшона | | alerts | String | + | Api-URL, где содержатся все алерты прометеуса | |criteria| Object | - | Критерии срабатывания экшона при обработке определенного алерта | | action | Object | + | Экшоны. Описания действий, которые выполняет бот |

cron

Параметр позволяет устанавливать время срабатывания действия бота. Например, если необходимо установить запрос на апи каждую минуту, то конфиг будет выглядеть cron: '* * * * *'.

Официальный пакет крона: node-cron - npm

criteria

Параметр позволяет устанавливать критерии на триггеры срабатывания бота. Например, если необходимо, чтобы бот реагировал только на горящие сообщения state: 'firing'.

action

Параметр задает действия бота. Здесь настраивается, что бот будет делать с найденным алертом.

action могут быть массивами и содержать параллельные действия.

Examples

bots: {
  plugins: {
    prometheus: {
      projects: [
        {
          cron: '* * * * *',
          alerts: 'ALERTS_URL',
          criteria: {
            state: 'firing',
            labels: {
              severity: 'high',
            },
          },
          action: {
            type: 'summary',
            telegram: [telegram.chat1],
            slack: [slack.chat1],
            parseMode: 'MarkdownV2',
            groupBy: 'labels.severity',
          },
        },
        {
          cron: '* * * * *',
          alerts: 'ALERTS_URL',
          criteria: {
            state: 'firing',
            labels: {
              severity: 'warn',
            },
          },
          action: {
            type: 'summary',
            telegram: [telegram.chat2],
            slack: [slack.chat2],
            parseMode: 'MarkdownV2',
            groupBy: 'labels.severity',
          },
        },
      ],
    },
  },
},

Параметры, используемые при настройке критериев:

| Criteria Field | Type | Values | Description | | ------ | :------: | ------ | ------ | | state | String | | Состояние алерта | | labels | String | | Тип алерта |

Список действий, которые реализованы в плагине:

  1. summary - отправка сообщений с информацией об алертах

summary

summary - действие бота, при котором бот отправляет информацию об алерте в заданные чаты. Есть поддержка telegram и slack. 

Params:

| Field | Type | Values | Description | | ------ | :------: | :------: | ------ | | type | String | summary | Название действия | | telegram | Array of Number\Array of String\Number\String | | ID чатов, в которые будет отправлено сообщение | | slack | Array of String\String | | URL хуков, в которые будет отправлено сообщение | | parseMode | String | Markdown, MarkdownV2, HTML | Метод парсинга сообщения | | groupBy | String | | Критерий для группировки алертов |

Example

bots: {
  plugins: {
    prometheus: {
      projects: [
        {
          cron: '* * * * *',
          alerts: 'ALERTS_URL',
          criteria: {
            state: 'firing',
            labels: {
              severity: 'high',
            },
          },
          action: {
            type: 'summary',
            telegram: [telegram.chat1],
            slack: [slack.chat1],
            parseMode: 'MarkdownV2',
            groupBy: 'labels.severity',
          },
        },
      ],
    },
  },
}

📖 License

This project is licensed under the MIT License - see the LICENSE file for details

👥 Contributors

👏 Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b features/fooBar)
  3. Commit your changes (git commit -am 'feat(image): Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

📮 Any questions? Always welcome :)