Skip to content

Commit

Permalink
[Integration][OpsGenie] - Performance Improvement (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyGis authored Sep 12, 2024
1 parent d6d0f82 commit 52e7b91
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 182 deletions.
132 changes: 99 additions & 33 deletions integrations/opsgenie/.port/resources/blueprints.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"identifier": "opsGenieService",
"description": "This blueprint represents an OpsGenie service in our software catalog",
"title": "OpsGenie Service",
"identifier": "opsGenieTeam",
"description": "This blueprint represents an OpsGenie team in our software catalog",
"title": "OpsGenie Team",
"icon": "OpsGenie",
"schema": {
"properties": {
Expand All @@ -18,53 +18,112 @@
"format": "url",
"icon": "DefaultProperty"
},
"tags": {
"oncallUsers": {
"type": "array",
"title": "Current Oncalls",
"items": {
"type": "string"
},
"title": "Tags",
"icon": "DefaultProperty"
"type": "string",
"format": "user"
}
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
},
{
"identifier": "opsGenieSchedule",
"description": "This blueprint represents a OpsGenie schedule in our software catalog",
"title": "OpsGenie Schedule",
"icon": "OpsGenie",
"schema": {
"properties": {
"timezone": {
"title": "Timezone",
"type": "string"
},
"oncallTeam": {
"type": "string",
"title": "OnCall Team",
"description": "Name of the team responsible for this service",
"icon": "DefaultProperty"
"description": {
"title": "Description",
"type": "string"
},
"teamMembers": {
"icon": "TwoUsers",
"users": {
"title": "Users",
"type": "array",
"items": {
"type": "string",
"format": "user"
},
"title": "Team Members",
"description": "Members of team responsible for this service"
}
},
"oncallUsers": {
"icon": "TwoUsers",
"startDate": {
"title": "Start Date",
"type": "string",
"format": "date-time"
},
"endDate": {
"title": "End Date",
"type": "string",
"format": "date-time"
},
"rotationType": {
"type": "string",
"title": "Rotation Type"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"ownerTeam": {
"title": "Owner Team",
"target": "opsGenieTeam",
"required": false,
"many": false
}
}
},
{
"identifier": "opsGenieService",
"description": "This blueprint represents an OpsGenie service in our software catalog",
"title": "OpsGenie Service",
"icon": "OpsGenie",
"schema": {
"properties": {
"description": {
"type": "string",
"title": "Description",
"icon": "DefaultProperty"
},
"url": {
"title": "URL",
"type": "string",
"description": "URL to the service",
"format": "url",
"icon": "DefaultProperty"
},
"tags": {
"type": "array",
"items": {
"type": "string",
"format": "user"
"type": "string"
},
"title": "Oncall Users",
"description": "Who is on call for this service"
"title": "Tags",
"icon": "DefaultProperty"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {
"teamSize": {
"title": "Team Size",
"icon": "DefaultProperty",
"description": "Size of the team",
"calculation": ".properties.teamMembers | length",
"type": "number"
"mirrorProperties": {
"oncallUsers": {
"title": "Current Oncalls",
"path": "ownerTeam.oncallUsers"
}
},
"calculationProperties": {
},
"aggregationProperties": {
"numberOfOpenIncidents": {
"title": "Number of open incidents",
Expand All @@ -86,7 +145,14 @@
}
}
},
"relations": {}
"relations": {
"ownerTeam": {
"title": "Owner Team",
"target": "opsGenieTeam",
"required": false,
"many": false
}
}
},
{
"identifier": "opsGenieIncident",
Expand Down
59 changes: 53 additions & 6 deletions integrations/opsgenie/.port/resources/port-app-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: team
selector:
query: 'true'
port:
entity:
mappings:
identifier: .id
title: .name
blueprint: '"opsGenieTeam"'
properties:
description: .description
url: .links.web
- kind: schedule
selector:
query: 'true'
apiQueryParams:
expand: rotation
port:
itemsToParse: .rotations
entity:
mappings:
identifier: .id + "_" + .item.id
title: .name + "_" + .item.name
blueprint: '"opsGenieSchedule"'
properties:
timezone: .timezone
description: .description
startDate: .item.startDate
endDate: .item.endDate
rotationType: .item.type
users: '[.item.participants[] | select(has("username")) | .username]'
relations:
ownerTeam: .ownerTeam.id
- kind: service
selector:
query: 'true'
port:
entity:
mappings:
identifier: .name | gsub("[^a-zA-Z0-9@_.:/=-]"; "-") | tostring
identifier: .id
title: .name
blueprint: '"opsGenieService"'
properties:
description: .description
url: .links.web
tags: .tags
oncallTeam: .__team.name
teamMembers: '[.__team.members[].user.username]'
oncallUsers: .__oncalls.onCallRecipients
relations:
ownerTeam: .teamId
- kind: alert
selector:
query: 'true'
apiQueryParams:
status: open
port:
entity:
mappings:
Expand All @@ -40,10 +74,12 @@ resources:
description: .description
integration: .integration.name
relations:
relatedIncident: .__relatedIncident.id
relatedIncident: 'if (.alias | contains("_")) then (.alias | split("_")[0]) else null end'
- kind: incident
selector:
query: 'true'
apiQueryParams:
status: open
port:
entity:
mappings:
Expand All @@ -60,4 +96,15 @@ resources:
updatedAt: .updatedAt
description: .description
relations:
services: '[.__impactedServices[] | .name | gsub("[^a-zA-Z0-9@_.:/=-]"; "-") | tostring]'
services: .impactedServices
- kind: schedule-oncall
selector:
query: 'true'
port:
entity:
mappings:
identifier: .ownerTeam.id
title: .ownerTeam.name
blueprint: '"opsGenieTeam"'
properties:
oncallUsers: .__currentOncalls.onCallRecipients
3 changes: 3 additions & 0 deletions integrations/opsgenie/.port/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ features:
- kind: alert
- kind: service
- kind: incident
- kind: schedule
- kind: team
- kind: schedule-on-call
configurations:
- name: apiToken
required: true
Expand Down
16 changes: 16 additions & 0 deletions integrations/opsgenie/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

## 0.2.0 (2024-09-09)


### Improvements

- Added new kinds for `team`, `schedule` and `schedule-oncall`
- Added support for filtering data from OpsGenie API to fetch only required data
- Introduced logs to facilitate easier debugging of integration issues

### Breaking Changes

- Removed extra API calls for fetching impacted services, improving performance with existing incident-service relations
- Removed extra API calls for relating alerts to incidents, using JQ for better performance and accuracy
- Changed `OpsGenieService` blueprint by removing team properties and making it a relation to team blueprint


## 0.1.77 (2024-09-05)


Expand Down
Loading

0 comments on commit 52e7b91

Please sign in to comment.