Skip to content

Latest commit

 

History

History
124 lines (85 loc) · 4.04 KB

readme_en.md

File metadata and controls

124 lines (85 loc) · 4.04 KB

license PRs Welcome BK Pipelines Status

(English Documents Available)

Overview

BK-Monitor custom report Python SDK.

Features

  • [Basic] BK-Monitor custom report API
  • [Basic] convert prometheus metrics to BK-Monitor custom metrics
  • [Basic] periodic reporting daemon
  • [Contrib] Celery worker metrics custom report Blueprint

Getting started

from bk_monitor_report import MonitorReporter 

reporter = MonitorReporter(
    data_id=123,  # BK-Monitor Data ID
    access_token="xx",  # custom report Token
    target="test",   # report identifier
    url="http://xxx:10205/v2/push/",  # report gateway
) 

# generate report data
reporter.generate_report_data()

# report manually
reporter.report()

# start periodic reporting daemon
reporter.start()

Report custom event

from bk_monitor_report import MonitorReporter 

reporter = MonitorReporter(
    data_id=123,  # BK-Monitor Data ID
    access_token="xx",  # custom report Token
    target="test",   # report identifier
    url="http://xxx:10205/v2/push/",  # report gateway
) 

reporter.report_event(
    name="my_event",   # event name
    content="event content",   # event content
    dimension={"a": "b"}  # custom dimensions
)

How to report celery worker's metrics

from bk_monitor_report import MonitorReporter 
from bk_monitor_report.contrib.celery import MonitorReportStep

reporter = MonitorReporter(
    data_id=123,  # BK-Monitor Data ID
    access_token="xx",  # custom report Token
    target="test",   # report identifier
    url="http://xxx:10205/v2/push/",  # report gateway
) 

MonitorReportStep.setup_reporter(reporter)

# init celery app
app = Celery("proj")

# set Blueprint if worker pool is not prefork
from bk_monitor_report.contrib.celery import MonitorReportStep
app.steps["worker"].add(MonitorReportStep)

# connect worker process init signal if worker pool is prefork
from celery.signals import worker_process_init 
worker_process_init.connect(reporter.start, weak=False)

Installation

pip install bk-monitor-report

Usage

Roadmap

Support

BlueKing Community

  • BK-CI:a continuous integration and continuous delivery system that can easily present your R & D process to you.
  • BK-BCS:a basic container service platform which provides orchestration and management for micro-service business.
  • BK-PaaS:an development platform that allows developers to create, develop, deploy and manage SaaS applications easily and quickly.
  • BK-SOPS:an lightweight scheduling SaaS for task flow scheduling and execution through a visual graphical interface.
  • BK-CMDB:an enterprise-level configuration management platform for assets and applications.

Contributing

If you have good ideas or suggestions, please let us know by Issues or Pull Requests and contribute to the Blue Whale Open Source Community.

License

Based on the MIT protocol. Please refer to LICENSE