Skip to main content

Command-line utility for interfacing with OpsDuty.

Project description

opsduty-python

Command-line utility for interfacing with OpsDuty.

The opsduty-python library is built with two core features in mind:

  • Command-line interface to interact with OpsDuty
  • Programatic way to report heartbeat checkins in Python

Help

See the documentation for more details.

CLI

The opsduty-python package contains a CLI that can be used to interact with OpsDuty.

The preferred way to install the CLI is to use pipx install opsduty-python.

$ opsduty
Usage: opsduty [OPTIONS] COMMAND [ARGS]...

Options:
  --log-format [json|logfmt|console]
                                  [default: console]
  --log-level [error|warning|info|debug]
                                  [default: info]
  --base-url TEXT                 Base URL for API requests to OpsDuty.
  --timeout INTEGER               API request timeout to OpsDuty.  [required]
  --access-token TEXT             Set the bearer token used to communicate
                                  with OpsDuty.  [env var:
                                  OPSDUTY_ACCESS_TOKEN]
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Commands:
  heartbeats  Commands for managing and monitoring heartbeats.
  schedules   Commands for accesing schedules.

  Command-line utility for interfacing with OpsDuty.

Heartbeats

Send periodic heartbeats to OpsDuty using opsduty-python. The heartbeat needs to be configured in OpsDuty before check-ins can be observed. Head over to https://opsduty.io to configure your heartbeats.

Installation

Install using pip install -U opsduty-python.

Alternative 1: Decorator

from opsduty_python.heartbeats.heartbeats import (
    heartbeat_checkin,
)

@heartbeat_checkin(heartbeat="HBXXXX", environment="prod", enabled=True)
def periodic_job():
    pass

Alternative 2: Send heartbeat manually.

from opsduty_python.heartbeats.heartbeats import (
    send_heartbeat_checkin,
)

def periodic_job():
    try:
        pass
    except Exception:
        print("Job failed.")
    else:
        send_heartbeat_checkin(heartbeat="HBXXXX", environment="prod")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opsduty_python-0.2.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opsduty_python-0.2.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file opsduty_python-0.2.2.tar.gz.

File metadata

  • Download URL: opsduty_python-0.2.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for opsduty_python-0.2.2.tar.gz
Algorithm Hash digest
SHA256 50a04b308edcd6c5d75d43a6dd94d077fc2a898d9a77528ecd528f08312c2518
MD5 8b0486acd505a9da289a1570184d91d8
BLAKE2b-256 78abc0a25143e3f81750e8223859c12f986994131b350f2d3723bc40d799e19a

See more details on using hashes here.

File details

Details for the file opsduty_python-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: opsduty_python-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for opsduty_python-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3af580064670169b12b0bc2a2785ea65f34a6bfda4c17ac4bcdb0b1e4f7c519b
MD5 b46510f2da5a30bb3bef4d3301ac3192
BLAKE2b-256 d2f945b14c0dc729f36e009aaa0d713b03caa53f4461b47a40007a01622c2203

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page