Skip to content

Commit

Permalink
Implement workaround for incident id
Browse files Browse the repository at this point in the history
see PagerDuty/go-pagerduty#218

see #8

Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Apr 22, 2020
1 parent 0fc6eb5 commit 870ba07
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions metrics_incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ func (m *MetricsCollectorIncident) Collect(ctx context.Context, callback chan<-
}

for _, incident := range list.Incidents {
// workaround for https://github.com/PagerDuty/go-pagerduty/issues/218
incidentId := incident.ID
if incidentId == "" && incident.Id != "" {
incidentId = incident.Id
}

// info
createdAt, _ := time.Parse(time.RFC3339, incident.CreatedAt)

incidentMetricList.AddTime(prometheus.Labels{
"incidentID": incident.Id,
"incidentID": incidentId,
"serviceID": incident.Service.ID,
"incidentUrl": incident.HTMLURL,
"incidentNumber": uintToString(incident.IncidentNumber),
Expand All @@ -108,7 +114,7 @@ func (m *MetricsCollectorIncident) Collect(ctx context.Context, callback chan<-
for _, acknowledgement := range incident.Acknowledgements {
createdAt, _ := time.Parse(time.RFC3339, acknowledgement.At)
incidentStatusMetricList.AddTime(prometheus.Labels{
"incidentID": incident.Id,
"incidentID": incidentId,
"userID": acknowledgement.Acknowledger.ID,
"time": createdAt.Format(opts.PagerDutyIncidentTimeFormat),
"type": "acknowledgement",
Expand All @@ -119,7 +125,7 @@ func (m *MetricsCollectorIncident) Collect(ctx context.Context, callback chan<-
for _, assignment := range incident.Assignments {
createdAt, _ := time.Parse(time.RFC3339, assignment.At)
incidentStatusMetricList.AddTime(prometheus.Labels{
"incidentID": incident.Id,
"incidentID": incidentId,
"userID": assignment.Assignee.ID,
"time": createdAt.Format(opts.PagerDutyIncidentTimeFormat),
"type": "assignment",
Expand All @@ -129,7 +135,7 @@ func (m *MetricsCollectorIncident) Collect(ctx context.Context, callback chan<-
// lastChange
changedAt, _ := time.Parse(time.RFC3339, incident.LastStatusChangeAt)
incidentStatusMetricList.AddTime(prometheus.Labels{
"incidentID": incident.Id,
"incidentID": incidentId,
"userID": incident.LastStatusChangeBy.ID,
"time": changedAt.Format(opts.PagerDutyIncidentTimeFormat),
"type": "lastChange",
Expand Down

0 comments on commit 870ba07

Please sign in to comment.