{"id":18510765,"url":"https://github.com/envato/pagerduty","last_synced_at":"2025-04-13T00:46:32.033Z","repository":{"id":1183159,"uuid":"1083422","full_name":"envato/pagerduty","owner":"envato","description":":pager: A Ruby gem for talking to the Pagerduty Events API","archived":false,"fork":false,"pushed_at":"2024-02-17T02:59:14.000Z","size":193,"stargazers_count":99,"open_issues_count":0,"forks_count":37,"subscribers_count":92,"default_branch":"main","last_synced_at":"2025-04-13T00:46:18.071Z","etag":null,"topics":["gem","pagerduty","ruby"],"latest_commit_sha":null,"homepage":"https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/envato.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-11-15T22:43:32.000Z","updated_at":"2025-04-01T00:49:51.000Z","dependencies_parsed_at":"2024-06-18T14:07:48.654Z","dependency_job_id":"8c5b439c-23f0-4b38-b404-07f8a13bac53","html_url":"https://github.com/envato/pagerduty","commit_stats":{"total_commits":205,"total_committers":20,"mean_commits":10.25,"dds":"0.31219512195121957","last_synced_commit":"1ad0f5444cc963e78678ffdd3e14ac07094634fb"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fpagerduty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fpagerduty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fpagerduty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fpagerduty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/envato","download_url":"https://codeload.github.com/envato/pagerduty/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650432,"owners_count":21139672,"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":["gem","pagerduty","ruby"],"created_at":"2024-11-06T15:24:57.038Z","updated_at":"2025-04-13T00:46:32.010Z","avatar_url":"https://github.com/envato.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pagerduty\n\n[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/envato/pagerduty/blob/HEAD/LICENSE.txt)\n[![Gem Version](https://img.shields.io/gem/v/pagerduty.svg?maxAge=2592000)](https://rubygems.org/gems/pagerduty)\n[![Gem Downloads](https://img.shields.io/gem/dt/pagerduty.svg?maxAge=2592000)](https://rubygems.org/gems/pagerduty)\n[![Build Status](https://github.com/envato/pagerduty/workflows/build/badge.svg?branch=main)](https://github.com/envato/pagerduty/actions?query=workflow%3Abuild+branch%3Amain)\n\nProvides a lightweight Ruby interface for calling the [PagerDuty Events\nAPI][events-v2-docs].\n\n[events-v2-docs]: https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pagerduty'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install pagerduty\n\n## Usage\n\nFirst, obtain an Events API integration key from PagerDuty. Follow the\n[instructions][integration-key-documentation] in PagerDuty's documentation to\nprocure one.\n\n[integration-key-documentation]: https://support.pagerduty.com/docs/services-and-integrations#create-a-generic-events-api-integration\n\n\n### Events API V2\n\n```ruby\n# Instantiate a Pagerduty service object providing an integration key and the\n# desired API version: 2\npagerduty = Pagerduty.build(\n  integration_key: \"\u003cintegration-key\u003e\",\n  api_version:     2\n)\n\n# Trigger an incident providing minimal details\nincident = pagerduty.trigger(\n  summary:  \"summary\",\n  source:   \"source\",\n  severity: \"critical\"\n)\n\n# Trigger an incident providing full context\nincident = pagerduty.trigger(\n  summary:        \"Example alert on host1.example.com\",\n  source:         \"monitoringtool:cloudvendor:central-region-dc-01:852559987:cluster/api-stats-prod-003\",\n  severity:       %w[critical error warning info].sample,\n  timestamp:      Time.now,\n  component:      \"postgres\",\n  group:          \"prod-datapipe\",\n  class:          \"deploy\",\n  custom_details: {\n                    ping_time: \"1500ms\",\n                    load_avg:  0.75\n                  },\n  images:         [\n                    {\n                      src:  \"https://www.pagerduty.com/wp-content/uploads/2016/05/pagerduty-logo-green.png\",\n                      href: \"https://example.com/\",\n                      alt:  \"Example text\",\n                    },\n                  ],\n  links:          [\n                    {\n                      href: \"https://example.com/\",\n                      text: \"Link text\",\n                    },\n                  ],\n  client:         \"Sample Monitoring Service\",\n  client_url:     \"https://monitoring.example.com\"\n)\n\n# Acknowledge and/or resolve the incident\nincident.acknowledge\nincident.resolve\n\n# Provide a client-defined incident key\n# (this can be used to update existing incidents)\nincident = pagerduty.incident(\"\u003cincident-key\u003e\")\nincident.trigger(\n  summary:  \"summary\",\n  source:   \"source\",\n  severity: \"critical\"\n)\nincident.acknowledge\nincident.resolve\n```\n\nSee the [PagerDuty Events API V2 documentation][events-v2-docs] for a\ndetailed description on the parameters you can send when triggering an\nincident.\n\n### Events API V1\n\nThe following code snippet shows how to use the [Pagerduty Events API version\n1](https://v2.developer.pagerduty.com/docs/events-api).\n\n```ruby\n# Instantiate a Pagerduty with a service integration key\npagerduty = Pagerduty.build(\n  integration_key: \"\u003cintegration-key\u003e\",\n  api_version:     1,\n)\n\n# Trigger an incident\nincident = pagerduty.trigger(\n  \"FAILURE for production/HTTP on machine srv01.acme.com\",\n)\n\n# Trigger an incident providing context and details\nincident = pagerduty.trigger(\n  \"FAILURE for production/HTTP on machine srv01.acme.com\",\n  client:     \"Sample Monitoring Service\",\n  client_url: \"https://monitoring.service.com\",\n  contexts:   [\n    {\n      type: \"link\",\n      href: \"http://acme.pagerduty.com\",\n      text: \"View the incident on PagerDuty\",\n    },\n    {\n      type: \"image\",\n      src:  \"https://chart.googleapis.com/chart?chs=600x400\u0026chd=t:6,2,9,5,2,5,7,4,8,2,1\u0026cht=lc\u0026chds=a\u0026chxt=y\u0026chm=D,0033FF,0,0,5,1\",\n    }\n  ],\n  details:    {\n    ping_time: \"1500ms\",\n    load_avg:  0.75,\n  },\n)\n\n# Acknowledge the incident\nincident.acknowledge\n\n# Acknowledge, providing a description and extra details\nincident.acknowledge(\n  \"Engineers are investigating the incident\",\n  {\n    ping_time: \"1700ms\",\n    load_avg:  0.71,\n  }\n)\n\n# Resolve the incident\nincident.resolve\n\n# Resolve, providing a description and extra details\nincident.acknowledge(\n  \"A fix has been deployed and the service has recovered\",\n  {\n    ping_time: \"120ms\",\n    load_avg:  0.23,\n  }\n)\n\n# Provide a client defined incident key\n# (this can be used to update existing incidents)\nincident = pagerduty.incident(\"\u003cincident-key\u003e\")\nincident.trigger(\"Description of the event\")\nincident.acknowledge\nincident.resolve\n```\n\nSee the [PagerDuty Events API V1\ndocumentation](https://v2.developer.pagerduty.com/docs/trigger-events) for a\ndetailed description of the parameters you can send when triggering an\nincident.\n\n### HTTP Proxy Support\n\nOne can explicitly define an HTTP proxy like this:\n\n```ruby\npagerduty = Pagerduty.build(\n  integration_key: \"\u003cintegration-key\u003e\",\n  api_version:     2, # The HTTP proxy settings work with either API version\n  http_proxy:      {\n    host:     \"my.http.proxy.local\",\n    port:     3128,\n    username: \"\u003cmy-proxy-username\u003e\",\n    password: \"\u003cmy-proxy-password\u003e\",\n  }\n)\n\n# Subsequent API calls will then be sent via the HTTP proxy\nincident = pagerduty.trigger(\n  summary:  \"summary\",\n  source:   \"source\",\n  severity: \"critical\"\n)\n```\n\n### Debugging Error Responses\n\nThe gem doesn't encapsulate HTTP error responses from PagerDuty. Here's how to\ngo about debugging these unhappy cases:\n\n```ruby\nbegin\n  pagerduty.trigger(\n    summary:  \"summary\",\n    source:   \"source\",\n    severity: \"critical\"\n  )\nrescue Net::HTTPClientException =\u003e error\n  error.response.code    #=\u003e \"400\"\n  error.response.message #=\u003e \"Bad Request\"\n  error.response.body    #=\u003e \"{\\\"status\\\":\\\"invalid event\\\",\\\"message\\\":\\\"Event object is invalid\\\",\\\"errors\\\":[\\\"Service key is the wrong length (should be 32 characters)\\\"]}\"\nend\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/envato/pagerduty/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvato%2Fpagerduty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenvato%2Fpagerduty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvato%2Fpagerduty/lists"}