Skip to main content

InfluxAlert

概览

以非常少的代码实现 InfluxDB 的告警

快速开始

前置需求

需要有 InfluxDB、MongoDB

安装模块

pip3 install InfluxAlert

运行

#!/usr/bin/env python3

import subprocess

from apscheduler.schedulers.blocking import BlockingScheduler
from nb_log import get_logger
from influx_alert.client import Client


influx = Client(influx_host='xx',
                influx_port='8086',
                influx_database='xx',
                influx_username='xx',
                influx_password='xxx',
                influx_ssl=True,
                mongo_host='xxx',
                mongo_port=27017,
                mongo_username='xxx',
                mongo_password='xxx',
                mongo_database='xxx',
                mongo_authsource='admin',
                feishu_app_id='xxx',
                feishu_app_secret='xxx',
                feishu_card_template_id='xxx',
                feishu_card_receive_id='xxx',
                wecom_webhook_url='xxx')

# 任务函数
def alert():
    '''
    任务函数
    '''
    influx.ping.unreachable()
    influx.no_data.node_exporter()
    influx.no_data.windows_exporter()
    log.debug('run 1 time')

# 创建调度器
scheduler = BlockingScheduler()

scheduler.add_job(alert, 'interval', seconds=60, max_instances=1)

# 启动调度器
scheduler.start()

功能支持

通知工具

  • 飞书消息卡片(支持)
  • 企业微信 Markdown(支持)

告警

支持以下告警

  • Ping 不可达
  • Node Exporter 无数据时告警
  • Windows Exporter 无数据时告警

Metadata

Release files for InfluxAlert 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for InfluxAlert 0.1.2
File Size Uploaded Provenance Actions
influxalert-0.1.2.tar.gz 12.0 kB Without provenance Details for influxalert-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for InfluxAlert 0.1.2
File Interpreter ABI Platform Actions
InfluxAlert-0.1.2-py3-none-any.whl Python 3 none any Details for InfluxAlert-0.1.2-py3-none-any.whl

Total release size: 26.4 kB

Release files / influxalert-0.1.2.tar.gz

Download URL influxalert-0.1.2.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
220b950970e5ee56d014b80cb37bef85acb5c10fb9d35bcb673fad21398a2b12
BLAKE2b-256 checksum
How to use checksums
5b9a2f601cc6b3ca3ca37a89d3022cfeeca98367c06011f034e4e64866f40585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / InfluxAlert-0.1.2-py3-none-any.whl

Download URL InfluxAlert-0.1.2-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
710ded87351c7bc41586173693fb8c3cece9935c7f1bf9db899adb2f98a23680
BLAKE2b-256 checksum
How to use checksums
bb2af9743cf6bb8d203c4aecbd2a3e2cc114294c20d5567bcd5cf4ea348695b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for InfluxAlert 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page