Skip to main content

钉钉群告警Handler

通过钉钉群机器人, 发送Python日志到钉钉群

参考钉钉群机器人接口 https://open.dingtalk.com/document/robots/custom-robot-access

安装

pip install dingtalk-log-handler

打包

python setup.py sdist

参数

  • webhook: webhook url for dingtalk open api
  • keyword: allowed message keyword, default 'alarm'
  • secret: secret for dingtalk open api
  • hostname: hostname for identify machine, default local ip address
  • timeout: http request timeout, default 1 second
  • cert_verify: verify SSL certificates or not, default True

使用示例

import logging
import logging.config

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '[%(levelname)s %(asctime)s %(name)s %(funcName)s %(lineno)d %(process)d]\t%(message)s'
        },
    },
    'handlers': {
        'dingtalk':{
            'class': 'dingtalk_log_handler.DingTalkHandler',
            'webhook': 'https://oapi.dingtalk.com/robot/send?access_token=XXXXX',
            # 'secret': '',
            # 'keyword': '',
            'formatter':'verbose',
            'level': 'ERROR',
        },
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose',
        },
    },
    'loggers': {
        '': {
            'handlers': ['dingtalk', 'console'],
            'level': 'INFO',
            'propagate': False,
        },
    }
}

logging.config.dictConfig(LOGGING)
logging.error('testing')

Release files for dingtalk-log-handler 0.0.7

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

Source distribution (sdist)

Source distribution for dingtalk-log-handler 0.0.7
File Size Uploaded
dingtalk-log-handler-0.0.7.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dingtalk-log-handler 0.0.7
File Interpreter ABI Platform
dingtalk_log_handler-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / dingtalk-log-handler-0.0.7.tar.gz

Download URL dingtalk-log-handler-0.0.7.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04aa31c53afe17d6941c845632367e5b5a0ef51c860e053033e7f50c428fd2d4
BLAKE2b-256 checksum
How to use checksums
2652f8df08a24e1a71c421b1753a6f1a607f8ab6a0da04acebe643f1f895f240
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / dingtalk_log_handler-0.0.7-py3-none-any.whl

Download URL dingtalk_log_handler-0.0.7-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c832e22690ac2a0a40c25e6838983f9f86834e76a2a3471e40cb10f7c939e2d9
BLAKE2b-256 checksum
How to use checksums
ed15334955aff040330e5e74ae3d8fbc3f5fee9a5ea4072fb27576d2ee13efa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

1 release file

0.0.3

2 release files

0.0.2

2 release files

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