Skip to content

Instantly share code, notes, and snippets.

@shairyar
Last active May 17, 2023 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shairyar/2877e2a7024af32969b73b42acdf9fc5 to your computer and use it in GitHub Desktop.
Save shairyar/2877e2a7024af32969b73b42acdf9fc5 to your computer and use it in GitHub Desktop.
Create uptime monitor in AppSignal using GraphQL API
mutation createUptimeMonitorMutation($appId: String!, $uptimeMonitor: UptimeMonitorInput!) {
createUptimeMonitor(appId: $appId, uptimeMonitor: $uptimeMonitor) {
...UptimeMonitor
__typename
}
}
fragment UptimeMonitor on UptimeMonitor {
id
name
url
description
notifierIds
warmupDuration
checkBodyContent
regions
notifiers {
id
name
icon
__typename
}
headers {
key
value
__typename
}
alerts {
...Alert
__typename
}
statusPages {
...StatusPage
__typename
}
__typename
}
fragment Alert on Alert {
id
state
message
metricDigest
createdAt
openedAt
resolvedAt
closedAt
timeframeStartAt
timeframeEndAt
lastValue
peakValue
mean
tags {
key
value
__typename
}
__typename
}
fragment StatusPage on StatusPage {
id
title
hasSsl
forceSsl
hostname
description
threshold
uptimeMonitorIds
__typename
}
@shairyar
Copy link
Author

Variables

{
  "appId": "YOUR-APP-ID",
  "uptimeMonitor": {
    "name": "Test",
    "url": "https://example.com",
    "description": "",
    "notifierIds": [],
    "warmupDuration": 1,
    "headers": [],
    "checkBodyContent": "",
    "regions": [
      "EUROPE",
      "ASIA_PACIFIC",
      "NORTH_AMERICA",
      "SOUTH_AMERICA"
    ]
  }
}

@shairyar
Copy link
Author

shairyar commented May 17, 2023

To update the uptime monitor

mutation updateUptimeMonitorMutation($appId: String!, $id: String!, $uptimeMonitor: UptimeMonitorInput!) {
  updateUptimeMonitor(appId: $appId, id: $id, uptimeMonitor: $uptimeMonitor) {
    ...UptimeMonitor
    __typename
  }
}

fragment UptimeMonitor on UptimeMonitor {
  id
  name
  url
  description
  notifierIds
  warmupDuration
  checkBodyContent
  regions
  notifiers {
    id
    name
    icon
    __typename
  }
  headers {
    key
    value
    __typename
  }
  alerts {
    ...Alert
    __typename
  }
  statusPages {
    ...StatusPage
    __typename
  }
  __typename
}

fragment Alert on Alert {
  id
  state
  message
  metricDigest
  createdAt
  openedAt
  resolvedAt
  closedAt
  timeframeStartAt
  timeframeEndAt
  lastValue
  peakValue
  mean
  tags {
    key
    value
    __typename
  }
  __typename
}

fragment StatusPage on StatusPage {
  id
  title
  hasSsl
  forceSsl
  hostname
  description
  threshold
  uptimeMonitorIds
  __typename
}

@shairyar
Copy link
Author

shairyar commented May 17, 2023

To delete the uptime monitor

mutation deleteUptimeMonitorMutation($appId: String!, $id: String!) {
  deleteUptimeMonitor(appId: $appId, id: $id) {
    ...UptimeMonitor
    __typename
  }
}

fragment UptimeMonitor on UptimeMonitor {
  id
  name
  url
  description
  notifierIds
  warmupDuration
  checkBodyContent
  regions
  notifiers {
    id
    name
    icon
    __typename
  }
  headers {
    key
    value
    __typename
  }
  alerts {
    ...Alert
    __typename
  }
  statusPages {
    ...StatusPage
    __typename
  }
  __typename
}

fragment Alert on Alert {
  id
  state
  message
  metricDigest
  createdAt
  openedAt
  resolvedAt
  closedAt
  timeframeStartAt
  timeframeEndAt
  lastValue
  peakValue
  mean
  tags {
    key
    value
    __typename
  }
  __typename
}

fragment StatusPage on StatusPage {
  id
  title
  hasSsl
  forceSsl
  hostname
  description
  threshold
  uptimeMonitorIds
  __typename
}

Variables

{
  "id": "ID-OF-UPTIME-MONITOR",
  "appId": "YOUR-APP-ID"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment