apache / incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
https://devlake.apache.org/
Apache License 2.0
2.57k stars 516 forks source link

[Feature][PagerDuty] Change Incident Times #7558

Open hayk96 opened 4 months ago

hayk96 commented 4 months ago

Search before asking

Use case

Hello team, regarding the incident timing in PagerDuty, is it possible to make some changes to the dashboard? Specifically, it would be better to display the DURATION time instead of the INCIDENT TIMES.

Description

PagerDuty allows modifications to the timeline of an incident, and in some cases, we use that feature to manually edit the incident time. Therefore, my suggestion is to consider the incident time based on the DURATION field and to use it in the dashboards as well. If you don't mind can you please consider the suggested solution?
Thanks in advance!

image

Related issues

N/A

Are you willing to submit a PR?

Code of Conduct

klesh commented 4 months ago

Hi, are you referring to a Grafana dashboard? If so, you are free to do so, just copy the dashboard and change the SQL you are good to go. You can also submit a PR for the change if you'd like it.

hayk96 commented 3 months ago

Hi @klesh, I have checked and seems this API https://api.pagerduty.com/incidents/{id} does not return that field 😞

example response


{
  "incident": {
    "id": "PT4KHLK",
    "type": "incident",
    "summary": "[#1234] The server is on fire.",
    "self": "https://api.pagerduty.com/incidents/PT4KHLK",
    "html_url": "https://subdomain.pagerduty.com/incidents/PT4KHLK",
    "incident_number": 1234,
    "title": "The server is on fire.",
    "created_at": "2015-10-06T21:30:42Z",
    "updated_at": "2015-10-06T21:40:23Z",
    "status": "acknowledged",
    "incident_key": "baf7cf21b1da41b4b0221008339ff357",
    "service": {
      "id": "PIJ90N7",
      "type": "service_reference",
      "summary": "My Mail Service",
      "self": "https://api.pagerduty.com/services/PIJ90N7",
      "html_url": "https://subdomain.pagerduty.com/service-directory/PIJ90N7"
    },
    "assignments": [
      {
        "at": "2015-11-10T00:31:52Z",
        "assignee": {
          "id": "PXPGF42",
          "type": "user_reference",
          "summary": "Earline Greenholt",
          "self": "https://api.pagerduty.com/users/PXPGF42",
          "html_url": "https://subdomain.pagerduty.com/users/PXPGF42"
        }
      }
    ],
    "assigned_via": "escalation_policy",
    "last_status_change_at": "2015-10-06T21:38:23Z",
    "resolved_at": null,
    "first_trigger_log_entry": {
      "id": "Q02JTSNZWHSEKV",
      "type": "trigger_log_entry_reference",
      "summary": "Triggered through the API",
      "self": "https://api.pagerduty.com/log_entries/Q02JTSNZWHSEKV?incident_id=PT4KHLK",
      "html_url": "https://subdomain.pagerduty.com/incidents/PT4KHLK/log_entries/Q02JTSNZWHSEKV"
    },
    "alert_counts": {
      "all": 2,
      "triggered": 1,
      "resolved": 1
    },
    "is_mergeable": true,
    "escalation_policy": {
      "id": "PT20YPA",
      "type": "escalation_policy_reference",
      "summary": "Another Escalation Policy",
      "self": "https://api.pagerduty.com/escalation_policies/PT20YPA",
      "html_url": "https://subdomain.pagerduty.com/escalation_policies/PT20YPA"
    },
    "teams": [
      {
        "id": "PQ9K7I8",
        "type": "team_reference",
        "summary": "Engineering",
        "self": "https://api.pagerduty.com/teams/PQ9K7I8",
        "html_url": "https://subdomain.pagerduty.com/teams/PQ9K7I8"
      }
    ],
    "pending_actions": [
      {
        "type": "unacknowledge",
        "at": "2015-11-10T01:02:52Z"
      },
      {
        "type": "resolve",
        "at": "2015-11-10T04:31:52Z"
      }
    ],
    "acknowledgements": [
      {
        "at": "2015-11-10T00:32:52Z",
        "acknowledger": {
          "id": "PXPGF42",
          "type": "user_reference",
          "summary": "Earline Greenholt",
          "self": "https://api.pagerduty.com/users/PXPGF42",
          "html_url": "https://subdomain.pagerduty.com/users/PXPGF42"
        }
      }
    ],
    "alert_grouping": {
      "grouping_type": "advanced",
      "started_at": "2015-10-06T21:30:42Z",
      "ended_at": null,
      "alert_grouping_active": true
    },
    "last_status_change_by": {
      "id": "PXPGF42",
      "type": "user_reference",
      "summary": "Earline Greenholt",
      "self": "https://api.pagerduty.com/users/PXPGF42",
      "html_url": "https://subdomain.pagerduty.com/users/PXPGF42"
    },
    "priority": {
      "id": "P53ZZH5",
      "type": "priority_reference",
      "summary": "P2",
      "self": "https://api.pagerduty.com/priorities/P53ZZH5"
    },
    "resolve_reason": null,
    "conference_bridge": {
      "conference_number": "+1-415-555-1212,,,,1234#",
      "conference_url": "https://example.com/acb-123"
    },
    "incidents_responders": [
      {
        "state": "pending",
        "user": {
          "id": "PL7A2O4",
          "type": "user_reference",
          "summary": "Lee Turner",
          "self": "https://api.pagerduty.com/users/PL7A2O4",
          "html_url": "https://subdomain.pagerduty.com/users/PL7A2O4",
          "avatar_url": "https://secure.gravatar.com/avatar/51c673f51f6b483b24c889bbafbd2a67.png?d=mm&r=PG"
        },
        "incident": {
          "id": "PXP12GZ",
          "type": "incident_reference",
          "summary": "Ongoing Incident in Mailroom",
          "self": "https://api.pagerduty.com/incidents/PXP12GZ",
          "html_url": "https://subdomain.pagerduty.com/incidents/PXP12GZ"
        },
        "updated_at": "2018-08-09T14:40:48-07:00",
        "message": "Please help with issue - join bridge at +1(234)-567-8910",
        "requester": {
          "id": "P09TT3C",
          "type": "user_reference",
          "summary": "Jane Doe",
          "self": "https://api.pagerduty.com/users/P09TT3C",
          "html_url": "https://subdomain.pagerduty.com/users/P09TT3C",
          "avatar_url": "https://secure.gravatar.com/avatar/1c747247b75acc1f724e2784c838b3f8.png?d=mm&r=PG"
        },
        "requested_at": "2018-08-09T21:40:49Z"
      }
    ],
    "responder_requests": [
      {
        "incident": {
          "id": "PXP12GZ",
          "type": "incident_reference",
          "summary": "Ongoing Incident in Mailroom",
          "self": "https://api.pagerduty.com/incidents/PXP12GZ",
          "html_url": "https://subdomain.pagerduty.com/incidents/PXP12GZ"
        },
        "requester": {
          "id": "P09TT3C",
          "type": "user_reference",
          "summary": "Jane Doe",
          "self": "https://api.pagerduty.com/users/P09TT3C",
          "html_url": "https://subdomain.pagerduty.com/users/P09TT3C"
        },
        "requested_at": "2018-08-16T14:55:17-07:00",
        "message": "Please help with issue - join bridge at +1(234)-567-8910",
        "responder_request_targets": [
          {
            "responder_request_target": {
              "type": "user",
              "id": "PL7A2O4",
              "incidents_responders": [
                {
                  "state": "pending",
                  "user": {
                    "id": "PL7A2O4",
                    "type": "user_reference",
                    "summary": "Lee Turner",
                    "self": "https://api.pagerduty.com/users/PL7A2O4",
                    "html_url": "https://subdomain.pagerduty.com/users/PL7A2O4",
                    "avatar_url": "https://secure.gravatar.com/avatar/51c673f51f6b483b24c889bbafbd2a67.png?d=mm&r=PG"
                  },
                  "incident": {
                    "id": "PXP12GZ",
                    "type": "incident_reference",
                    "summary": "Ongoing Incident in Mailroom",
                    "self": "https://api.pagerduty.com/incidents/PXP12GZ",
                    "html_url": "https://subdomain.pagerduty.com/incidents/PXP12GZ"
                  },
                  "updated_at": "2018-08-09T14:40:48-07:00",
                  "message": "Please help with issue - join bridge at +1(234)-567-8910",
                  "requester": {
                    "id": "P09TT3C",
                    "type": "user_reference",
                    "summary": "Jane Doe",
                    "self": "https://api.pagerduty.com/users/P09TT3C",
                    "html_url": "https://subdomain.pagerduty.com/users/P09TT3C",
                    "avatar_url": "https://secure.gravatar.com/avatar/1c747247b75acc1f724e2784c838b3f8.png?d=mm&r=PG"
                  },
                  "requested_at": "2018-08-09T21:40:49Z"
                }
              ]
            }
          }
        ]
      }
    ],
    "urgency": "high",
    "custom_fields": [
      {
        "id": "PT4KHEE",
        "type": "field_value",
        "name": "environment",
        "display_name": "Runtime Environment",
        "description": "environment where incident occurred",
        "data_type": "string",
        "field_type": "single_value_fixed",
        "value": "production"
      }
    ]
  }
}
klesh commented 3 months ago

I think it could be calculated by subtracting created_at from resolve_at, no? Assuming resolved_at is not null.

hayk96 commented 3 months ago

Actually no, the number that I want is editable on PagerDuty and you can apply any value there. Seems PD does not provide that value via API. 😐 I think we can close this issue as PD does not support that.

klesh commented 3 months ago

I see. I am closing the issue for now, feel free to reopen it if things have changed.

richard-fletcher commented 3 months ago

@klesh @hayk96 I think this data is available from the analytics endpoint https://developer.pagerduty.com/api-reference/328d94baeaa0e-get-raw-data-single-incident as the field user_defined_effort_seconds

hayk96 commented 3 months ago

Thank you @richard-fletcher, I have checked the API you shared, and seems the user_defined_effort_seconds field shows something else. In my case it was null ("user_defined_effort_seconds": null)

richard-fletcher commented 3 months ago

It may only have a value when the field has been set by the user, did you test this?

hayk96 commented 3 months ago

Hmm, it seems that the value is not updating in real-time. Yesterday, I made some changes and tried calling this API several times but received null. I just double-checked, and now I see that the value has been updated 😄 Thanks again @richard-fletcher it was really helpful!

@klesh, what are the plans regarding this? Can we add this feature in DevLake for calculating PD incident times?

I guess these two fields, seconds_to_resolve and user_defined_effort_seconds, can tell us how much time an incident took. For example, the seconds_to_resolve field shows the incident duration in seconds (resolved_at - created_at). The user_defined_effort_seconds field has a null value by default. What do you think about calculating incident time via this API? If the user_defined_effort_seconds is not null, the incident time can be the same as the seconds_to_resolve field. Otherwise, we can take the value of the user_defined_effort_seconds field.

klesh commented 3 months ago

It sounds good to me, we are open to PRs that implement the feature.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

hayk96 commented 1 month ago

Hi @klesh do you know, are there any plans regarding this feature request?

klesh commented 1 month ago

@hayk96 Not that I know. Would you like to work on it?