{"id":15528555,"url":"https://github.com/mbovo/pdh","last_synced_at":"2025-07-05T17:10:03.913Z","repository":{"id":38825438,"uuid":"406795323","full_name":"mbovo/pdh","owner":"mbovo","description":"PDH - Pagerduty CLI for humans","archived":false,"fork":false,"pushed_at":"2024-12-09T22:25:49.000Z","size":345,"stargazers_count":16,"open_issues_count":9,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-10T14:51:48.961Z","etag":null,"topics":["cli","cli-app","pagerduty","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbovo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mbovo"}},"created_at":"2021-09-15T14:15:19.000Z","updated_at":"2024-11-29T10:38:52.000Z","dependencies_parsed_at":"2024-02-29T20:27:52.480Z","dependency_job_id":"236500bb-5458-4deb-a0d6-6aa3ebde5093","html_url":"https://github.com/mbovo/pdh","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.07499999999999996,"last_synced_commit":"3be43b8e86122a04511a4c3ccda27d8fa36e3d6f"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovo%2Fpdh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovo%2Fpdh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovo%2Fpdh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbovo%2Fpdh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbovo","download_url":"https://codeload.github.com/mbovo/pdh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230547679,"owners_count":18243227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-app","pagerduty","python3"],"created_at":"2024-10-02T11:14:14.909Z","updated_at":"2025-07-05T17:10:03.906Z","avatar_url":"https://github.com/mbovo.png","language":"Python","funding_links":["https://github.com/sponsors/mbovo"],"categories":[],"sub_categories":[],"readme":"# PDH - PagerDuty CLI for humans\n\n[![Tag and build](https://github.com/mbovo/pdh/actions/workflows/build-release.yml/badge.svg)](https://github.com/mbovo/pdh/actions/workflows/build-release.yml) [![Nix](https://github.com/mbovo/pdh/actions/workflows/nix.yml/badge.svg)](https://github.com/mbovo/pdh/actions/workflows/nix.yml)\n\n`PDH` is a new lightweight CLI for pagerduty interaction: uou can handle your incidents triage without leaving your terminal.\nIt also add some nice tricks to automate the incident triage and easy the on-call burden.\n\nSee [docs](./docs) (TBD)\n\n## Install\n\n### Nix\n\nIf you are using [cachix](https://cachix.org) you can use the prebuilt packages:\n\n```bash\ncachix use pdh\n```\n\n```bash\nnix shell github:mbovo/pdh\n```\n\n### Arch linux\n\n```bash\nyay -S pdh\n```\n\n### With docker\n\n```bash\ndocker run -ti -v ~/.config/pdh.yaml:/root/.config/pdh.yaml --rm pdh:0.3.10 inc ls\n```\n\n### With pip\n\n```bash\npip install pdh\u003e=0.3.10\n```\n\n### From source with nix and direnv\n\n```bash\n\ngit clone https://github.com/mbovo/pdh\ndirenv allow pdh\ncd pdh\npdh inc ls -e\n```\n\n### From source with devbox\n\n```bash\ngit clone https://github.com/mbovo/pdh\ndirenv allow pdh\ncd pdh\npdh inc ls -e\n\n```\n\n### From source\n\n```bash\ngit clone https://github.com/mbovo/pdh\ncd pdh\ntask setup\nsource .venv/bin/activate\npdh inc ls -e\n```\n\n## Usage\n\nFirst of all you need to configure `pdh` to talk with PagerDuty's APIs:\n\n```bash\npdh config\n```\n\nThe wizard will prompt you for 3 settings:\n\n- `apikey` is the API key, you can generate it from the user's profile page on pagerduty website\n- `email` the email address of your pagerduty profile\n- `uid` the userID of your account (you can read it from the browser address bar when clicking on \"My Profile\")\n\nSettings are persisted to `~/.config/pdh.yaml` in clear.\n\n### Listing incidents\n\nAssigned to self:\n\n```bash\npdh inc ls\n```\n\nAny other incident currently outstanding:\n\n```bash\npdh inc ls -e\n```\n\n#### Listing incident by team\n\nListing only outstanding alerts only if they are assigned to a specific team:\n\n```bash\npdh inc ls -e --teams mine\n```\n\nSearch for a given team id:\n\n```bash\npdh teams ls\n```\n\nUse specific id (list):\n\n```bash\npdh inc ls -e --team-id \"P1LONJG,P4SEF5R\"\n```\n\n### Sorting incident by field\n\n```bash\npdh inc ls --sort assignee --reverse\n```\n\nIn case the field is not found the cli will notice you and print the list of available fields\n\n```bash\n pdh inc ls -e --sort unkn --reverse\nInvalid sort field: unkn\nAvailable fields: id, assignee, title, status, created_at, last_status_change_at, url\n```\n\nYou can always sort by multiple fields using comma as separator:\n\n```bash\npdh inc ls --sort assignee,status\n```\n\n### Auto ACK incoming incidents\n\nWatch for new incidents every 10s and automatically set them to `Acknowledged`\n\n```bash\npdh inc ls --watch --new --ack --timeout 10\n```\n\n### List all HIGH priority incidents periodically\n\nList incidents assigned to all users every 5s\n\n```bash\npdh inc ls --high --everything --watch --timeout 5\n```\n\n### Resolve specific incidents\n\n```bash\npdh inc resolve INCID0001 INCID0024 INCID0023\n```\n\n### Resolve all incidents related to `Backups`\n\n```bash\npdh inc ls --resolve --regexp \".*Backup.*\"\n```\n\n### Extract custom fields\n\nYou can also extract custom fields from the pagerduty json output:\n\nYou can nested fields using dot notation (i.e `service.summary`)\n\n```bash\npdh inc ls -e --fields service.summary,status,title,assignee,created_at,url\n```\n\nTo understand the available fields you can get the raw json output and inspect it:\n\n```bash\npdh inc ls -e -o raw\n```\n\n\n## Rules\n\n`PDH` support custom scripting applied to your incidents list. These `rules` are in fact any type of executable you can run on your machine.\n\n```bash\npdh inc ls -e --rules-path ./rules/ --rules\n```\n\nThe `apply` subcommand will call the listed executable/script passing along a json to stdin with the incident information. The called script can apply any type of checks/sideffects and output another json to stout to answer the call.\n\nEven though rules can be written in any language it's very straightforward using python:\n\n### Rules: an example\n\nAn example rule can be written in python with the following lines\n\n```python\n#!/usr/bin/env python3\nfrom pdh.rules import rule\n\n@rule\ndef main(alerts, pagerduty, Filters, Transformations):\n\n    # From the given input extract only incidents with the word \"EC2\" in title\n    filtered = Filters.apply(alerts, filters=[\n                    Filters.not_regexp(\"service.summary\", \".*My Service.*\"),\n                    Filters.regexp(\"title\", \".*EC2.*\")\n                ])\n\n    # # auto acknowledge all previously filtered incidents\n    pagerduty.incidents.ack(filtered)\n\n    return filtered\n\nif __name__ == \"__main__\":\n    main()                  # type: ignore\n```\n\n\n```bash\n\n pdh inc ls -e --rules-path ./rules/ --rules\n┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n┃ script ┃ Q1LNI5LNM7RZ2C                                                     ┃ Q1C5KG41H0SZAM                                                                       ┃\n┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n│ ./a.py │  AWS Health Event: us-east-1 EC2 : AWS_EC2_INSTANCE_STOP_SCHEDULED │  AWS Health Event: us-east-1 EC2 : AWS_EC2_INSTANCE_STORE_DRIVE_PERFORMANCE_DEGRADED │\n└────────┴────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────┘\n```\n\nThe default output is `table` with one line for each script run and with one column per each element in the returned object\n\n### Rules: more examples\n\nsee [rules](./rules) for more\n\n## Requirements\n\n- [Taskfile](https://taskfile.dev)\n- Python \u003e=3.10\n- Docker\n\n## Contributing\n\nFirst of all you need to setup the dev environment, using Taskfile:\n\n```bash\ntask setup\n```\n\nThis will create a python virtualenv and install `pre-commit` and `poetry` in your system if you lack them.\n\n## License\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\nSee [](LICENSE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbovo%2Fpdh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbovo%2Fpdh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbovo%2Fpdh/lists"}